Skip to content

Instantly share code, notes, and snippets.

@ckholmes5
Created September 23, 2016 01:22
Show Gist options
  • Save ckholmes5/f66374f0209bd33261694379cd97035a to your computer and use it in GitHub Desktop.
Save ckholmes5/f66374f0209bd33261694379cd97035a to your computer and use it in GitHub Desktop.
def trees(neighborhoods):
   neighborhoods_trees = {}
   for neighborhood in neighborhoods:
       temp = april[april.Neighborhood == neighborhood]
       if len(temp) > 500:
           test = temp['Taxi_Order'] + temp['Uber_Order']
           #Deleting unnecessary columns
           del temp['Taxi_Order']
           del temp['Uber_Order']
           del temp['Min']
           del temp['Max']
           del temp['Neighborhood']
           del temp['Date']
           del temp['Uber_Share']
           del temp['Unnamed: 0']
           np.random.seed(1)
           randomForest = ensemble.RandomForestClassifier()
           randomForest.fit(temp, test) # fit
           neighborhoods_trees[neighborhood] = (float(randomForest.predict(get_current_conditions())))
   return neighborhoods_trees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment