Last active
July 19, 2022 19:51
-
-
Save lujiaying/8a4ebe772fef7a90f3295ead84b93288 to your computer and use it in GitHub Desktop.
AutoGluon BugReport for PR #1956
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from autogluon.tabular import TabularPredictor, TabularDataset | |
if __name__ == '__main__': | |
path_prefix = 'https://autogluon.s3.amazonaws.com/datasets/CoverTypeMulticlassClassification/' | |
path_train = path_prefix + 'train_data.csv' | |
path_test = path_prefix + 'test_data.csv' | |
label = 'Cover_Type' | |
sample = 20000 # Number of rows to use to train | |
train_data = TabularDataset(path_train) | |
if sample is not None and (sample < len(train_data)): | |
train_data = train_data.sample(n=sample, random_state=0).reset_index(drop=True) | |
test_data = TabularDataset(path_test) | |
fit_kwargs = dict( | |
train_data=train_data, | |
hyperparameters={ | |
'NN_TORCH': {}, | |
'GBM': {}, | |
'KNN': {}, | |
}, | |
presets='high_quality', | |
time_limit=120, | |
num_bag_folds=3, | |
num_bag_sets=2, | |
) | |
predictor = TabularPredictor( | |
label=label, | |
eval_metric='log_loss', | |
) | |
predictor.fit(**fit_kwargs) | |
predictor.leaderboard() | |
predictor.persist_models('all') | |
# works well | |
we_model = predictor.fit_weighted_ensemble(base_models=['KNeighbors_BAG_L1', 'LightGBM_BAG_L1'], name_suffix='trial1') | |
print(f'we_model={we_model}, expect ["WeightedEnsemble_L2_trial1"]') | |
# not as expect | |
we_model_refit = predictor.fit_weighted_ensemble(base_models=['KNeighbors_BAG_L1', 'LightGBM_BAG_L1'], name_suffix='trial2', refit_full=True) | |
print(f'we_model_refit={we_model_refit}, expect ["WeightedEnsemble_L2_trial2_FULL"]') | |
predictor.leaderboard() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment