Created
January 12, 2017 04:11
-
-
Save jmsword/4a6e88a25c28fbfc32b89a153aac9d82 to your computer and use it in GitHub Desktop.
multivariant anal;ysis
This file contains hidden or 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 as pd | |
import statsmodels.api as sm | |
import statsmodels.formula.api as smf | |
import numpy as np | |
df = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv') | |
df['annual_inc'] = df['Monthly.Income'].map(lambda x: x * 12) | |
df['int_rate'] = df['Interest.Rate'].map(lambda x: round(float(x.rstrip('%')) / 100, 4)) | |
df['home_ownership'] = df['Home.Ownership'] | |
annual_inc = df['annual_inc'] | |
int_rate = df['int_rate'] | |
home_ownership = df['home_ownership'] | |
est1 = smf.ols(formula = 'int_rate ~ annual_inc', data=df).fit() | |
est2 = smf.ols(formula = 'int_rate ~ annual_inc + home_ownership', data=df).fit() | |
print(est1.summary()) | |
print(est2.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment