runtests.py 765 B

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