我试图在Forest Cover Type Prediction上使用TPOTClassifier。 但是在初始运行后,它产生的错误作为输出。如果你建议如何解决这个错误,这将是有帮助的。谢谢。TPOTClassifier产生错误
from tpot import TPOTClassifier
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# loading the data
data = pd.read_csv("train.csv")
data_test = pd.read_csv("test.csv")
data.head()
data_test.head()
print data['Cover_Type'].values
data1 = data
data1= data1.rename(columns={'Cover_Type':'class'})
data1.dtypes
features =list(data1.dtypes[1:55].index)
target =list(data1.dtypes[55:56].index)
print data1.dtypes.tail()
## train test split
X_train , X_test, y_train, y_test = train_test_split(data1[features],data1[target],train_size=0.75, test_size=0.25)
X_train.head()
tpot =TPOTClassifier(generations=5, population_size=500, verbosity=2)
tpot.fit(X_train, y_train)
print (tpot.score(X_test, y_test))
tpot.export('tpot_forest_pipeline.py')
但其产生错误:
代1 - 当前最好的内部CV得分:INF
第2代 - 当前最好的内部CV得分:INF
代3 - 当前最好的内部CV分数:inf
第4代 - 当前最佳内部简历分数:inf
第5代 - 当前最好的内部CV得分:INF
ValueError异常回溯(最近最后调用) 在()
1 TPOT = TPOTClassifier(代= 5,population_size = 500,冗长度= 2)
2 tpot.fit(X_train,y_train)
3打印(tpot.score(X_test,y_test))
4 tpot.export( 'tpot_forest_pipeline.py'
355如果不是self._optimized_pipeline:
356升ValueError异常(有没有在TPOT优化
357过程中的错误。这可能是因为数据为 358未正确格式化,或者因为数据的原因)ValueError:TPOT优化过程中出现错误。这可能是因为数据格式不正确或者因为提供了回归问题的数据到TPOTClassifier对象。请确保您正确地将数据传递给TPOT。
感谢您的回复。我已按照您的建议进行了更改。它显示了几代人。然后它显示最佳管道:ExtraTreesClassifier(SelectFromModel(input_matrix,1.0000000000000001e-05,60.0,0.080000000000000002),6,0.63)之后,导出到tpot.export时发生错误('tpot_forest_pipeline.py') – Harry
我怎样才能从最佳管道显示中解读参数?如何解决在通过tpot.export('tpot_forest_pipeline.py')导出时最后出现的错误 – Harry