Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
18,
'uniform',
2
]
expected_code = """make_pipeline(
make_union(
StackingEstimator(estimator=GradientBoostingClassifier(learning_rate=38.0, max_depth=5, max_features=5, min_samples_leaf=5, min_samples_split=0.05, n_estimators=0.5)),
StackingEstimator(estimator=make_pipeline(
ZeroCount(),
GaussianNB()
))
),
KNeighborsClassifier(n_neighbors=18, p="uniform", weights=2)
)"""
assert expected_code == generate_pipeline_code(pipeline, tpot_obj.operators)
expected_code = """make_pipeline(
make_union(
StackingEstimator(estimator=GradientBoostingClassifier(learning_rate=38.0, max_depth=5, max_features=5, min_samples_leaf=5, min_samples_split=0.05, n_estimators=0.5)),
make_union(
MinMaxScaler(),
make_pipeline(
MaxAbsScaler(),
ZeroCount()
)
)
),
KNeighborsClassifier(n_neighbors=18, p="uniform", weights=2)
)"""
assert expected_code == generate_pipeline_code(pipeline, tpot_obj.operators)
while bad_pipeline and num_test < NUM_TESTS:
# clone individual before each func call so it is not altered for
# the possible next cycle loop
args = [self._toolbox.clone(arg) if isinstance(arg, creator.Individual) else arg for arg in args]
try:
with warnings.catch_warnings():
warnings.simplefilter('ignore')
expr = func(self, *args, **kwargs)
# mutation operator returns tuple (ind,); crossover operator
# returns tuple of (ind1, ind2)
expr_tuple = expr if isinstance(expr, tuple) else (expr,)
for expr_test in expr_tuple:
pipeline_code = generate_pipeline_code(
expr_to_tree(expr_test, self._pset),
self.operators
)
sklearn_pipeline = eval(pipeline_code, self.operators_context)
if self.classification:
sklearn_pipeline.fit(pretest_X, pretest_y)
else:
sklearn_pipeline.fit(pretest_X_reg, pretest_y_reg)
bad_pipeline = False
except BaseException as e:
message = '_pre_test decorator: {fname}: num_test={n} {e}'.format(
n=num_test,
fname=func.__name__,
e=e
)