Skip to content

Instantly share code, notes, and snippets.

@ckholmes5
Created September 23, 2016 01:15
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 ckholmes5/154e89f47939e23a876503d9c9bd24a7 to your computer and use it in GitHub Desktop.
Save ckholmes5/154e89f47939e23a876503d9c9bd24a7 to your computer and use it in GitHub Desktop.
#Fitting linear regression model
def linear_regression(neighborhoods):
   neighborhoods_regression = []
   for neighborhood in april.Neighborhood.unique():
       temp = april[april.Neighborhood == neighborhood]
       if len(temp) > 500:
           #Creating test set
           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']
ols.train(temp, test)
           neighborhoods_regression[neighborhood] = float(ols.predict(get_current_conditions()))
   return neighborhoods_regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment