Skip to content

Instantly share code, notes, and snippets.

@jmsword
Created January 12, 2017 04:11
Show Gist options
  • Save jmsword/4a6e88a25c28fbfc32b89a153aac9d82 to your computer and use it in GitHub Desktop.
Save jmsword/4a6e88a25c28fbfc32b89a153aac9d82 to your computer and use it in GitHub Desktop.
multivariant anal;ysis
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