-
Notifications
You must be signed in to change notification settings - Fork 3
/
FINALSVR.py
25 lines (20 loc) · 859 Bytes
/
FINALSVR.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
import pandas as pd
from pandas import DataFrame
from sklearn.cross_validation import train_test_split
import numpy as np
from numpy import ndarray
from sklearn.metrics import r2_score
from sklearn.svm import SVR
from sklearn.preprocessing import MinMaxScaler
df = pd.read_csv("solution.csv")
scaler = MinMaxScaler()
df[['BHK', 'AREA', 'YEARS', 'BATH', 'FLOOR', 'LAT', 'LONG', 'MD_AIRPORT']] = scaler.fit_transform(df[['BHK', 'AREA', 'YEARS', 'BATH', 'FLOOR', 'LAT', 'LONG', 'MD_AIRPORT']])
dfx = df[['BHK', 'AREA', 'YEARS', 'BATH', 'FLOOR', 'LAT', 'LONG', 'MD_AIRPORT']].copy()
dfy = df[['PRICE']].copy()
x_train, x_test, y_train, y_test = train_test_split(dfx,dfy,test_size = 0.3)
model = SVR(kernel='rbf')
model.fit(x_train, y_train)
ans = model.predict(x_test)
normal_ytest = y_test.as_matrix()
result_r2 = r2_score(normal_ytest, ans)
print result_r2