Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. targets_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/targets"
  2. objects_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/objects"
  3.  
  4. # svmlight data
  5. train_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/train"
  6.  
  7. with open(train_path, "r") as f:
  8. objects_file = open(objects_path, "w")
  9. targets_file = open(targets_path, "w")
  10. while True:
  11. line = f.readline()
  12. if not line:
  13. break
  14. temp = line.strip().split()
  15. target = temp[0] + "\n"
  16. obj = " ".join(temp[1:]) + "\n"
  17. objects_file.write(obj)
  18. targets_file.write(target)
  19. targets_file.close()
  20. objects_file.close()
Add Comment
Please, Sign In to add comment