我正在尝试通过使用SVR预测波士顿的住房数据,并且正在使用以下代码,但出现一些错误。
# -*- coding: utf-8 -*-
import sys
import pandas as pd
columns=['ID','crim','zn','indus','chas','nox','rm','age','dis','rad','tax','ptratio','black','lstat','medv']
dataset_train=pd.read_csv('train.csv')#,names=columns)
train_y=pd.DataFrame(dataset_train.medv)
dataset_train=dataset_train.drop('medv',axis=1)
columns_test=['ID','crim','zn','indus','chas','nox','rm','age','dis','rad','tax','ptratio','black','lstat']
dataset_test=pd.read_csv('test.csv')#,names=columns_test)
y_sub=pd.read_csv('submission_example.csv')
y_sub1=y_sub.drop('ID',axis=1)
dataset_train.describe()
dataset_train.head(10)
dataset_train.tail(10)
dataset_train.isnull().sum()
from sklearn.preprocessing import StandardScaler
SC=StandardScaler()
SC_train=SC.fit_transform(dataset_train)
SC_test=SC.fit_transform(dataset_test)
from sklearn.svm import SVR
svr=SVR(kernel='rbf')
svr.fit(dataset_train,train_y)
y_pred=pd.DataFrame(svr.predict(dataset_test))
y_sub1.dtype
#print("SVM Score:{}".format(svr.score(y_pred,y_sub1)))
svr.score(y_sub1,y_pred)
from sklearn.metrics import accuracy_score
print(accuracy_score(y_pred,y_sub1))
我遇到以下错误
ValueError: X.shape[1] = 1 should be equal to 14, the number of features at training time