我按照这里给出的所有步骤安装了tpot机器学习库: http://epistasislab.github.io/tpot/installing/
以下是我简单的源代码 [https://github.com/EpistasisLab/tpot]:
from tpot import TPOTClassifierfrom sklearn.datasets import load_digitsfrom sklearn.model_selection import train_test_splitdigits = load_digits()X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, train_size=0.75, test_size=0.25)tpot = TPOTClassifier(generations=5, population_size=20, verbosity=2)tpot.fit(X_train, y_train)print(tpot.score(X_test, y_test))tpot.export('tpot_mnist_pipeline.py')
我得到了以下错误:
Traceback (most recent call last): File "test.py", line 1, in <module> from tpot import TPOTClassifierModuleNotFoundError: No module named 'tpot'
我现在不确定是什么原因导致的。我查看了该模块的GitHub问题,并按照那里给出的所有解决方案进行了操作。我使用的是Max OS High Sierra操作系统,并通过Homebrew安装了Python
回答:
我遇到了同样的问题,看起来是因为脚本被命名为tpot.py
。将其改为其他名称应该可以解决问题 🙂