runtests.py 839 B

1234567891011121314151617181920212223242526272829
  1. import sys
  2. import Vector
  3. import sample
  4. import nearestneighbors
  5. # test classifications on a pickled file of samples and denoting active features with
  6. # sample codes, ex: high.total_packets
  7. # Usage: main.py pickled_sample_file high.total_packets high.time_spent...
  8. def main():
  9. i = 0
  10. sampleList = Vector.readPickledData(sys.argv[1])
  11. featureList = []
  12. for s in sampleList:
  13. featureList.append(Vector.SampleToFeatureVector(s))
  14. activeFeatureStrings = []
  15. for i in range(2, len(sys.argv)):
  16. activeFeatureStrings.append(sys.argv[i])
  17. for f in featureList:
  18. temp = []
  19. for s in activeFeatureStrings:
  20. temp.append(f.sampleInfo[s])
  21. f.activefeatures = temp
  22. # perform classification on f here
  23. nearestneighbors.kNearestNeighbors()
  24. if __name__ == '__main__':
  25. main()