本文整理汇总了Python中tpot.TPOT类的典型用法代码示例。如果您正苦于以下问题:Python TPOT类的具体用法?Python TPOT怎么用?Python TPOT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TPOT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_feat_agg
def test_feat_agg():
"""Assert that the TPOT FeatureAgglomeration preprocessor outputs the input dataframe
when the number of training features is 0"""
tpot_obj = TPOT()
assert np.array_equal(tpot_obj._feat_agg(training_testing_data.ix[:, -3:], 5, 1, 1),
training_testing_data.ix[:, -3:])
示例2: test_nystroem
def test_nystroem():
"""Assert that the TPOT Nystroem preprocessor outputs the input dataframe
when the number of training features is 0"""
tpot_obj = TPOT()
assert np.array_equal(tpot_obj._nystroem(training_testing_data.ix[:, -3:], 1, 0.1, 1),
training_testing_data.ix[:, -3:])
示例3: test_fit
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
示例4: test_rbf
def test_rbf():
"""Assert that the TPOT RBFSampler outputs the input dataframe when # of
training features is 0"""
tpot_obj = TPOT()
assert np.array_equal(tpot_obj._rbf(training_testing_data.ix[:, -3:], 0.1),
training_testing_data.ix[:, -3:])
示例5: test_fast_ica
def test_fast_ica():
"""Assert that the TPOT FastICA preprocessor outputs the input dataframe
when the number of training features is 0"""
tpot_obj = TPOT()
assert np.array_equal(tpot_obj._fast_ica(training_testing_data.ix[:, -3:], 1.0),
training_testing_data.ix[:, -3:])
示例6: test_gen
def test_gen():
"""Assert that TPOT's gen_grow_safe function returns a pipeline of expected structure"""
tpot_obj = TPOT()
pipeline = tpot_obj._gen_grow_safe(tpot_obj._pset, 1, 3)
assert len(pipeline) > 1
assert pipeline[0].ret == Output_DF
示例7: test_df_feature_selection
def test_df_feature_selection():
tpot_obj = TPOT()
top_10_feature_pairs = ['00002', '00013', '00020', '00021', '00026', '00042',
'00043', '00058', '00061', 'class', 'group', 'guess']
assert np.array_equal(tpot_obj._dt_feature_selection(training_testing_data, 10).columns.values,
top_10_feature_pairs)
示例8: test_export
def test_export():
"""Assert that TPOT's export function throws a ValueError when no optimized pipeline exists"""
tpot_obj = TPOT()
try:
tpot_obj.export("test_export.py")
assert False # Should be unreachable
except ValueError:
pass
示例9: test_export
def test_export():
"""Ensure that the TPOT export function raises a ValueError when no optimized pipeline exists"""
tpot_obj = TPOT()
try:
tpot_obj.export('will_not_output')
assert False # Should be unreachable
except ValueError:
pass
示例10: test_predict
def test_predict():
"""Ensure that the TPOT predict function raises a ValueError when no optimized pipeline exists"""
tpot_obj = TPOT()
try:
tpot_obj.predict(testing_features)
assert False # Should be unreachable
except ValueError:
pass
示例11: test_score
def test_score():
"""Assert that the TPOT score function raises a ValueError when no optimized pipeline exists"""
tpot_obj = TPOT()
try:
tpot_obj.score(testing_features, testing_classes)
assert False # Should be unreachable
except ValueError:
pass
示例12: test_variance_threshold
def test_variance_threshold():
tpot_obj = TPOT()
non_feature_columns = ['class', 'group', 'guess']
training_features = training_testing_data.loc[training_testing_data['group'] == 'training'].drop(non_feature_columns, axis=1)
selector = VarianceThreshold(threshold=0)
selector.fit(training_features)
mask = selector.get_support(True)
mask_cols = list(training_features.iloc[:, mask].columns) + non_feature_columns
assert np.array_equal(tpot_obj._variance_threshold(training_testing_data, 0), training_testing_data[mask_cols])
示例13: test_gradient_boosting_2
def test_gradient_boosting_2():
"""Ensure that the TPOT GradientBoostingClassifier outputs the same as the sklearn classifier when max_depth < 1"""
tpot_obj = TPOT()
result = tpot_obj._gradient_boosting(training_testing_data, 1.0, 0)
result = result[result['group'] == 'testing']
gbc = GradientBoostingClassifier(learning_rate=1.0, max_depth=1, n_estimators=500, random_state=42)
gbc.fit(training_features, training_classes)
assert np.array_equal(result['guess'].values, gbc.predict(testing_features))
示例14: test_svc_2
def test_svc_2():
"""Ensure that the TPOT random forest method outputs the same as the sklearn svc when C<0.0001"""
tpot_obj = TPOT()
result = tpot_obj._svc(training_testing_data, 0.00001)
result = result[result['group'] == 'testing']
svc = SVC(C=0.0001, random_state=42)
svc.fit(training_features, training_classes)
assert np.array_equal(result['guess'].values, svc.predict(testing_features))
示例15: test_linear_svc
def test_linear_svc():
"""Ensure that the TPOT LinearSVC outputs the same as the sklearn LinearSVC"""
tpot_obj = TPOT()
result = tpot_obj._linear_svc(training_testing_data, 1.0, 0, 0)
result = result[result['group'] == 'testing']
lsvc = LinearSVC(C=1.0, loss='hinge', fit_intercept=True, random_state=42)
lsvc.fit(training_features, training_classes)
assert np.array_equal(result['guess'].values, lsvc.predict(testing_features))