Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import numpy as np
  2. from sklearn.manifold import TSNE
  3. import glob
  4. import os
  5. import sys
  6. from numpy import genfromtxt
  7. import matplotlib.pyplot as plt
  8.  
  9. numFilesRead = 0
  10. data = np.zeros((144,1))
  11.  
  12. dataRows = []
  13. dataFiles = []
  14.  
  15. def processData(fullPath) :
  16. global data
  17. global numFilesRead
  18. if ( numFilesRead > 10000) :
  19. return
  20.  
  21. featureData = genfromtxt(fullPath, delimiter=',')
  22. dataRows.append(featureData)
  23.  
  24. pathparts = fullPath.split("/")
  25.  
  26. # dataFiles.append(pathparts[len(pathparts)-1].replace(".features",""))
  27. dataFiles.append(fullPath)
  28. numFilesRead += 1
  29.  
  30.  
  31. for root, dirs, files in os.walk("."):
  32. if ( numFilesRead > 10000) :
  33. break
  34. path = root.split(os.sep)
  35. for fileName in files:
  36. if fileName.endswith(".features") :
  37. fullPath = root +"/"+ fileName
  38. processData(fullPath)
  39.  
  40.  
  41.  
  42. data = np.vstack(dataRows)
  43. print(data)
  44.  
  45. X_embedded = TSNE(n_components=2).fit_transform(data)
  46.  
  47. for i in range(len(X_embedded)) :
  48. print(dataFiles[i] + "," + str(X_embedded[i][0]) + "," + str(X_embedded[i][1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement