Created
March 2, 2014 06:34
-
-
Save zachguo/9302779 to your computer and use it in GitHub Desktop.
ordinary linear regression & print full results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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