Python大战机器学习中支持向量回归SVC程序报错ImportError: cannot import name 'cross_validation' from 'sklearn'

版本问题出现的错误:
Python2.7中:

import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model,cross_validation,svm
def load_data_classfication():
iris=datasets.load_iris()
X_train=iris.data
y_train=iris.target
return model_selection.train_test_split(X_train, y_train,test_size=0.25,random_state=0,stratify=y_train)

line 13, in
from sklearn import datasets, linear_model,cross_validation,svm
ImportError: cannot import name ‘cross_validation’ from ‘sklearn’

canda的Jupyter Notebook代码
在Python3中应修改为:

import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model,model_selection,svm

你可能感兴趣的:(Python大战机器学习中支持向量回归SVC程序报错ImportError: cannot import name 'cross_validation' from 'sklearn')