Skip to content

Commit

Permalink
fix bugs and add scoring type
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenWuyifan committed May 2, 2024
1 parent 692ae55 commit f0dbb87
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
13 changes: 9 additions & 4 deletions alpha_automl/pipeline_search/agent_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def __init__(self, config: EnvContext):
self.board = self.game.getInitBoard() # initial board
self.step_stack = ["S"] # stack for steps
self.metadata = self.board[: self.game.m]

if self.metadata[0] == 2: # regression.error
self.scoring_type = "error"
else: # classification.precision | clustering | regression.r2
self.scoring_type = "precision"

self.observation_space = Dict(
{
"board": Box(
Expand Down Expand Up @@ -93,11 +99,10 @@ def step(self, action):
game_end = self.game.getGameEnded(self.board)
if game_end == 1: # pipeline score over threshold
try:
if self.game.problem == "REGRESSION":
# reward = 10 + (100 / self.game.getEvaluation(self.board))
reward = 10 + (self.game.getEvaluation(self.board)) ** 3 * 100
if self.scoring_type == "error":
reward = 10 + (100 / self.game.getEvaluation(self.board))
else:
reward = 10 + (self.game.getEvaluation(self.board)) ** 2 * 100
reward = 10 + (self.game.getEvaluation(self.board)) ** 3 * 100
except Exception as e:
logger.critical(f"[PIPELINE FOUND] Error happened: {str(e)}")
elif game_end == 2: # finished but invalid
Expand Down
2 changes: 1 addition & 1 deletion alpha_automl/pipeline_search/agent_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def train_rllib_model(algo, time_bound, checkpoint_load_folder, checkpoint_save_
while True:
if (
time.time() > timeout
or (best_unchanged_iter >= 600 and result["episode_reward_mean"] >= 0)
or (best_unchanged_iter >= 10 and result["episode_reward_mean"] >= 0)
# or result["episode_reward_mean"] >= 70
):
logger.debug(f"Training timeout reached")
Expand Down
9 changes: 4 additions & 5 deletions alpha_automl/pipeline_synthesis/pipeline_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
"lightgbm.LGBMClassifier": {'verbose': -1},
"lightgbm.LGBMRegressor": {'verbose': -1},
"catboost.CatBoostRegressor": {
'depth': 8,
'grow_policy': 'Depthwise',
'l2_leaf_reg': 2.7997999596449104,
'learning_rate': 0.031375015734637225,
'max_ctr_complexity': 2,
'one_hot_max_size': 3,
'logging_level': 'Silent'
},
"catboost.CatBoostClassifier": {
'grow_policy': 'Depthwise',
'logging_level': 'Silent'
}
}


Expand Down
7 changes: 5 additions & 2 deletions alpha_automl/pipeline_synthesis/setup_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,19 @@ def compute_metafeatures(metric, metadata):
"mean_squared_error",
"mean_squared_log_error",
"median_absolute_error",
"r2_score",
]:
scoring_type = 2
elif metric in [
"r2_score",
]:
scoring_type = 3
elif metric in [
"adjusted_mutual_info_score",
"rand_score",
"mutual_info_score",
"normalized_mutual_info_score",
]:
scoring_type = 3
scoring_type = 4
metafeatures.append(scoring_type)

# IMPUTE
Expand Down
11 changes: 8 additions & 3 deletions alpha_automl/resource/primitives_hierarchy.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"sklearn.svm.SVC",
"sklearn.tree.DecisionTreeClassifier",
"xgboost.XGBClassifier",
"lightgbm.LGBMClassifier"
"lightgbm.LGBMClassifier",
"catboost.CatBoostClassifier"
],
"CLUSTERER": [
"sklearn.cluster.KMeans",
Expand All @@ -32,10 +33,14 @@
"alpha_automl.builtin_primitives.datetime_encoder.DummyEncoder"
],
"FEATURE_SCALER": [
"sklearn.preprocessing.RobustScaler"
"sklearn.preprocessing.MaxAbsScaler",
"sklearn.preprocessing.RobustScaler",
"sklearn.preprocessing.StandardScaler"
],
"FEATURE_SELECTOR": [
"sklearn.feature_selection.SelectPercentile"
"sklearn.feature_selection.GenericUnivariateSelect",
"sklearn.feature_selection.SelectPercentile",
"sklearn.feature_selection.SelectKBest"
],
"IMPUTER": [
"sklearn.impute.SimpleImputer"
Expand Down

0 comments on commit f0dbb87

Please sign in to comment.