-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX formatting in docs #342
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
The following example shows how adjust the configuration space of | ||
the search. Currently, there are two changes that can be made to the space:- | ||
|
||
1. Adjust individual hyperparameters in the pipeline | ||
2. Include or exclude components: | ||
a) include: Dictionary containing components to include. Key is the node | ||
|
@@ -57,80 +58,78 @@ def get_search_space_updates(): | |
return updates | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
############################################################################ | ||
# Data Loading | ||
# ============ | ||
X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True) | ||
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( | ||
X, | ||
y, | ||
random_state=1, | ||
) | ||
|
||
############################################################################ | ||
# Build and fit a classifier with include components | ||
# ================================================== | ||
api = TabularClassificationTask( | ||
search_space_updates=get_search_space_updates(), | ||
include_components={'network_backbone': ['MLPBackbone', 'ResNetBackbone'], | ||
'encoder': ['OneHotEncoder']} | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train.copy(), | ||
y_train=y_train.copy(), | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
optimize_metric='accuracy', | ||
total_walltime_limit=150, | ||
func_eval_time_limit_secs=30 | ||
) | ||
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
print(api.show_models()) | ||
|
||
# Print statistics from search | ||
print(api.sprint_statistics()) | ||
|
||
############################################################################ | ||
# Build and fit a classifier with exclude components | ||
# ================================================== | ||
api = TabularClassificationTask( | ||
search_space_updates=get_search_space_updates(), | ||
exclude_components={'network_backbone': ['MLPBackbone'], | ||
'encoder': ['OneHotEncoder']} | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
optimize_metric='accuracy', | ||
total_walltime_limit=150, | ||
func_eval_time_limit_secs=30 | ||
) | ||
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
print(api.show_models()) | ||
|
||
# Print statistics from search | ||
print(api.sprint_statistics()) | ||
############################################################################ | ||
# Data Loading | ||
# ============ | ||
X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True) | ||
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( | ||
X, | ||
y, | ||
random_state=1, | ||
) | ||
|
||
############################################################################ | ||
# Build and fit a classifier with include components | ||
# ================================================== | ||
api = TabularClassificationTask( | ||
search_space_updates=get_search_space_updates(), | ||
include_components={'network_backbone': ['MLPBackbone', 'ResNetBackbone'], | ||
'encoder': ['OneHotEncoder']} | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train.copy(), | ||
y_train=y_train.copy(), | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
optimize_metric='accuracy', | ||
total_walltime_limit=150, | ||
func_eval_time_limit_secs=30 | ||
) | ||
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
print(api.show_models()) | ||
|
||
# Print statistics from search | ||
print(api.sprint_statistics()) | ||
|
||
############################################################################ | ||
# Build and fit a classifier with exclude components | ||
# ================================================== | ||
api = TabularClassificationTask( | ||
search_space_updates=get_search_space_updates(), | ||
exclude_components={'network_backbone': ['MLPBackbone'], | ||
'encoder': ['OneHotEncoder']} | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
Comment on lines
+119
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
optimize_metric='accuracy', | ||
total_walltime_limit=150, | ||
func_eval_time_limit_secs=30 | ||
) | ||
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
print(api.show_models()) | ||
|
||
# Print statistics from search | ||
print(api.sprint_statistics()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,13 @@ | |
from autoPyTorch.api.tabular_classification import TabularClassificationTask | ||
from autoPyTorch.datasets.resampling_strategy import CrossValTypes, HoldoutValTypes | ||
|
||
############################################################################ | ||
# Default Resampling Strategy | ||
# ============================ | ||
|
||
############################################################################ | ||
# Data Loading | ||
# ============ | ||
# ------------ | ||
X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True) | ||
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( | ||
X, | ||
|
@@ -39,7 +42,7 @@ | |
|
||
############################################################################ | ||
# Build and fit a classifier with default resampling strategy | ||
# =========================================================== | ||
# ----------------------------------------------------------- | ||
api = TabularClassificationTask( | ||
# 'HoldoutValTypes.holdout_validation' with 'val_share': 0.33 | ||
# is the default argument setting for TabularClassificationTask. | ||
|
@@ -51,7 +54,7 @@ | |
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
# ----------------------------------------------------- | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
@@ -64,7 +67,7 @@ | |
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
# ------------------------------------ | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
|
@@ -76,17 +79,21 @@ | |
|
||
############################################################################ | ||
|
||
############################################################################ | ||
# Cross validation Resampling Strategy | ||
# ===================================== | ||
|
||
############################################################################ | ||
# Build and fit a classifier with Cross validation resampling strategy | ||
# ==================================================================== | ||
# -------------------------------------------------------------------- | ||
api = TabularClassificationTask( | ||
resampling_strategy=CrossValTypes.k_fold_cross_validation, | ||
resampling_strategy_args={'num_splits': 3} | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
# ------------ | ||
ravinkohli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
@@ -99,7 +106,7 @@ | |
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
# ------------ | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
|
@@ -111,9 +118,13 @@ | |
|
||
############################################################################ | ||
|
||
############################################################################ | ||
# Stratified Resampling Strategy | ||
# =============================== | ||
|
||
############################################################################ | ||
# Build and fit a classifier with Stratified resampling strategy | ||
# ============================================================== | ||
# -------------------------------------------------------------- | ||
api = TabularClassificationTask( | ||
# For demonstration purposes, we use | ||
# Stratified hold out validation. However, | ||
|
@@ -124,7 +135,7 @@ | |
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
# ----------------------------------------------------- | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,50 +24,48 @@ | |
from autoPyTorch.api.tabular_classification import TabularClassificationTask | ||
|
||
|
||
if __name__ == '__main__': | ||
############################################################################ | ||
# Data Loading | ||
# ============ | ||
X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True) | ||
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( | ||
X, | ||
y, | ||
random_state=42, | ||
) | ||
|
||
############################################################################ | ||
# Data Loading | ||
# ============ | ||
X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True) | ||
X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split( | ||
X, | ||
y, | ||
random_state=42, | ||
) | ||
############################################################################ | ||
# Build and fit a classifier | ||
# ========================== | ||
api = TabularClassificationTask( | ||
seed=42, | ||
) | ||
|
||
############################################################################ | ||
# Build and fit a classifier | ||
# ========================== | ||
api = TabularClassificationTask( | ||
seed=42, | ||
) | ||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
optimize_metric='accuracy', | ||
total_walltime_limit=300, | ||
func_eval_time_limit_secs=50, | ||
# Setting this option to "greedy" | ||
# will make smac run the configurations | ||
# present in 'autoPyTorch/configs/greedy_portfolio.json' | ||
portfolio_selection="greedy" | ||
) | ||
|
||
############################################################################ | ||
# Search for an ensemble of machine learning algorithms | ||
# ===================================================== | ||
api.search( | ||
X_train=X_train, | ||
y_train=y_train, | ||
X_test=X_test.copy(), | ||
y_test=y_test.copy(), | ||
optimize_metric='accuracy', | ||
total_walltime_limit=300, | ||
func_eval_time_limit_secs=50, | ||
# Setting this option to "greedy" | ||
# will make smac run the configurations | ||
# present in 'autoPyTorch/configs/greedy_portfolio.json' | ||
portfolio_selection="greedy" | ||
) | ||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
# Print the final ensemble built by AutoPyTorch | ||
print(api.show_models()) | ||
|
||
############################################################################ | ||
# Print the final ensemble performance | ||
# ==================================== | ||
y_pred = api.predict(X_test) | ||
score = api.score(y_pred, y_test) | ||
print(score) | ||
# Print the final ensemble built by AutoPyTorch | ||
print(api.show_models()) | ||
|
||
# Print statistics from search | ||
print(api.sprint_statistics()) | ||
# Print statistics from search | ||
print(api.sprint_statistics()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.copy()