Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- targets_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/targets"
- objects_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/objects"
- # svmlight data
- train_path = "/Users/nikitakrutoy/playground/ml-practice-homework/hw5/data/svmlin/train"
- with open(train_path, "r") as f:
- objects_file = open(objects_path, "w")
- targets_file = open(targets_path, "w")
- while True:
- line = f.readline()
- if not line:
- break
- temp = line.strip().split()
- target = temp[0] + "\n"
- obj = " ".join(temp[1:]) + "\n"
- objects_file.write(obj)
- targets_file.write(target)
- targets_file.close()
- objects_file.close()
Add Comment
Please, Sign In to add comment