-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSVR.py
44 lines (29 loc) · 839 Bytes
/
SVR.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
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 19 17:44:02 2018
@author: KarthikM
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset = pd.read_csv('SVR Data Set.csv')
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:,2:3]
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
sc_y = StandardScaler()
X = sc_X.fit_transform(X)
y = sc_y.fit_transform(y)
#Creating SVR
from sklearn.svm import SVR
#obj
regressor = SVR(kernel = 'rbf')
#Fitting SVR obj to dataset
regressor.fit(X,y)
y_pred = sc_y.iinverse_transform(regressor.predict(sc_X.transform(np.array([[6.5]]))))
plt.scatter(X,y,color='red')
plt.plot(regressor.predict(X),color = 'blue')
plt.title('Regression model')
plt.xlabel('X axis')
plt.ylabel('Y axis')