python sklearn svm标准化数据

时间:2018-11-17 08:39:11

标签: python scikit-learn

我正在尝试对标准化数据运行SVC分类器。当我运行以下内容时,它不会停止处理。

import numpy as np
import pandas as pd
import time

from sklearn.model_selection import cross_val_score, GridSearchCV, cross_validate, 
  train_test_split
from sklearn.metrics import accuracy_score, classification_report
from sklearn.svm import SVC
from sklearn.linear_model import LinearRegression
from sklearn.neural_network import MLPClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import StandardScaler, normalize

X_train, X_test, y_train, y_test = train_test_split(x_data, y_data) 
scaler = StandardScaler().fit(X_train)
standardized_X = scaler.transform(X_train)
standardized_X_test = scaler.transform(X_test)
tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4],
                 'C': [1, 10, 100, 1000]},
                {'kernel': ['linear'], 'C': [1, 10, 100, 1000]}]
clf = GridSearchCV(SVC(), tuned_parameters, cv=5)
clf.fit(standardized_X,y_train)

我该如何标准化数据,以便对其进行训练并测试其准确性

我也不希望使用管道libaray。

0 个答案:

没有答案