-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVM_SVR.py
More file actions
34 lines (27 loc) · 876 Bytes
/
SVM_SVR.py
File metadata and controls
34 lines (27 loc) · 876 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
33
34
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Position_Salaries.csv')
X = dataset.iloc[:,[1]].values
y = dataset.iloc[:,[2]].values
# Splitting the dataset into the Training set and Test set
"""from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)"""
# 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)
from sklearn.svm import SVR
svr=SVR(kernel='rbf')
svr.fit(X,y)
Y_pred=svr.predict(6.5)
Y_pred
plt.scatter(X,y, color='blue')
plt.plot(X, svr.predict(X), color='green')
plt.title('shdjkawhdw')
plt.xlabel('positionsalaries')
plt.ylabel('salary')
plt.show()