添加数据
This commit is contained in:
+5
-9
@@ -1,15 +1,12 @@
|
||||
import os
|
||||
import sys
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from sklearn import preprocessing
|
||||
from sklearn import svm
|
||||
from sklearn.model_selection import GridSearchCV, train_test_split
|
||||
from sklearn.pipeline import Pipeline
|
||||
from sklearn.preprocessing import PolynomialFeatures
|
||||
import os
|
||||
import sys
|
||||
curPath = os.path.abspath(os.path.dirname(__file__))
|
||||
rootPath = os.path.split(curPath)[0]
|
||||
sys.path.append(rootPath)
|
||||
sys.path.append("/home/wenyan/Sklearn")
|
||||
import common
|
||||
|
||||
|
||||
@@ -32,11 +29,10 @@ c_range = np.logspace(-5, 15, 11, base=2)
|
||||
gamma_range = np.logspace(-9, 3, 13, base=2)
|
||||
param_grid = [{'svr__kernel': ['rbf', 'linear'], 'svr__C': c_range, 'svr__gamma': gamma_range}]
|
||||
svr = svm.SVR()
|
||||
pipeline = Pipeline([('poly', PolynomialFeatures(3)),
|
||||
('standard', preprocessing.StandardScaler()),
|
||||
pipeline = Pipeline([('standard', preprocessing.StandardScaler()),
|
||||
('minMax', preprocessing.MinMaxScaler()),
|
||||
('svr', svr)])
|
||||
grid = GridSearchCV(pipeline, param_grid, cv=3, n_jobs=10)
|
||||
grid = GridSearchCV(pipeline, param_grid, cv=3, n_jobs=20)
|
||||
clf = grid.fit(x_train, y_train.values.ravel())
|
||||
test_score = grid.score(x_test, y_test)
|
||||
print('测试得分是%s' % test_score)
|
||||
|
||||
Reference in New Issue
Block a user