-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSVM_Reg
27 lines (22 loc) · 814 Bytes
/
SVM_Reg
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
[11:07 AM, 9/4/2019] Chandan ML Training.: # SVR
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('50_Startups.csv') """Copy the full file path"""
X = dataset.iloc[:, 1:2].values
Y = dataset.iloc[:, 2].values
# Splitting the dataset into the Training set and Test set
"""from sklearn.model_selection 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.reshape(-1,1))
# Fitting SVR to the dataset
from sklearn.svm import SVR
regressor = SVR(kernel = 'rbf')
regressor.fit(x, y)