Skip to content

Instantly share code, notes, and snippets.

@thmain
Created January 7, 2017 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/d4db8d952b4a5464bcaf56e0f322934a to your computer and use it in GitHub Desktop.
Save thmain/d4db8d952b4a5464bcaf56e0f322934a to your computer and use it in GitHub Desktop.
items = [];
for i in range(1,len(lines)):
line = lines[i].split(',');
itemFeatures = {"Class" : line[-1]};
for j in range(len(features)):
#Iterate through the features
f = features[j]; #Get the feature at index j
#The first item in the line is the class, skip it
v = float(line[j]); #Convert value to integer
itemFeatures[f] = v; #Add feature to dict
items.append(itemFeatures); #Append temp dict to items
shuffle(items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment