Skip to content

Commit

Permalink
Update example to use predefined_split properly (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman authored Dec 12, 2021
1 parent c03438b commit 772f268
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/40_advanced/example_resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@
# data by the first feature. In practice, one would use a splitting according
# to the use case at hand.

selected_indices = (X_train[:, 0] < np.mean(X_train[:, 0])).astype(int)
resampling_strategy = sklearn.model_selection.PredefinedSplit(
test_fold=np.where(X_train[:, 0] < np.mean(X_train[:, 0]))[0]
test_fold=selected_indices
)

automl = autosklearn.classification.AutoSklearnClassifier(
Expand All @@ -111,6 +112,8 @@
)
automl.fit(X_train, y_train, dataset_name='breast_cancer')

print(automl.sprint_statistics())

############################################################################
# For custom resampling strategies (i.e. resampling strategies that are not
# defined as strings by Auto-sklearn) it is necessary to perform a refit:
Expand Down

0 comments on commit 772f268

Please sign in to comment.