-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVR
More file actions
32 lines (26 loc) · 727 Bytes
/
SVR
File metadata and controls
32 lines (26 loc) · 727 Bytes
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
#reading the data
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset=pd.read_csv('Position_Salaries.csv')
X=dataset.iloc[:,1:2].values
Y=dataset.iloc[:, 2].values
#scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
sc_Y = StandardScaler()
X = sc_X.fit_transform(X)
Y = sc_Y.fit_transform(Y)
#fitting the SVR
from sklearn.svm import SVR
regressor=SVR(kernel='rbf')
regressor.fit(X,Y)
#predict
y_predict=sc_Y.inverse_transform(regressor.predict(sc_X.transform(np.array[[6.5]])))
#plot svr
plt.scatter(X,Y,color='red')
plt.plot(X,regressor.predict(X),color='blue')
plt.xlabel('levels')
plt.ylabel('salary')
plt.title('truth or bluff(linear regresson)')
plt.show()