test_class_KdNN.py 588 B

12345678910111213141516171819
  1. #!/usr/bin/python
  2. import class_KdJamet as kdj
  3. import numpy as np
  4. import sys
  5. if len(sys.argv) != 3:
  6. print "test_class_KdNN.py must be launch with two arguments:"
  7. print " $ test_class_KdNN.py LOG_KdNeuralNetwork_TestCase_Input.csv your_output.csv"
  8. sys.exit(-1)
  9. K = kdj.KdJamet('idMERIS')
  10. tab = np.loadtxt(sys.argv[1], skiprows=1)
  11. KDs = np.zeros(tab.shape,dtype=np.float32)
  12. for i in range(tab.shape[0]):
  13. KDs[i,:] = K.compute_allKd(tab[i,:])
  14. np.savetxt(sys.argv[2],KDs,fmt='%.7f',header="Kd%d Kd%d Kd%d Kd%d Kd%d Kd%d" %(K.WL[0],K.WL[1],K.WL[2],K.WL[3],K.WL[4],K.WL[5]))