Skip to content

Instantly share code, notes, and snippets.

@zachguo
Created March 2, 2014 06:34
Show Gist options
  • Save zachguo/9302779 to your computer and use it in GitHub Desktop.
Save zachguo/9302779 to your computer and use it in GitHub Desktop.
ordinary linear regression & print full results
import pandas
import statsmodels.api as sm
import numpy as np
def print_full(x):
pandas.set_option('display.max_rows', len(x))
print(x)
pandas.reset_option('display.max_rows')
dataframe = pandas.read_csv("turnstile_data_master_with_weather.csv")
dummy_units = pandas.get_dummies(dataframe['UNIT'], prefix='unit')
features = dataframe[['rain', 'precipi', 'Hour', 'meantempi']].join(dummy_units)
values = dataframe[['ENTRIESn_hourly']]
model = sm.OLS(values,features).fit()
# print model.params.shape, features.shape, model.predict().shape
# print model.summary()
# print print_full(model.params)
# print np.inner(features, model.params) == model.predict()
print model.params.tolist()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment