Shi-Lixin / Machine-Learning-Algorithms

Python实现经典分类回归、关联分析、聚类以及推荐算法等
202 stars 77 forks source link

About "from machine_learning_algorithm.cross_validation import validate" #2

Open YYYYWD opened 5 years ago

YYYYWD commented 5 years ago
from machine_learning_algorithm.cross_validation import validate

ModuleNotFoundError: No module named 'machine_learning_algorithm'

请问一下,您这个模块是没有上传到github上吗

w179962443 commented 5 years ago
from machine_learning_algorithm.cross_validation import validate

ModuleNotFoundError: No module named 'machine_learning_algorithm'

请问一下,您这个模块是没有上传到github上吗

hey brother 用下面这几句替代作者那几句 if name == 'main': import pandas as pd dataset=pd.read_csv('iris.csv',names=['sepal length','sepal width','petal length','petal width','class']) dataset['class']=np.where(dataset['class'].str.contains('Iris-setosa'), 1,np.where(dataset['class'].str.contains('Iris-versicolor'),2,3)) X=dataset.values x=X[:,:4] y=X[:,4] from sklearn.model_selection import KFold kf = KFold(n_splits=10) for xun, ce in kf.split(X): X_data_train,X_data_test,y_data_train,y_data_test = x[xun], x[ce], y[xun], y[ce] clf = CART_CLF() clf.fit(X_data_train, y_data_train) score = 0 for a, b in zip(X_data_test,y_data_test): if clf.predict(a) == b: score += 1 print(score / len(y_data_test))

其中iris数据集自己去下载。

future-zy commented 3 years ago

改成 from cross_validation import validate 就行了,那个是博主自己写的代码