-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled4.py
102 lines (37 loc) · 796 Bytes
/
Untitled4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# coding: utf-8
# In[3]:
import pandas as pd
import numpy as np
from sklearn import linear_model
from sklearn.cross_validation import train_test_split
from sklearn.datasets import load_boston
# In[6]:
boston = load_boston()
# In[7]:
boston
# In[14]:
df_x= pd.DataFrame(boston.data,columns = boston.feature_names)
# In[15]:
df_y= pd.DataFrame(boston.target)
# In[16]:
reg = linear_model.LinearRegression()
# In[17]:
df_x.describe()
# In[19]:
x_train, x_test, y_train, y_test = train_test_split(df_x, df_y, test_size=0.2, random_state=4)
# In[20]:
x_train.head()
# In[21]:
y_train.head()
# In[22]:
reg.fit(x_train,y_train)
# In[24]:
a= reg.predict(x_test)
# In[25]:
a
# In[26]:
a[0]
# In[28]:
y_test
# In[29]:
np.mean((a-y_test)**2)