Skip to content

Commit d440106

Browse files
Derek Hao HuDerek Hao Hu
authored andcommitted
Add a problem solution
This problem "Day 6: Multiple Linear Regression: Predicting House Prices" comes from Intro to Statistics contest.
1 parent 8459c07 commit d440106

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎predicting-house-prices.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#predicting-house-prices.py
2+
#Day 6: Multiple Linear Regression: Predicting House Prices
3+
#Intro to Statistics
4+
#By derekhh
5+
#Apr 2, 2016
6+
7+
from sklearn import linear_model
8+
9+
f, n = input().split()
10+
f = int(f)
11+
n = int(n)
12+
13+
clf = linear_model.LinearRegression()
14+
x_train = []
15+
y_train = []
16+
17+
for i in range(n):
18+
tmp = [float(n) for n in input().split()]
19+
x_train.append(tmp[0: len(tmp) - 1])
20+
y_train.append(tmp[len(tmp) - 1])
21+
22+
clf.fit(x_train, y_train)
23+
24+
x_test = []
25+
n = int(input())
26+
for i in range(n):
27+
tmp = [float(n) for n in input().split()]
28+
x_test.append(tmp)
29+
30+
y_test = clf.predict(x_test)
31+
for y in y_test:
32+
print(y)

0 commit comments

Comments
 (0)