Skip to content

Commit 0f7c349

Browse files
authored
Add files via upload
1 parent 2fbace1 commit 0f7c349

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Outliers Removal.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# coding: utf-8
3+
4+
# In[20]:
5+
6+
7+
import random
8+
import numpy as np
9+
import pickle
10+
import matplotlib.pyplot as plt
11+
from outlier_cleaner import outlierCleaner
12+
13+
14+
# In[22]:
15+
16+
17+
ages = pickle.load( open("practice_outliers_ages_modified_unix.pkl", "rb") )
18+
net_worths = pickle.load( open("practice_outliers_net_worths_modified_unix.pkl", "rb") )
19+
20+
21+
# In[31]:
22+
23+
24+
ages = np.reshape(np.array(ages), (len(ages), 1))
25+
new_worths = np.reshape(np.array(net_worths), (len(net_worths), 1))
26+
27+
from sklearn.cross_validation import train_test_split
28+
ages_train, ages_test, net_worths_train, net_worths_test = train_test_split(ages, net_worths, test_size=0.1, random_state = 42)
29+
30+
31+
# In[37]:
32+
33+
34+
from sklearn.linear_model import LinearRegression
35+
reg = LinearRegression()
36+
reg.fit(ages_train, net_worths_train)
37+
reg.predict(ages_test)
38+
print('coef:', reg.coef_)
39+
print('intercept:', reg.intercept_)
40+
print('scores:', reg.score(ages_test, net_worths_test))
41+

0 commit comments

Comments
 (0)