PyIAML 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iaml/__init__.py +56 -0
- iaml/actionable.py +11 -0
- iaml/actionables/__init__.py +21 -0
- iaml/actionables/boosting/__init__.py +4 -0
- iaml/actionables/boosting/act_adaboost.py +59 -0
- iaml/actionables/cleaning/__init__.py +26 -0
- iaml/actionables/cleaning/act_categorical_imputer.py +124 -0
- iaml/actionables/cleaning/act_count_vectorizer.py +204 -0
- iaml/actionables/cleaning/act_drop_categorical_column.py +51 -0
- iaml/actionables/cleaning/act_drop_date_column.py +48 -0
- iaml/actionables/cleaning/act_drop_high_cardinality_categorical.py +337 -0
- iaml/actionables/cleaning/act_drop_numerical_column.py +75 -0
- iaml/actionables/cleaning/act_drop_textual_column.py +51 -0
- iaml/actionables/cleaning/act_encode_target_column.py +56 -0
- iaml/actionables/cleaning/act_frequency_encoder.py +127 -0
- iaml/actionables/cleaning/act_hashing_vectorizer.py +186 -0
- iaml/actionables/cleaning/act_knn_imputer.py +152 -0
- iaml/actionables/cleaning/act_mean_column.py +79 -0
- iaml/actionables/cleaning/act_mice.py +464 -0
- iaml/actionables/cleaning/act_missing_count_feature.py +109 -0
- iaml/actionables/cleaning/act_missing_indicator.py +124 -0
- iaml/actionables/cleaning/act_onehot.py +65 -0
- iaml/actionables/cleaning/act_ordinal_encoder.py +177 -0
- iaml/actionables/cleaning/act_rare_category_grouper.py +173 -0
- iaml/actionables/cleaning/act_simple_imputer.py +109 -0
- iaml/actionables/cleaning/act_split_date.py +68 -0
- iaml/actionables/cleaning/act_target_encoder.py +274 -0
- iaml/actionables/cleaning/act_text_normalizer.py +241 -0
- iaml/actionables/cleaning/act_tf_idf.py +80 -0
- iaml/actionables/cleaning/act_word2vec.py +150 -0
- iaml/actionables/features_precleaning/__init__.py +12 -0
- iaml/actionables/features_precleaning/act_coerce_numeric_strings.py +194 -0
- iaml/actionables/features_precleaning/act_date_converter.py +99 -0
- iaml/actionables/features_precleaning/act_drop_bad_quality_rows.py +77 -0
- iaml/actionables/features_precleaning/act_drop_duplicate_rows.py +131 -0
- iaml/actionables/features_precleaning/act_drop_high_missing_columns.py +94 -0
- iaml/actionables/features_precleaning/act_drop_id_like_columns.py +294 -0
- iaml/actionables/features_precleaning/act_normalize_column_names.py +157 -0
- iaml/actionables/features_precleaning/act_sentinel_to_na_n.py +270 -0
- iaml/actionables/features_precleaning/act_trim_space.py +79 -0
- iaml/actionables/features_preprocessing/__init__.py +18 -0
- iaml/actionables/features_preprocessing/act_cyclical_date_encoding.py +212 -0
- iaml/actionables/features_preprocessing/act_fast_ica.py +161 -0
- iaml/actionables/features_preprocessing/act_feature_agglomeration.py +90 -0
- iaml/actionables/features_preprocessing/act_k_bins_discretizer.py +207 -0
- iaml/actionables/features_preprocessing/act_k_means_features.py +296 -0
- iaml/actionables/features_preprocessing/act_kernel_pca.py +143 -0
- iaml/actionables/features_preprocessing/act_log_transformer.py +122 -0
- iaml/actionables/features_preprocessing/act_nystroem.py +100 -0
- iaml/actionables/features_preprocessing/act_pca.py +77 -0
- iaml/actionables/features_preprocessing/act_polynomial_features.py +86 -0
- iaml/actionables/features_preprocessing/act_power_transformer.py +106 -0
- iaml/actionables/features_preprocessing/act_quantile_transformer.py +114 -0
- iaml/actionables/features_preprocessing/act_rbf_sampler.py +88 -0
- iaml/actionables/features_preprocessing/act_select_percentile.py +112 -0
- iaml/actionables/features_preprocessing/act_sparse_random_projection.py +157 -0
- iaml/actionables/features_preprocessing/act_truncated_svd.py +137 -0
- iaml/actionables/features_selection/__init__.py +8 -0
- iaml/actionables/features_selection/act_permutation_importance_selector.py +421 -0
- iaml/actionables/features_selection/act_remove_high_correlated_column.py +70 -0
- iaml/actionables/features_selection/act_remove_low_variance_column.py +74 -0
- iaml/actionables/features_selection/act_rfe.py +214 -0
- iaml/actionables/features_selection/act_select_from_model.py +325 -0
- iaml/actionables/features_selection/act_select_k_best.py +181 -0
- iaml/actionables/features_selection/act_vif_selector.py +130 -0
- iaml/actionables/imbalance/__init__.py +10 -0
- iaml/actionables/imbalance/act_adasyn.py +150 -0
- iaml/actionables/imbalance/act_borderline_smote.py +171 -0
- iaml/actionables/imbalance/act_near_miss.py +158 -0
- iaml/actionables/imbalance/act_random_over_sampling.py +60 -0
- iaml/actionables/imbalance/act_random_under_sampler.py +135 -0
- iaml/actionables/imbalance/act_smote.py +162 -0
- iaml/actionables/imbalance/act_smote_tomek.py +182 -0
- iaml/actionables/imbalance/act_smoteenn.py +193 -0
- iaml/actionables/imbalance/act_tomek_links.py +138 -0
- iaml/actionables/normalize/__init__.py +6 -0
- iaml/actionables/normalize/act_max_abs_scaler.py +78 -0
- iaml/actionables/normalize/act_minmax_scaler.py +56 -0
- iaml/actionables/normalize/act_normalizer.py +95 -0
- iaml/actionables/normalize/act_robust_scaler.py +111 -0
- iaml/actionables/normalize/act_standard_scaler.py +55 -0
- iaml/actionables/predictors/__init__.py +6 -0
- iaml/actionables/predictors/_xgboost.py +16 -0
- iaml/actionables/predictors/classifier/__init__.py +26 -0
- iaml/actionables/predictors/classifier/act_bagging_classifier.py +113 -0
- iaml/actionables/predictors/classifier/act_bernoulli_nb.py +89 -0
- iaml/actionables/predictors/classifier/act_catboost_classifier.py +135 -0
- iaml/actionables/predictors/classifier/act_complement_nb.py +106 -0
- iaml/actionables/predictors/classifier/act_decision_tree_classifier.py +117 -0
- iaml/actionables/predictors/classifier/act_extra_trees_classifier.py +115 -0
- iaml/actionables/predictors/classifier/act_gaussian_nb.py +53 -0
- iaml/actionables/predictors/classifier/act_hist_gradient_boosting_classifier.py +144 -0
- iaml/actionables/predictors/classifier/act_knn.py +86 -0
- iaml/actionables/predictors/classifier/act_light_gbm_classifier.py +211 -0
- iaml/actionables/predictors/classifier/act_linear_discriminant_analysis.py +63 -0
- iaml/actionables/predictors/classifier/act_linear_svc.py +134 -0
- iaml/actionables/predictors/classifier/act_logistic_regression.py +92 -0
- iaml/actionables/predictors/classifier/act_mlp_classifier.py +107 -0
- iaml/actionables/predictors/classifier/act_multinomial_nb.py +76 -0
- iaml/actionables/predictors/classifier/act_passive_aggressive_classifier.py +141 -0
- iaml/actionables/predictors/classifier/act_quadratic_discriminant_analysis.py +72 -0
- iaml/actionables/predictors/classifier/act_randomforest.py +113 -0
- iaml/actionables/predictors/classifier/act_ridge_classifier.py +116 -0
- iaml/actionables/predictors/classifier/act_sgd_classifier.py +149 -0
- iaml/actionables/predictors/classifier/act_svm_svc.py +88 -0
- iaml/actionables/predictors/classifier/act_xgboost.py +111 -0
- iaml/actionables/predictors/regressor/__init__.py +27 -0
- iaml/actionables/predictors/regressor/act_ada_boost_regressor.py +75 -0
- iaml/actionables/predictors/regressor/act_ard_regression.py +95 -0
- iaml/actionables/predictors/regressor/act_catboost_regressor.py +134 -0
- iaml/actionables/predictors/regressor/act_decision_tree_regressor.py +111 -0
- iaml/actionables/predictors/regressor/act_elastic_net_regressor.py +109 -0
- iaml/actionables/predictors/regressor/act_extra_trees_regressor.py +113 -0
- iaml/actionables/predictors/regressor/act_gaussian_process_regressor.py +55 -0
- iaml/actionables/predictors/regressor/act_gboost_regressor.py +95 -0
- iaml/actionables/predictors/regressor/act_hist_gradient_boosting_regressor.py +105 -0
- iaml/actionables/predictors/regressor/act_huber_regressor.py +101 -0
- iaml/actionables/predictors/regressor/act_knn_regressor.py +86 -0
- iaml/actionables/predictors/regressor/act_lasso_regressor.py +103 -0
- iaml/actionables/predictors/regressor/act_light_gbm_regressor.py +201 -0
- iaml/actionables/predictors/regressor/act_linear_regression.py +43 -0
- iaml/actionables/predictors/regressor/act_mlp_regressor.py +104 -0
- iaml/actionables/predictors/regressor/act_poisson_regressor.py +111 -0
- iaml/actionables/predictors/regressor/act_quantile_regressor.py +87 -0
- iaml/actionables/predictors/regressor/act_randomforest_regressor.py +116 -0
- iaml/actionables/predictors/regressor/act_ransac_regressor.py +106 -0
- iaml/actionables/predictors/regressor/act_ridge_regressor.py +107 -0
- iaml/actionables/predictors/regressor/act_sgd_regressor.py +106 -0
- iaml/actionables/predictors/regressor/act_svm_svr.py +81 -0
- iaml/actionables/predictors/regressor/act_xgboost_regressor.py +97 -0
- iaml/actionables/predictors/survival/__init__.py +12 -0
- iaml/actionables/predictors/survival/act_aalen_additive_model.py +83 -0
- iaml/actionables/predictors/survival/act_cox.py +110 -0
- iaml/actionables/predictors/survival/act_coxnet_survival_analysis.py +134 -0
- iaml/actionables/predictors/survival/act_extra_survival_trees.py +101 -0
- iaml/actionables/predictors/survival/act_fast_survival_svm.py +102 -0
- iaml/actionables/predictors/survival/act_gradient_boosting_survival_analysis.py +93 -0
- iaml/actionables/predictors/survival/act_random_survival_forest.py +91 -0
- iaml/actionables/predictors/survival/act_survival_component_wise_gboost.py +80 -0
- iaml/actionables/predictors/survival/act_survival_tree.py +120 -0
- iaml/actionables/predictors/survival/act_survival_xgboost.py +9 -0
- iaml/actionables/predictors/survival/act_weibull_aft.py +230 -0
- iaml/cache.py +61 -0
- iaml/cache_keys.py +57 -0
- iaml/candidate.py +736 -0
- iaml/core_dispatcher.py +125 -0
- iaml/data_type.py +11 -0
- iaml/dataset.py +506 -0
- iaml/decorators/__init__.py +3 -0
- iaml/decorators/all.py +4 -0
- iaml/decorators/is_step.py +45 -0
- iaml/decorators/runner.py +100 -0
- iaml/explanation.py +112 -0
- iaml/iaml.py +1072 -0
- iaml/iaml_pipeline.py +600 -0
- iaml/logger.py +138 -0
- iaml/meta_explorer_step.py +62 -0
- iaml/meta_ordered_step.py +28 -0
- iaml/meta_partial_explorer_step.py +34 -0
- iaml/meta_singleton.py +24 -0
- iaml/metastep.py +211 -0
- iaml/metric.py +111 -0
- iaml/metric_plot.py +82 -0
- iaml/metrics/__init__.py +21 -0
- iaml/metrics/_classification.py +28 -0
- iaml/metrics/_survival_times.py +22 -0
- iaml/metrics/accuracy_metric.py +59 -0
- iaml/metrics/balanced_accuracy_metric.py +67 -0
- iaml/metrics/brier_score.py +90 -0
- iaml/metrics/classification_error_metric.py +66 -0
- iaml/metrics/concordance_index_ipcw.py +84 -0
- iaml/metrics/concordance_index_metric.py +67 -0
- iaml/metrics/cumulative_dynamic_auc.py +119 -0
- iaml/metrics/f1_score_metric.py +71 -0
- iaml/metrics/integrated_brier_score.py +98 -0
- iaml/metrics/integrated_brier_score_loss.py +41 -0
- iaml/metrics/mean_absolute_error_metric.py +46 -0
- iaml/metrics/mean_squared_error_metric.py +46 -0
- iaml/metrics/mean_squared_log_error_metric.py +49 -0
- iaml/metrics/median_absolute_error_metric.py +48 -0
- iaml/metrics/precision_metric.py +63 -0
- iaml/metrics/r2_score_metric.py +45 -0
- iaml/metrics/recall_metric.py +65 -0
- iaml/metrics/roc_auc_metric.py +50 -0
- iaml/metrics/specificity_metric.py +44 -0
- iaml/metrics/specificity_multiclass_metric.py +55 -0
- iaml/metrics/specificity_multilabel_metric.py +60 -0
- iaml/optimizers/__init__.py +5 -0
- iaml/optimizers/bayesian_optimizer.py +193 -0
- iaml/optimizers/genetic_optimizer.py +284 -0
- iaml/optimizers/optimizer.py +31 -0
- iaml/optimizers/random_optimizer.py +101 -0
- iaml/plot.py +138 -0
- iaml/plots/__init__.py +32 -0
- iaml/plots/bar_plot.py +141 -0
- iaml/plots/box_plot.py +166 -0
- iaml/plots/class_prediction_error_plot.py +37 -0
- iaml/plots/classification_report_plot.py +35 -0
- iaml/plots/confusion_matrix_plot.py +34 -0
- iaml/plots/correlation_heatmap_plot.py +201 -0
- iaml/plots/cumulative_hazard_plot.py +72 -0
- iaml/plots/density_plot.py +210 -0
- iaml/plots/histogram_plot.py +179 -0
- iaml/plots/kaplan_meier_comparison_plot.py +89 -0
- iaml/plots/line_plot.py +70 -0
- iaml/plots/missingness_heatmap_plot.py +203 -0
- iaml/plots/outlier_plot.py +217 -0
- iaml/plots/pair_plot.py +228 -0
- iaml/plots/precision_recall_curve_plot.py +86 -0
- iaml/plots/prediction_error_plot.py +34 -0
- iaml/plots/qq_plot.py +220 -0
- iaml/plots/residual_plot.py +38 -0
- iaml/plots/roc_dynamique_curve_plot.py +79 -0
- iaml/plots/rocauc_plot.py +96 -0
- iaml/plots/shap_plot.py +187 -0
- iaml/plots/target_distribution_plot.py +241 -0
- iaml/plots/violin_plot.py +206 -0
- iaml/predictor.py +139 -0
- iaml/reference.py +65 -0
- iaml/shared_cache.py +90 -0
- iaml/sklearn_preprocessor.py +74 -0
- iaml/splitters/__init__.py +3 -0
- iaml/splitters/kfold_splitter.py +32 -0
- iaml/splitters/random_splitter.py +26 -0
- iaml/stack.py +39 -0
- iaml/statistic.py +66 -0
- iaml/statistics/__init__.py +77 -0
- iaml/statistics/anova_statistic.py +80 -0
- iaml/statistics/cardinality_ratio_statistic.py +63 -0
- iaml/statistics/category_cooccurrence_statistic.py +79 -0
- iaml/statistics/chi_square_statistic.py +81 -0
- iaml/statistics/coef_variation_statistic.py +72 -0
- iaml/statistics/correlation_with_target.py +105 -0
- iaml/statistics/count.py +72 -0
- iaml/statistics/data_type_summary_statistic.py +74 -0
- iaml/statistics/duplicate_row_statistic.py +56 -0
- iaml/statistics/effect_size_statistic.py +129 -0
- iaml/statistics/entropy_statistic.py +69 -0
- iaml/statistics/event_rate_statistic.py +52 -0
- iaml/statistics/grouped_mean_statistic.py +60 -0
- iaml/statistics/iqr_statistic.py +66 -0
- iaml/statistics/kurtosis.py +50 -0
- iaml/statistics/mad_statistic.py +66 -0
- iaml/statistics/mean.py +61 -0
- iaml/statistics/median_statistic.py +61 -0
- iaml/statistics/minmax.py +60 -0
- iaml/statistics/missing_rate_statistic.py +62 -0
- iaml/statistics/mode.py +47 -0
- iaml/statistics/most_frequent_ratio.py +81 -0
- iaml/statistics/outlier_count_iqr_statistic.py +76 -0
- iaml/statistics/quantile.py +59 -0
- iaml/statistics/range.py +53 -0
- iaml/statistics/rare_category_rate.py +92 -0
- iaml/statistics/skewness.py +53 -0
- iaml/statistics/stdev.py +50 -0
- iaml/statistics/summary_table_statistic.py +60 -0
- iaml/statistics/time_by_group_statistic.py +83 -0
- iaml/statistics/time_summary_statistic.py +56 -0
- iaml/statistics/top_k_value_counts.py +68 -0
- iaml/statistics/unique_count_statistic.py +57 -0
- iaml/statistics/value_counts.py +63 -0
- iaml/statistics/variance.py +51 -0
- iaml/statistics/violin.py +63 -0
- iaml/step.py +600 -0
- iaml/step_cache.py +87 -0
- iaml/step_wrapper.py +79 -0
- iaml/timed_pool_executor.py +492 -0
- iaml/type_of_target.py +68 -0
- iaml/void_step.py +101 -0
- iaml/worker_manager.py +169 -0
- iaml/wrapper/__init__.py +4 -0
- iaml/wrapper/wrap_basic_gridsearch.py +68 -0
- iaml/wrapper/wrap_genetic_gridsearch.py +293 -0
- iaml/wrapper/wrap_iterative_gridsearch.py +399 -0
- pyiaml-1.0.0.dist-info/METADATA +802 -0
- pyiaml-1.0.0.dist-info/RECORD +279 -0
- pyiaml-1.0.0.dist-info/WHEEL +5 -0
- pyiaml-1.0.0.dist-info/licenses/LICENSE +674 -0
- pyiaml-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"""[STEP] LightGBM Classifier"""
|
|
2
|
+
import textwrap
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from lightgbm import LGBMClassifier
|
|
7
|
+
from lightgbm.basic import LightGBMError
|
|
8
|
+
_LGBM_ERRORS: tuple[type[Exception], ...] = (LightGBMError,)
|
|
9
|
+
except ImportError: # pragma: no cover - optional dependency
|
|
10
|
+
LGBMClassifier = None # type: ignore
|
|
11
|
+
_LGBM_ERRORS = tuple()
|
|
12
|
+
|
|
13
|
+
from ....predictor import Predictor
|
|
14
|
+
from ....dataset import Dataset
|
|
15
|
+
from ....candidate import Candidate
|
|
16
|
+
from ....data_type import DataType
|
|
17
|
+
from ....decorators.all import is_step
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@is_step('predictor', 'tabular', 'classifier')
|
|
21
|
+
class ActLightGBMClassifier(Predictor):
|
|
22
|
+
"""[STEP] LightGBM Classifier"""
|
|
23
|
+
|
|
24
|
+
name: str = "LightGBM Classifier"
|
|
25
|
+
_description: str = textwrap.dedent('''\
|
|
26
|
+
LightGBMClassifier is a gradient boosting algorithm that builds
|
|
27
|
+
decision trees efficiently for classification tasks.''')
|
|
28
|
+
_description_long: str = textwrap.dedent('''\
|
|
29
|
+
LightGBMClassifier trains an ensemble of decision trees using histogram-based
|
|
30
|
+
splits and leaf-wise growth. It is designed to be fast while preserving
|
|
31
|
+
accuracy on tabular classification problems.''')
|
|
32
|
+
_usage: str = "Use when you want fast gradient boosting on tabular classification; compare to ActCatBoost or ActExtraTreesClassifier. Applicable to numeric and categorical features with binary or multiclass targets. Avoid when you need a simple, interpretable model or very small data."
|
|
33
|
+
refs: list[dict[str, Any]] = [
|
|
34
|
+
{
|
|
35
|
+
'year': 2017,
|
|
36
|
+
'name': 'LightGBM: A Highly Efficient Gradient Boosting Decision Tree',
|
|
37
|
+
'authors': [
|
|
38
|
+
'Guolin Ke',
|
|
39
|
+
'Qi Meng',
|
|
40
|
+
'Thomas Finley',
|
|
41
|
+
'Taifeng Wang',
|
|
42
|
+
'Wei Chen',
|
|
43
|
+
'Weidong Ma',
|
|
44
|
+
'Qiwei Ye',
|
|
45
|
+
'Tie-Yan Liu'
|
|
46
|
+
],
|
|
47
|
+
'doi': 'https://doi.org/10.48550/arXiv.1712.01005',
|
|
48
|
+
'publisher': 'Advances in Neural Information Processing Systems 30 (NeurIPS 2017)'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
def __init__(self):
|
|
53
|
+
self.configuration = {
|
|
54
|
+
'boosting_type': {
|
|
55
|
+
'description': 'Type of boosting algorithm.',
|
|
56
|
+
'default': 'gbdt',
|
|
57
|
+
'categorical': ['gbdt', 'dart']
|
|
58
|
+
},
|
|
59
|
+
'n_estimators': {
|
|
60
|
+
'description': 'Number of boosting iterations.',
|
|
61
|
+
'default': 200,
|
|
62
|
+
'range': [50, 1000]
|
|
63
|
+
},
|
|
64
|
+
'learning_rate': {
|
|
65
|
+
'description': 'Shrinkage rate applied to each tree.',
|
|
66
|
+
'default': 0.1,
|
|
67
|
+
'range': [0.01, 1.0]
|
|
68
|
+
},
|
|
69
|
+
'num_leaves': {
|
|
70
|
+
'description': 'Maximum number of leaves in one tree.',
|
|
71
|
+
'default': 31,
|
|
72
|
+
'range': [7, 255]
|
|
73
|
+
},
|
|
74
|
+
'max_depth': {
|
|
75
|
+
'description': 'Maximum depth of a tree, -1 means no limit.',
|
|
76
|
+
'default': -1,
|
|
77
|
+
'categorical': [-1, 3, 5, 10, 15]
|
|
78
|
+
},
|
|
79
|
+
'min_child_samples': {
|
|
80
|
+
'description': 'Minimum number of data in one leaf.',
|
|
81
|
+
'default': 20,
|
|
82
|
+
'range': [5, 200]
|
|
83
|
+
},
|
|
84
|
+
'subsample': {
|
|
85
|
+
'description': 'Fraction of data to use for each boosting iteration.',
|
|
86
|
+
'default': 1.0,
|
|
87
|
+
'range': [0.5, 1.0]
|
|
88
|
+
},
|
|
89
|
+
'subsample_freq': {
|
|
90
|
+
'description': 'Frequency for subsampling, 0 means disabled.',
|
|
91
|
+
'default': 0,
|
|
92
|
+
'range': [0, 10]
|
|
93
|
+
},
|
|
94
|
+
'colsample_bytree': {
|
|
95
|
+
'description': 'Fraction of features used for each tree.',
|
|
96
|
+
'default': 1.0,
|
|
97
|
+
'range': [0.5, 1.0]
|
|
98
|
+
},
|
|
99
|
+
'reg_alpha': {
|
|
100
|
+
'description': 'L1 regularization.',
|
|
101
|
+
'default': 0.0,
|
|
102
|
+
'range': [0.0, 1.0]
|
|
103
|
+
},
|
|
104
|
+
'reg_lambda': {
|
|
105
|
+
'description': 'L2 regularization.',
|
|
106
|
+
'default': 0.0,
|
|
107
|
+
'range': [0.0, 1.0]
|
|
108
|
+
},
|
|
109
|
+
'class_weight': {
|
|
110
|
+
'description': textwrap.dedent('''\
|
|
111
|
+
The "balanced" mode uses values of y to adjust weights inversely
|
|
112
|
+
proportional to class frequencies.'''),
|
|
113
|
+
'default': None,
|
|
114
|
+
'categorical': [None, 'balanced']
|
|
115
|
+
},
|
|
116
|
+
'random_state': {
|
|
117
|
+
'description': 'Random seed for reproducibility.',
|
|
118
|
+
'default': 42
|
|
119
|
+
},
|
|
120
|
+
'verbosity': {
|
|
121
|
+
'description': 'Controls the level of LightGBM verbosity.',
|
|
122
|
+
'default': -1,
|
|
123
|
+
'categorical': [-1, 0, 1]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
self.model: LGBMClassifier = None
|
|
127
|
+
self.columns: list[str] = []
|
|
128
|
+
self.categorical_columns: list[str] = []
|
|
129
|
+
self._category_levels: dict[str, list] = {}
|
|
130
|
+
|
|
131
|
+
def _select_features(self, X):
|
|
132
|
+
if self.columns and hasattr(X, 'columns'):
|
|
133
|
+
return X[self.columns]
|
|
134
|
+
return X
|
|
135
|
+
|
|
136
|
+
def _prepare_features(self, X, fit: bool = False):
|
|
137
|
+
X_selected = self._select_features(X)
|
|
138
|
+
if not hasattr(X_selected, 'copy'):
|
|
139
|
+
return X_selected
|
|
140
|
+
X_prepared = X_selected.copy()
|
|
141
|
+
if self.categorical_columns:
|
|
142
|
+
for column in self.categorical_columns:
|
|
143
|
+
if column not in X_prepared.columns:
|
|
144
|
+
continue
|
|
145
|
+
X_prepared[column] = X_prepared[column].astype('category')
|
|
146
|
+
if not fit and column in self._category_levels:
|
|
147
|
+
X_prepared[column] = X_prepared[column].cat.set_categories(
|
|
148
|
+
self._category_levels[column]
|
|
149
|
+
)
|
|
150
|
+
if fit:
|
|
151
|
+
self._category_levels = {
|
|
152
|
+
column: list(X_prepared[column].cat.categories)
|
|
153
|
+
for column in self.categorical_columns
|
|
154
|
+
if column in X_prepared.columns and hasattr(X_prepared[column], 'cat')
|
|
155
|
+
}
|
|
156
|
+
return X_prepared
|
|
157
|
+
|
|
158
|
+
def fit(self, dataset: Dataset): # pylint: disable=unused-argument
|
|
159
|
+
if LGBMClassifier is None:
|
|
160
|
+
raise ImportError(
|
|
161
|
+
"lightgbm is required for ActLightGBMClassifier. "
|
|
162
|
+
"Install with: pip install lightgbm"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
self.columns = dataset.get_columns_names_by_type(
|
|
166
|
+
[DataType.NUMERIC, DataType.CATEGORICAL]
|
|
167
|
+
)
|
|
168
|
+
if not self.columns:
|
|
169
|
+
self.columns = dataset.features
|
|
170
|
+
self.categorical_columns = dataset.get_columns_names_by_type(DataType.CATEGORICAL)
|
|
171
|
+
|
|
172
|
+
X_prepared = self._prepare_features(dataset.X, fit=True)
|
|
173
|
+
self.model = LGBMClassifier(**self.passthrough_parameters())
|
|
174
|
+
|
|
175
|
+
categorical_features = []
|
|
176
|
+
if self.categorical_columns and hasattr(X_prepared, 'columns'):
|
|
177
|
+
categorical_features = [
|
|
178
|
+
col for col in self.categorical_columns if col in X_prepared.columns
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
if categorical_features:
|
|
183
|
+
self.model.fit(
|
|
184
|
+
X_prepared,
|
|
185
|
+
dataset.y,
|
|
186
|
+
categorical_feature=categorical_features
|
|
187
|
+
)
|
|
188
|
+
else:
|
|
189
|
+
self.model.fit(X_prepared, dataset.y)
|
|
190
|
+
except _LGBM_ERRORS as exc:
|
|
191
|
+
raise ValueError(f"LightGBMClassifier training failed: {exc}") from exc
|
|
192
|
+
return self
|
|
193
|
+
|
|
194
|
+
def predict(self, X):
|
|
195
|
+
return super().predict(self._prepare_features(X))
|
|
196
|
+
|
|
197
|
+
def predict_proba(self, X):
|
|
198
|
+
return super().predict_proba(self._prepare_features(X))
|
|
199
|
+
|
|
200
|
+
def score(self, X, y=None, *args, **kwargs):
|
|
201
|
+
return self.model.score(self._prepare_features(X), y, *args, **kwargs)
|
|
202
|
+
|
|
203
|
+
def suitable(self, dataset: Dataset) -> bool:
|
|
204
|
+
supported = dataset.get_columns_names_by_type(
|
|
205
|
+
[DataType.NUMERIC, DataType.CATEGORICAL]
|
|
206
|
+
)
|
|
207
|
+
return LGBMClassifier is not None and dataset.type_of_target in \
|
|
208
|
+
['binary', 'multiclass', 'multilabel-indicator'] and bool(supported)
|
|
209
|
+
|
|
210
|
+
def priorize(self, candidate: Candidate = None) -> float:
|
|
211
|
+
return 0.5 # neutral
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
[STEP] Linear Discriminant Analysis
|
|
3
|
+
"""
|
|
4
|
+
import textwrap
|
|
5
|
+
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
|
|
6
|
+
from ....predictor import Predictor
|
|
7
|
+
from ....dataset import Dataset
|
|
8
|
+
from ....candidate import Candidate
|
|
9
|
+
from ....decorators.all import is_step
|
|
10
|
+
|
|
11
|
+
@is_step('predictor', 'tabular', 'classifier')
|
|
12
|
+
class ActLinearDiscriminantAnalysis(Predictor):
|
|
13
|
+
"""
|
|
14
|
+
[STEP] Linear Discriminant Analysis
|
|
15
|
+
"""
|
|
16
|
+
name = "Linear Discriminant Analysis"
|
|
17
|
+
_description = textwrap.dedent('''\
|
|
18
|
+
LinearDiscriminantAnalysis is a machine learning algorithm that finds
|
|
19
|
+
a linear combination of features that maximizes the separation between
|
|
20
|
+
classes for classification tasks.''')
|
|
21
|
+
_description_long = textwrap.dedent('''\
|
|
22
|
+
LinearDiscriminantAnalysis is a type of dimensionality reduction
|
|
23
|
+
algorithm that finds a linear combination of features that maximizes the
|
|
24
|
+
separation between classes for classification tasks.
|
|
25
|
+
It works by calculating the within-class and between-class scatter matrices,
|
|
26
|
+
and then finding the directions in the feature space that maximize the ratio of
|
|
27
|
+
the between-class scatter to the within-class scatter.''')
|
|
28
|
+
_usage = "Use when you need a fast linear classifier; simpler than ActCatBoost or ActExtraTreesClassifier. Applicable to tabular numeric data with binary or multiclass labels. Avoid when strong nonlinear patterns or categorical splits favor ActDecisionTreeClassifier."
|
|
29
|
+
refs = [
|
|
30
|
+
{
|
|
31
|
+
'year': 1936,
|
|
32
|
+
'name': 'The Use of Multiple Measurements in Taxonomic Problems',
|
|
33
|
+
'authors': [
|
|
34
|
+
'Sir Ronald Aylmer Fisher'
|
|
35
|
+
],
|
|
36
|
+
'doi': 'https://doi.org/10.1111/j.1469-1809.1936.tb02137.x',
|
|
37
|
+
'publisher': 'Annals of Eugenics Vol.7 page 179--188'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
def __init__(self):
|
|
41
|
+
self.configuration = {
|
|
42
|
+
'tol': {
|
|
43
|
+
'description': textwrap.dedent('''\
|
|
44
|
+
Absolute threshold for a singular value of X to be
|
|
45
|
+
considered significant, used to estimate the rank of X.'''),
|
|
46
|
+
'default': 0.0001,
|
|
47
|
+
'range': [1e-05, 0.1]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
self.model: LinearDiscriminantAnalysis = None
|
|
51
|
+
|
|
52
|
+
def fit(self, dataset: Dataset): # pylint: disable=unused-argument
|
|
53
|
+
self.model = LinearDiscriminantAnalysis(**self.passthrough_parameters())
|
|
54
|
+
|
|
55
|
+
self.model.fit(dataset.X, dataset.y)
|
|
56
|
+
|
|
57
|
+
return self
|
|
58
|
+
|
|
59
|
+
def suitable(self, dataset: Dataset) -> bool:
|
|
60
|
+
return dataset.type_of_target in ['binary', 'multiclass']
|
|
61
|
+
|
|
62
|
+
def priorize(self, candidate: Candidate = None) -> float:
|
|
63
|
+
return 0.5 # neutral
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""[STEP] Linear SVC Classifier"""
|
|
2
|
+
import textwrap
|
|
3
|
+
from typing import Any
|
|
4
|
+
from sklearn.svm import LinearSVC
|
|
5
|
+
from ....predictor import Predictor
|
|
6
|
+
from ....dataset import Dataset
|
|
7
|
+
from ....candidate import Candidate
|
|
8
|
+
from ....data_type import DataType
|
|
9
|
+
from ....decorators.all import is_step
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@is_step('predictor', 'tabular', 'classifier')
|
|
13
|
+
class ActLinearSVC(Predictor):
|
|
14
|
+
"""[STEP] Linear SVC Classifier"""
|
|
15
|
+
|
|
16
|
+
name: str = "Linear SVC Classifier"
|
|
17
|
+
_description: str = textwrap.dedent('''\
|
|
18
|
+
LinearSVC is a fast linear support vector classifier for high-dimensional
|
|
19
|
+
feature spaces, fitting a linear decision boundary with a large margin.''')
|
|
20
|
+
_description_long: str = textwrap.dedent('''\
|
|
21
|
+
LinearSVC solves a linear SVM optimization problem with the liblinear
|
|
22
|
+
optimizer. It scales well to sparse and high-dimensional data and supports
|
|
23
|
+
multiclass classification via a one-vs-rest strategy.''')
|
|
24
|
+
_usage: str = "Use when you need a fast linear margin classifier for high-dimensional numeric or sparse data; compare ActComplementNB. Applicable to tabular numeric binary or multiclass targets. Avoid when strong non-linear patterns or tree ensembles like ActExtraTreesClassifier are needed."
|
|
25
|
+
refs: list[dict[str, Any]] = [
|
|
26
|
+
{
|
|
27
|
+
'year': 1995,
|
|
28
|
+
'name': 'Support-Vector Networks',
|
|
29
|
+
'authors': [
|
|
30
|
+
'Corinna Cortes',
|
|
31
|
+
'Vladimir Vapnik'
|
|
32
|
+
],
|
|
33
|
+
'doi': 'https://doi.org/10.1007/BF00994018',
|
|
34
|
+
'publisher': 'Machine Learning Vol. 20, No. 3, page 273--297'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
'year': 2008,
|
|
38
|
+
'name': 'LIBLINEAR: A Library for Large Linear Classification',
|
|
39
|
+
'authors': [
|
|
40
|
+
'Rong-En Fan',
|
|
41
|
+
'Kai-Wei Chang',
|
|
42
|
+
'Cho-Jui Hsieh',
|
|
43
|
+
'Xiang-Rui Wang',
|
|
44
|
+
'Chih-Jen Lin'
|
|
45
|
+
],
|
|
46
|
+
'doi': 'https://doi.org/10.1145/1390681.1390687',
|
|
47
|
+
'publisher': 'Journal of Machine Learning Research Vol. 9, page 1871--1874'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
def __init__(self):
|
|
52
|
+
self.configuration = {
|
|
53
|
+
'C': {
|
|
54
|
+
'description': 'Inverse of regularization strength.',
|
|
55
|
+
'default': 1.0,
|
|
56
|
+
'range': [1e-03, 100.0]
|
|
57
|
+
},
|
|
58
|
+
'penalty': {
|
|
59
|
+
'description': textwrap.dedent('''\
|
|
60
|
+
Specify the norm of the penalty. The "l1" penalty requires
|
|
61
|
+
loss="squared_hinge" and dual=False.'''),
|
|
62
|
+
'default': 'l2',
|
|
63
|
+
'categorical': ['l2', 'l1']
|
|
64
|
+
},
|
|
65
|
+
'loss': {
|
|
66
|
+
'description': textwrap.dedent('''\
|
|
67
|
+
Loss function. The "hinge" loss requires penalty="l2" and dual=True.'''),
|
|
68
|
+
'default': 'squared_hinge',
|
|
69
|
+
'categorical': ['squared_hinge', 'hinge']
|
|
70
|
+
},
|
|
71
|
+
'dual': {
|
|
72
|
+
'description': textwrap.dedent('''\
|
|
73
|
+
Select the dual optimization problem. Prefer True when
|
|
74
|
+
n_samples < n_features.'''),
|
|
75
|
+
'default': True,
|
|
76
|
+
'categorical': [True, False]
|
|
77
|
+
},
|
|
78
|
+
'tol': {
|
|
79
|
+
'description': 'The stopping criterion.',
|
|
80
|
+
'default': 0.0001,
|
|
81
|
+
'range': [1e-05, 0.1]
|
|
82
|
+
},
|
|
83
|
+
'max_iter': {
|
|
84
|
+
'description': 'Maximum number of iterations.',
|
|
85
|
+
'default': 1000,
|
|
86
|
+
'range': [100, 5000]
|
|
87
|
+
},
|
|
88
|
+
'fit_intercept': {
|
|
89
|
+
'description': 'Whether to fit the intercept term.',
|
|
90
|
+
'default': True,
|
|
91
|
+
'categorical': [True, False]
|
|
92
|
+
},
|
|
93
|
+
'class_weight': {
|
|
94
|
+
'description': textwrap.dedent('''\
|
|
95
|
+
The "balanced" mode uses values of y to adjust weights inversely
|
|
96
|
+
proportional to class frequencies.'''),
|
|
97
|
+
'default': None,
|
|
98
|
+
'categorical': [None, 'balanced']
|
|
99
|
+
},
|
|
100
|
+
'random_state': {
|
|
101
|
+
'description': 'Random state for reproducibility.',
|
|
102
|
+
'default': 42
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
self.model: LinearSVC = None
|
|
106
|
+
self.columns: list[str] = []
|
|
107
|
+
|
|
108
|
+
def _select_features(self, X):
|
|
109
|
+
if self.columns and hasattr(X, 'columns'):
|
|
110
|
+
return X[self.columns]
|
|
111
|
+
return X
|
|
112
|
+
|
|
113
|
+
def fit(self, dataset: Dataset): # pylint: disable=unused-argument
|
|
114
|
+
self.columns = dataset.get_columns_names_by_type(DataType.NUMERIC)
|
|
115
|
+
if not self.columns:
|
|
116
|
+
self.columns = dataset.features
|
|
117
|
+
|
|
118
|
+
self.model = LinearSVC(**self.passthrough_parameters())
|
|
119
|
+
self.model.fit(self._select_features(dataset.X), dataset.y)
|
|
120
|
+
return self
|
|
121
|
+
|
|
122
|
+
def predict(self, X):
|
|
123
|
+
return super().predict(self._select_features(X))
|
|
124
|
+
|
|
125
|
+
def score(self, X, y=None, *args, **kwargs):
|
|
126
|
+
return self.model.score(self._select_features(X), y, *args, **kwargs)
|
|
127
|
+
|
|
128
|
+
def suitable(self, dataset: Dataset) -> bool:
|
|
129
|
+
return dataset.type_of_target in \
|
|
130
|
+
['binary', 'multiclass', 'multilabel-indicator'] \
|
|
131
|
+
and bool(dataset.get_columns_names_by_type(DataType.NUMERIC))
|
|
132
|
+
|
|
133
|
+
def priorize(self, candidate: Candidate = None) -> float:
|
|
134
|
+
return 0.5 # neutral
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""[STEP] Logistic Regression Classifier"""
|
|
2
|
+
import textwrap
|
|
3
|
+
from typing import Any
|
|
4
|
+
from sklearn.linear_model import LogisticRegression
|
|
5
|
+
from ....predictor import Predictor
|
|
6
|
+
from ....dataset import Dataset
|
|
7
|
+
from ....candidate import Candidate
|
|
8
|
+
from ....decorators.all import is_step
|
|
9
|
+
|
|
10
|
+
@is_step('predictor', 'tabular', 'fast_predictor', 'classifier', 'baseline_predictor')
|
|
11
|
+
class ActLogisticRegression(Predictor):
|
|
12
|
+
"""[STEP] Logistic Regression Classifier"""
|
|
13
|
+
|
|
14
|
+
name: str = "Logistic Regression Classifier"
|
|
15
|
+
_description: str = textwrap.dedent('''\
|
|
16
|
+
LogisticRegression is a machine learning algorithm
|
|
17
|
+
that models the relationship between input features and a binary
|
|
18
|
+
output variable using a logistic function.''')
|
|
19
|
+
_description_long: str = textwrap.dedent('''\
|
|
20
|
+
LogisticRegression is a type of classification algorithm that models
|
|
21
|
+
the relationship between input features and a binary
|
|
22
|
+
output variable using a logistic function.
|
|
23
|
+
It works by finding the best-fitting line or hyperplane that
|
|
24
|
+
maximizes the likelihood of the observed output variables given the input features.''')
|
|
25
|
+
_usage: str = "Use when you need a fast linear baseline over ActDecisionTreeClassifier. Applicable to tabular binary or multiclass data with numeric or one-hot inputs. Avoid when nonlinear interactions dominate or max accuracy is required; prefer ActCatBoost."
|
|
26
|
+
refs: list[dict[str, Any]] = [
|
|
27
|
+
{
|
|
28
|
+
'year': 1944,
|
|
29
|
+
'name': 'Application of the Logistic Function to Bio-Essay',
|
|
30
|
+
'authors': [
|
|
31
|
+
'Joseph Berkson'
|
|
32
|
+
],
|
|
33
|
+
'doi': 'https://doi.org/10.2307/2280041',
|
|
34
|
+
'publisher': (
|
|
35
|
+
'Journal of the American Statistical Association '
|
|
36
|
+
'Vol. 39, No. 227, page 357--365'
|
|
37
|
+
)
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
'year': 1951,
|
|
41
|
+
'name': 'Why I Prefer Logits to Probits',
|
|
42
|
+
'authors': [
|
|
43
|
+
'Joseph Berkson'
|
|
44
|
+
],
|
|
45
|
+
'doi': 'https://doi.org/10.2307/3001655',
|
|
46
|
+
'publisher': (
|
|
47
|
+
'Biometrics '
|
|
48
|
+
'Vol. 7, No. 4, page 327--339'
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
def __init__(self):
|
|
54
|
+
self.configuration = {
|
|
55
|
+
'random_state': {
|
|
56
|
+
'description': 'random_state',
|
|
57
|
+
'default': 42
|
|
58
|
+
},
|
|
59
|
+
'penalty': {
|
|
60
|
+
'description': 'Specify the norm of the penalty',
|
|
61
|
+
'default': 'l2',
|
|
62
|
+
'categorical': ['l2', None]
|
|
63
|
+
},
|
|
64
|
+
'tol': {
|
|
65
|
+
'description': 'The stopping criterion.',
|
|
66
|
+
'default': 0.0001,
|
|
67
|
+
'range': [1e-05, 0.1]
|
|
68
|
+
},
|
|
69
|
+
'class_weight': {
|
|
70
|
+
'description': textwrap.dedent('''\
|
|
71
|
+
The “balanced” mode uses the values of y to automatically
|
|
72
|
+
adjust weights inversely proportional to class frequencies.'''),
|
|
73
|
+
'default': None,
|
|
74
|
+
'categorical': [None, 'balanced']
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
self.model: LogisticRegression = None
|
|
78
|
+
|
|
79
|
+
def fit(self, dataset: Dataset): # pylint: disable=unused-argument
|
|
80
|
+
self.model = LogisticRegression(
|
|
81
|
+
**self.passthrough_parameters()
|
|
82
|
+
)
|
|
83
|
+
self.model.fit(dataset.X, dataset.y)
|
|
84
|
+
|
|
85
|
+
return self
|
|
86
|
+
|
|
87
|
+
def suitable(self, dataset: Dataset) -> bool:
|
|
88
|
+
return dataset.type_of_target in \
|
|
89
|
+
['binary', 'multiclass', 'multilabel-indicator']
|
|
90
|
+
|
|
91
|
+
def priorize(self, candidate: Candidate = None) -> float:
|
|
92
|
+
return 0.5 # neutral
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""[STEP] MLP Classifier"""
|
|
2
|
+
|
|
3
|
+
import textwrap
|
|
4
|
+
from typing import Any
|
|
5
|
+
from sklearn.neural_network import MLPClassifier
|
|
6
|
+
from ....predictor import Predictor
|
|
7
|
+
from ....dataset import Dataset
|
|
8
|
+
from ....candidate import Candidate
|
|
9
|
+
from ....decorators.all import is_step
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@is_step('predictor', 'tabular', 'classifier')
|
|
13
|
+
class ActMLPClassifier(Predictor):
|
|
14
|
+
"""[STEP] MLP Classifier"""
|
|
15
|
+
|
|
16
|
+
name: str = "MLP Classifier"
|
|
17
|
+
_description: str = textwrap.dedent('''\
|
|
18
|
+
MLPClassifier is a machine learning algorithm that models the relationship
|
|
19
|
+
between input features and a categorical output variable using a
|
|
20
|
+
multi-layer perceptron neural network.''')
|
|
21
|
+
_description_long: str = textwrap.dedent('''\
|
|
22
|
+
MLPClassifier is a type of neural network algorithm that models the
|
|
23
|
+
relationship between input features and a categorical output variable using a
|
|
24
|
+
multi-layer perceptron (MLP) neural network.
|
|
25
|
+
It works by transforming the input features through one or more hidden layers with
|
|
26
|
+
non-linear activation functions, and then using a final layer with a softmax activation
|
|
27
|
+
function to output a probability distribution over the classes.''')
|
|
28
|
+
_usage: str = "Use when you need a nonlinear tabular classifier and can tune, versus ActDecisionTreeClassifier or ActExtraTreesClassifier. Applicable to binary or multiclass tabular features. Avoid when data are small, very sparse, or you need fast, transparent models like ActBernoulliNb."
|
|
29
|
+
refs: list[dict[str, Any]] = [
|
|
30
|
+
{
|
|
31
|
+
'year': 1989,
|
|
32
|
+
'name': 'Connectionist Learning Procedures',
|
|
33
|
+
'authors': [
|
|
34
|
+
'Geoffrey E. Hinton'
|
|
35
|
+
],
|
|
36
|
+
'doi': 'https://doi.org/10.1016/0004-3702(89)90049-0',
|
|
37
|
+
'publisher': 'Artificial intelligence Vol. 40.1 page 185--234'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
'year': 2010,
|
|
41
|
+
'name': 'Understanding the difficulty of training deep feedforward neural networks',
|
|
42
|
+
'authors': [
|
|
43
|
+
'Xavier Glorot',
|
|
44
|
+
'Yoshua Bengio'
|
|
45
|
+
],
|
|
46
|
+
'doi': "https://www.semanticscholar.org/paper/\
|
|
47
|
+
Understanding-the-difficulty-of-training-deep-Glorot-Bengio/\
|
|
48
|
+
ea9d2a2b4ce11aaf85136840c65f3bc9c03ab649",
|
|
49
|
+
'publisher': (
|
|
50
|
+
'Proceedings of the Thirteenth International Conference on '
|
|
51
|
+
'Artificial Intelligence and Statistics page 249--256'
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
def __init__(self):
|
|
57
|
+
self.configuration = {
|
|
58
|
+
'activation': {
|
|
59
|
+
'description': 'Activation function for the hidden layer.',
|
|
60
|
+
'default': 'relu',
|
|
61
|
+
'categorical': ["tanh", "relu"]
|
|
62
|
+
},
|
|
63
|
+
'alpha': {
|
|
64
|
+
'description': textwrap.dedent('''\
|
|
65
|
+
Strength of the L2 regularization term. The L2
|
|
66
|
+
regularization term is divided by the sample size when
|
|
67
|
+
added to the loss.'''),
|
|
68
|
+
'default': 0.0001,
|
|
69
|
+
'range': [1e-07, 0.1]
|
|
70
|
+
},
|
|
71
|
+
'hidden_layer_count': {
|
|
72
|
+
'description': 'NUmber of hidden layer',
|
|
73
|
+
'default': 1,
|
|
74
|
+
'range': [1, 4],
|
|
75
|
+
'passthrough': False
|
|
76
|
+
},
|
|
77
|
+
'node_per_layer': {
|
|
78
|
+
'description': 'Number of node per layer',
|
|
79
|
+
'default': 32,
|
|
80
|
+
'range': [16, 256],
|
|
81
|
+
'passthrough': False
|
|
82
|
+
},
|
|
83
|
+
'learning_rate_init': {
|
|
84
|
+
'description': 'Learning rate schedule for weight updates',
|
|
85
|
+
'default': 0.001,
|
|
86
|
+
'range': [0.0001, 0.5]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
self.model: MLPClassifier = None
|
|
90
|
+
|
|
91
|
+
def fit(self, dataset: Dataset): # pylint: disable=unused-argument
|
|
92
|
+
self.model = MLPClassifier(
|
|
93
|
+
hidden_layer_sizes=[self.get_config('node_per_layer') \
|
|
94
|
+
for i in range(self.get_config('hidden_layer_count'))],
|
|
95
|
+
early_stopping=True,
|
|
96
|
+
max_iter=400,
|
|
97
|
+
**self.passthrough_parameters())
|
|
98
|
+
|
|
99
|
+
self.model.fit(dataset.X, dataset.y)
|
|
100
|
+
return self
|
|
101
|
+
|
|
102
|
+
def suitable(self, dataset: Dataset) -> bool:
|
|
103
|
+
return dataset.type_of_target in \
|
|
104
|
+
['binary', 'multiclass', 'multilabel-indicator']
|
|
105
|
+
|
|
106
|
+
def priorize(self, candidate: Candidate = None) -> float:
|
|
107
|
+
return 0.5 # neutral
|