runtests.py 774 B

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