本文整理汇总了Python中tpot.TPOT.fit方法的典型用法代码示例。如果您正苦于以下问题:Python TPOT.fit方法的具体用法?Python TPOT.fit怎么用?Python TPOT.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpot.TPOT
的用法示例。
在下文中一共展示了TPOT.fit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fit
# 需要导入模块: from tpot import TPOT [as 别名]
# 或者: from tpot.TPOT import fit [as 别名]
def test_fit():
"""Assert that the TPOT fit function provides an optimized pipeline"""
tpot_obj = TPOT(random_state=42, population_size=1, generations=1, verbosity=0)
tpot_obj.fit(training_features, training_classes)
assert isinstance(tpot_obj._optimized_pipeline, creator.Individual)
assert tpot_obj.gp_generation == 0
示例2: load_iris
# 需要导入模块: from tpot import TPOT [as 别名]
# 或者: from tpot.TPOT import fit [as 别名]
from tpot import TPOT
from sklearn.datasets import load_iris
from sklearn.cross_validation import train_test_split
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target,
train_size=0.75, test_size=0.25)
tpot = TPOT(generations=5,verbosity=2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('tpot_iris_pipeline.py')
示例3: train_test_split
# 需要导入模块: from tpot import TPOT [as 别名]
# 或者: from tpot.TPOT import fit [as 别名]
train = train.drop(drop_list,axis=1)
train = train[0:3000000:300]
train.info(memory_usage='deep')
X = train.drop("hotel_cluster",axis=1).values
y = train.loc[: , "hotel_cluster"].values
del train
import gc
gc.collect()
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.75,test_size=0.25)
print("got here!")
my_tpot = TPOT(generations=20,verbosity=2,population_size=5) # seems to have a problem with pop <5
# gen 1-> really means two generations!
start = time.clock()
print(start)
my_tpot.fit(X_train, y_train)
my_tpot.export('tpot_expedia_pipeline.py')
end = time.clock()
duration = end - start
score = my_tpot.score(X_test, y_test)
print(duration,score)