Guest User

Untitled

a guest
May 27th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import csv
  2. import random
  3. def loadDataset(filename, split, trainingSet=[] , testSet=[]):
  4. with open(filename, 'rb') as csvfile:
  5. lines = csv.reader(csvfile)
  6. dataset = list(lines)
  7. for x in range(len(dataset)-1):
  8. for y in range(4):
  9. dataset[x][y] = float(dataset[x][y])
  10. if random.random() < split:
  11. trainingSet.append(dataset[x])
  12. else:
  13. testSet.append(dataset[x])
Add Comment
Please, Sign In to add comment