Last active
January 20, 2018 04:30
-
-
Save Kristen-Huber/05499838478bb1a1fb0898f785c5ed31 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Jan 26 16:13:41 2016 | |
@author: Kristen | |
""" | |
import numpy as np | |
import pandas as pd | |
import statsmodels.api as sm | |
loansData=pd.read_csv('loansData.csv') | |
loansData['Interest.Rate']=[float(interest[0:-1])/100 for interest in loansData['Interest.Rate']] | |
loansData['Loan.Length']=[int(length[0:-7])for length in loansData['Loan.Length']] | |
loansData['FICO.Score']=[int(val.split('-')[0]) for val in loansData['FICO.Range']] | |
intrate=loansData['Interest.Rate'] | |
loanamt=loansData['Amount.Requested'] | |
fico=loansData['FICO.Score'] | |
y=np.matrix(intrate).transpose() | |
x1=np.matrix(fico).transpose() | |
x2=np.matrix(loanamt).transpose() | |
x=np.column_stack([x1,x2]) | |
X=sm.add_constant(x) | |
model=sm.OLS(y,X) | |
f=model.fit() | |
print(f.summary()) | |
loansData.to_csv('loansData_clean.csv',header=True, index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment