diff --git a/geochemistrypi/data_mining/model/_base.py b/geochemistrypi/data_mining/model/_base.py index 7d54c16..a6b3715 100644 --- a/geochemistrypi/data_mining/model/_base.py +++ b/geochemistrypi/data_mining/model/_base.py @@ -301,19 +301,19 @@ def _plot_permutation_importance( trained_model: object, image_config: dict, algorithm_name: str, - grah_name: str, + graph_name: str, local_path: str, mlflow_path: str, ) -> None: """Permutation importance plot.""" - print(f"-----* {grah_name} *-----") # Permutation Importance + print(f"-----* {graph_name} *-----") # Permutation Importance importances_mean, importances_std, importances = plot_permutation_importance(X_test, y_test, trained_model, image_config) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) - save_data(X_test, name_column, f"{grah_name} - X Test", local_path, mlflow_path) - save_data(y_test, name_column, f"{grah_name} - Y Test", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) + save_data(X_test, name_column, f"{graph_name} - X Test", local_path, mlflow_path) + save_data(y_test, name_column, f"{graph_name} - Y Test", local_path, mlflow_path) data_dict = {"importances_mean": importances_mean.tolist(), "importances_std": importances_std.tolist(), "importances": importances.tolist()} data_str = json.dumps(data_dict, indent=4) - save_text(data_str, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_text(data_str, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) class TreeWorkflowMixin: diff --git a/geochemistrypi/data_mining/model/clustering.py b/geochemistrypi/data_mining/model/clustering.py index 9df245b..ce8d609 100644 --- a/geochemistrypi/data_mining/model/clustering.py +++ b/geochemistrypi/data_mining/model/clustering.py @@ -80,45 +80,45 @@ def _score(data: pd.DataFrame, labels: pd.Series, func_name: str, algorithm_name mlflow.log_metrics(scores) @staticmethod - def _scatter2d(data: pd.DataFrame, labels: pd.Series, name_column: str, cluster_centers_: pd.DataFrame, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _scatter2d(data: pd.DataFrame, labels: pd.Series, name_column: str, cluster_centers_: pd.DataFrame, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the two-dimensional diagram of the clustering result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") scatter2d(data, labels, cluster_centers_, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data_with_labels = pd.concat([data, labels], axis=1) - save_data(data_with_labels, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data_with_labels, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod - def _scatter3d(data: pd.DataFrame, labels: pd.Series, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _scatter3d(data: pd.DataFrame, labels: pd.Series, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the three-dimensional diagram of the clustering result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") scatter3d(data, labels, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data_with_labels = pd.concat([data, labels], axis=1) - save_data(data_with_labels, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data_with_labels, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod def _plot_silhouette_diagram( - data: pd.DataFrame, labels: pd.Series, name_column: str, model: object, cluster_centers_: np.ndarray, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str + data: pd.DataFrame, labels: pd.Series, name_column: str, model: object, cluster_centers_: np.ndarray, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str ) -> None: """Plot the silhouette diagram of the clustering result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_silhouette_diagram(data, labels, cluster_centers_, model, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data_with_labels = pd.concat([data, labels], axis=1) - save_data(data_with_labels, name_column, f"{grah_name} - Data With Labels", local_path, mlflow_path) + save_data(data_with_labels, name_column, f"{graph_name} - Data With Labels", local_path, mlflow_path) if not isinstance(cluster_centers_, str): cluster_center_data = pd.DataFrame(cluster_centers_, columns=data.columns) - save_data(cluster_center_data, name_column, f"{grah_name} - Cluster Centers", local_path, mlflow_path) + save_data(cluster_center_data, name_column, f"{graph_name} - Cluster Centers", local_path, mlflow_path) @staticmethod - def _plot_silhouette_value_diagram(data: pd.DataFrame, labels: pd.Series, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_silhouette_value_diagram(data: pd.DataFrame, labels: pd.Series, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the silhouette value diagram of the clustering result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_silhouette_value_diagram(data, labels, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data_with_labels = pd.concat([data, labels], axis=1) - save_data(data_with_labels, name_column, f"{grah_name} - Data With Labels", local_path, mlflow_path) + save_data(data_with_labels, name_column, f"{graph_name} - Data With Labels", local_path, mlflow_path) def common_components(self) -> None: """Invoke all common application functions for clustering algorithms.""" @@ -159,7 +159,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, + graph_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, ) # choose three of dimensions to draw @@ -171,7 +171,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.CLUSTER_THREE_DIMENSIONAL_DIAGRAM.value, + graph_name=ClusteringCommonFunction.CLUSTER_THREE_DIMENSIONAL_DIAGRAM.value, ) elif self.X.shape[1] == 3: # choose two of dimensions to draw @@ -184,7 +184,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, + graph_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, ) # no need to choose @@ -195,7 +195,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.CLUSTER_THREE_DIMENSIONAL_DIAGRAM.value, + graph_name=ClusteringCommonFunction.CLUSTER_THREE_DIMENSIONAL_DIAGRAM.value, ) elif self.X.shape[1] == 2: self._scatter2d( @@ -206,7 +206,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, + graph_name=ClusteringCommonFunction.CLUSTER_TWO_DIMENSIONAL_DIAGRAM.value, ) else: pass @@ -220,7 +220,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.SILHOUETTE_DIAGRAM.value, + graph_name=ClusteringCommonFunction.SILHOUETTE_DIAGRAM.value, ) self._plot_silhouette_value_diagram( data=self.X, @@ -229,7 +229,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=ClusteringCommonFunction.SILHOUETTE_VALUE_DIAGRAM.value, + graph_name=ClusteringCommonFunction.SILHOUETTE_VALUE_DIAGRAM.value, ) diff --git a/geochemistrypi/data_mining/model/decomposition.py b/geochemistrypi/data_mining/model/decomposition.py index 25cb611..feeb936 100644 --- a/geochemistrypi/data_mining/model/decomposition.py +++ b/geochemistrypi/data_mining/model/decomposition.py @@ -67,28 +67,28 @@ def _reduced_data2pd(self, reduced_data: np.ndarray, components_num: int) -> Non self.X_reduced.columns = pa_name @staticmethod - def _plot_2d_scatter_diagram(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_2d_scatter_diagram(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the two-dimensional diagram of the decomposition result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_2d_scatter_diagram(data, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) - save_data(data, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod - def _plot_heatmap(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_heatmap(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot a heatmap for the decomposition result.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_heatmap(data, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) - save_data(data, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod - def _plot_contour(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_contour(data: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot a contour plot for dimensionality reduction results.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_contour(data, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) - save_data(data, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) def common_components(self) -> None: """Invoke all common application functions for decomposition algorithms by Scikit-learn framework.""" @@ -100,7 +100,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=DecompositionCommonFunction.DECOMPOSITION_TWO_DIMENSIONAL_DIAGRAM.value, + graph_name=DecompositionCommonFunction.DECOMPOSITION_TWO_DIMENSIONAL_DIAGRAM.value, ) self._plot_heatmap( data=self.X, @@ -108,7 +108,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=DecompositionCommonFunction.DECOMPOSITION_HEATMAP.value, + graph_name=DecompositionCommonFunction.DECOMPOSITION_HEATMAP.value, ) self._plot_contour( data=self.X, @@ -116,7 +116,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=DecompositionCommonFunction.DIMENSIONALITY_REDUCTION_CONTOUR_PLOT.value, + graph_name=DecompositionCommonFunction.DIMENSIONALITY_REDUCTION_CONTOUR_PLOT.value, ) diff --git a/geochemistrypi/data_mining/model/func/algo_regression/_enum.py b/geochemistrypi/data_mining/model/func/algo_regression/_enum.py index 8f3d010..f3568fb 100644 --- a/geochemistrypi/data_mining/model/func/algo_regression/_enum.py +++ b/geochemistrypi/data_mining/model/func/algo_regression/_enum.py @@ -20,25 +20,54 @@ class RegressionSpecialFunction(Enum): THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" +class XGBoostSpecialFunction(Enum): + FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram" + + +class DecisionTreeSpecialFunction(Enum): + FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram" + SINGLE_TREE_DIAGRAM = "Single Tree Diagram" + + class MLPSpecialFunction(Enum): LOSS_CURVE_DIAGRAM = "Loss Curve Diagram" class ClassicalLinearSpecialFunction(Enum): LINEAR_REGRESSION_FORMULA = "Linear Regression Formula" + TWO_DIMENSIONAL_SCATTER_DIAGRAM = "2D Scatter Diagram" + THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram" + TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram" + THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" class LassoSpecialFunction(Enum): LASSO_REGRESSION_FORMULA = "Lasso Regression Formula" + TWO_DIMENSIONAL_SCATTER_DIAGRAM = "2D Scatter Diagram" + THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram" + TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram" + THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" class ElasticNetSpecialFunction(Enum): ELASTIC_NET_FORMULA = "Elastic Net Formula" + TWO_DIMENSIONAL_SCATTER_DIAGRAM = "2D Scatter Diagram" + THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram" + TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram" + THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" class SGDSpecialFunction(Enum): SGD_REGRESSION_FORMULA = "SGD Regression Formula" + TWO_DIMENSIONAL_SCATTER_DIAGRAM = "2D Scatter Diagram" + THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram" + TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram" + THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" class RidgeSpecialFunction(Enum): RIDGE_REGRESSION_FORMULA = "Ridge Regression Formula" + TWO_DIMENSIONAL_SCATTER_DIAGRAM = "2D Scatter Diagram" + THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram" + TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram" + THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram" diff --git a/geochemistrypi/data_mining/model/regression.py b/geochemistrypi/data_mining/model/regression.py index c8ef439..9fbf4db 100644 --- a/geochemistrypi/data_mining/model/regression.py +++ b/geochemistrypi/data_mining/model/regression.py @@ -27,6 +27,7 @@ from .func.algo_regression._elastic_net import elastic_net_manual_hyper_parameters from .func.algo_regression._enum import ( ClassicalLinearSpecialFunction, + DecisionTreeSpecialFunction, ElasticNetSpecialFunction, LassoSpecialFunction, MLPSpecialFunction, @@ -34,6 +35,7 @@ RegressionSpecialFunction, RidgeSpecialFunction, SGDSpecialFunction, + XGBoostSpecialFunction, ) from .func.algo_regression._extra_tree import extra_trees_manual_hyper_parameters from .func.algo_regression._gradient_boosting import gradient_boosting_manual_hyper_parameters @@ -52,7 +54,7 @@ class RegressionWorkflowBase(WorkflowBase): """The base workflow class of regression algorithms.""" - common_function = [grah.value for grah in RegressionCommonFunction] + common_function = [func.value for func in RegressionCommonFunction] # ["Model Score", "Cross Validation", "Model Prediction", "Model Persistence", "Predicted vs. Actual Diagram", "Residuals Diagram", "Permutation Importance Diagram"] def __init__(self) -> None: @@ -132,40 +134,40 @@ def manual_hyper_parameters(cls) -> Dict: return dict() @staticmethod - def _plot_predicted_vs_actual(y_test_predict: pd.DataFrame, y_test: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_predicted_vs_actual(y_test_predict: pd.DataFrame, y_test: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the predicted vs. actual diagram.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") plot_predicted_vs_actual(y_test_predict, y_test, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data = pd.concat([y_test, y_test_predict], axis=1) - save_data(data, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod - def _plot_residuals(y_test_predict: pd.DataFrame, y_test: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, grah_name: str) -> None: + def _plot_residuals(y_test_predict: pd.DataFrame, y_test: pd.DataFrame, name_column: str, algorithm_name: str, local_path: str, mlflow_path: str, graph_name: str) -> None: """Plot the residuals diagram.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") residuals = plot_residuals(y_test_predict, y_test, algorithm_name) - save_fig(f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_fig(f"{graph_name} - {algorithm_name}", local_path, mlflow_path) data = pd.concat([y_test, residuals], axis=1) - save_data(data, name_column, f"{grah_name} - {algorithm_name}", local_path, mlflow_path) + save_data(data, name_column, f"{graph_name} - {algorithm_name}", local_path, mlflow_path) @staticmethod - def _score(y_true: pd.DataFrame, y_predict: pd.DataFrame, algorithm_name: str, store_path: str, grah_name: str) -> None: + def _score(y_true: pd.DataFrame, y_predict: pd.DataFrame, algorithm_name: str, store_path: str, graph_name: str) -> None: """Calculate the score of the model.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") scores = score(y_true, y_predict) scores_str = json.dumps(scores, indent=4) - save_text(scores_str, f"{grah_name} - {algorithm_name}", store_path) + save_text(scores_str, f"{graph_name} - {algorithm_name}", store_path) mlflow.log_metrics(scores) @staticmethod - def _cross_validation(trained_model: object, X_train: pd.DataFrame, y_train: pd.DataFrame, cv_num: int, algorithm_name: str, store_path: str, grah_name: str) -> None: + def _cross_validation(trained_model: object, X_train: pd.DataFrame, y_train: pd.DataFrame, cv_num: int, algorithm_name: str, store_path: str, graph_name: str) -> None: """Cross validation.""" - print(f"-----* {grah_name} *-----") + print(f"-----* {graph_name} *-----") print(f"K-Folds: {cv_num}") scores = cross_validation(trained_model, X_train, y_train, cv_num=cv_num) scores_str = json.dumps(scores, indent=4) - save_text(scores_str, f"{grah_name} - {algorithm_name}", store_path) + save_text(scores_str, f"{graph_name} - {algorithm_name}", store_path) @dispatch() def common_components(self) -> None: @@ -177,7 +179,7 @@ def common_components(self) -> None: y_predict=RegressionWorkflowBase.y_test_predict, algorithm_name=self.naming, store_path=GEOPI_OUTPUT_METRICS_PATH, - grah_name=RegressionCommonFunction.MODEL_SCORE.value, + graph_name=RegressionCommonFunction.MODEL_SCORE.value, ) self._cross_validation( trained_model=self.model, @@ -186,7 +188,7 @@ def common_components(self) -> None: cv_num=10, algorithm_name=self.naming, store_path=GEOPI_OUTPUT_METRICS_PATH, - grah_name=RegressionCommonFunction.CROSS_VALIDATION.value, + graph_name=RegressionCommonFunction.CROSS_VALIDATION.value, ) self._plot_predicted_vs_actual( y_test_predict=RegressionWorkflowBase.y_test_predict, @@ -195,7 +197,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.PREDICTED_VS_ACTUAL_DIAGRAM.value, + graph_name=RegressionCommonFunction.PREDICTED_VS_ACTUAL_DIAGRAM.value, ) self._plot_residuals( y_test_predict=RegressionWorkflowBase.y_test_predict, @@ -204,7 +206,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.RESIDUALS_DIAGRAM.value, + graph_name=RegressionCommonFunction.RESIDUALS_DIAGRAM.value, ) self._plot_permutation_importance( X_test=RegressionWorkflowBase.X_test, @@ -215,7 +217,7 @@ def common_components(self) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.PERMUTATION_IMPORTANC_DIAGRAM.value, + graph_name=RegressionCommonFunction.PERMUTATION_IMPORTANC_DIAGRAM.value, ) @dispatch(bool) @@ -228,7 +230,7 @@ def common_components(self, is_automl: bool = False) -> None: y_predict=RegressionWorkflowBase.y_test_predict, algorithm_name=self.naming, store_path=GEOPI_OUTPUT_METRICS_PATH, - grah_name=RegressionCommonFunction.MODEL_SCORE.value, + graph_name=RegressionCommonFunction.MODEL_SCORE.value, ) self._cross_validation( trained_model=self.auto_model, @@ -237,7 +239,7 @@ def common_components(self, is_automl: bool = False) -> None: cv_num=10, algorithm_name=self.naming, store_path=GEOPI_OUTPUT_METRICS_PATH, - grah_name=RegressionCommonFunction.CROSS_VALIDATION.value, + graph_name=RegressionCommonFunction.CROSS_VALIDATION.value, ) self._plot_predicted_vs_actual( y_test_predict=RegressionWorkflowBase.y_test_predict, @@ -246,7 +248,7 @@ def common_components(self, is_automl: bool = False) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.PREDICTED_VS_ACTUAL_DIAGRAM.value, + graph_name=RegressionCommonFunction.PREDICTED_VS_ACTUAL_DIAGRAM.value, ) self._plot_residuals( y_test_predict=RegressionWorkflowBase.y_test_predict, @@ -255,7 +257,7 @@ def common_components(self, is_automl: bool = False) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.RESIDUALS_DIAGRAM.value, + graph_name=RegressionCommonFunction.RESIDUALS_DIAGRAM.value, ) self._plot_permutation_importance( X_test=RegressionWorkflowBase.X_test, @@ -266,7 +268,7 @@ def common_components(self, is_automl: bool = False) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - grah_name=RegressionCommonFunction.PERMUTATION_IMPORTANC_DIAGRAM.value, + graph_name=RegressionCommonFunction.PERMUTATION_IMPORTANC_DIAGRAM.value, ) @@ -274,7 +276,7 @@ class PolynomialRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Polynomial Regression algorithm to make insightful products.""" name = "Polynomial Regression" - special_function = [] + special_function = [] # "Polynomial Regression Formula" def __init__( self, @@ -344,7 +346,8 @@ class XGBoostRegression(TreeWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using XGBoost algorithm to make insightful products.""" name = "XGBoost" - special_function = [RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value] # Feature Importance Diagram + special_function = [func.value for func in XGBoostSpecialFunction] + # Feature Importance Diagram # In fact, it's used for type hint in the original xgboost package. # Hence, we have to copy it here again. Just ignore it @@ -626,8 +629,7 @@ def __init__( early_stopping_rounds=self.early_stopping_rounds, ) - self.naming = (XGBoostRegression.name,) - self.func = (XGBoostRegression.special_function,) + self.naming = XGBoostRegression.name @property def settings(self) -> Dict: @@ -668,7 +670,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) # self._histograms_feature_weights( # X=XGBoostRegression.X, @@ -691,7 +693,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) # self._histograms_feature_weights( # X=XGBoostRegression.X, @@ -707,10 +709,7 @@ class DecisionTreeRegression(TreeWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Decision Tree algorithm to make insightful products.""" name = "Decision Tree" - special_function = [ - RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, - RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, - ] + special_function = [func.value for func in DecisionTreeSpecialFunction] # ["Feature Importance Diagram", "Single Tree Diagram"] def __init__( @@ -884,7 +883,6 @@ def __init__( ccp_alpha=self.ccp_alpha[0], ) self.naming = DecisionTreeRegression.name - self.func = DecisionTreeRegression.special_function self.customized = True self.customized_name = "Decision Tree" @@ -952,7 +950,7 @@ def special_components(self, **kwargs): algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.model, @@ -960,7 +958,7 @@ def special_components(self, **kwargs): algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @dispatch(bool) @@ -975,7 +973,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.auto_model, @@ -983,7 +981,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @@ -991,10 +989,7 @@ class ExtraTreesRegression(TreeWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Extra-Trees algorithm to make insightful products.""" name = "Extra-Trees" - special_function = [ - RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, - RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, - ] + special_function = [func.value for func in DecisionTreeSpecialFunction] # ["Feature Importance Diagram", "Single Tree Diagram"] def __init__( @@ -1224,7 +1219,6 @@ def __init__( ) self.naming = ExtraTreesRegression.name - self.func = ExtraTreesRegression.special_function @property def settings(self) -> Dict: @@ -1259,7 +1253,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.model.estimators_[0], @@ -1267,7 +1261,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @dispatch(bool) @@ -1282,7 +1276,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.auto_model.estimators_[0], @@ -1290,7 +1284,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @@ -1298,10 +1292,7 @@ class RandomForestRegression(TreeWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Random Forest algorithm to make insightful products.""" name = "Random Forest" - special_function = [ - RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, - RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, - ] + special_function = [func.value for func in DecisionTreeSpecialFunction] # ["Feature Importance Diagram", "Single Tree Diagram"] def __init__( @@ -1533,7 +1524,6 @@ def __init__( max_samples=self.max_samples, ) self.naming = RandomForestRegression.name - self.func = RandomForestRegression.special_function @property def settings(self) -> Dict: @@ -1568,7 +1558,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.model.estimators_[0], @@ -1576,7 +1566,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @dispatch(bool) @@ -1591,7 +1581,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.auto_model.estimators_[0], @@ -1599,7 +1589,7 @@ def special_components(self, is_automl: bool = False, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @@ -1777,7 +1767,8 @@ class MLPRegression(RegressionWorkflowBase): """The automation workflow of using Multi-layer Perceptron algorithm to make insightful products.""" name = "Multi-layer Perceptron" - special_function = [MLPSpecialFunction.LOSS_CURVE_DIAGRAM.value] # "Loss Curve Diagram" + special_function = [func.value for func in MLPSpecialFunction] + # "Loss Curve Diagram" def __init__( self, @@ -1994,7 +1985,6 @@ def __init__( ) self.naming = MLPRegression.name - self.func = MLPRegression.special_function def ray_tune(self, X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.DataFrame, y_test: pd.DataFrame) -> None: """The customized MLP of the combinations of Ray, FLAML and Scikit-learn framework.""" @@ -2088,7 +2078,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=MLPSpecialFunction.LOSS_CURVE_DIAGRAM.value, ) @dispatch(bool) @@ -2101,7 +2091,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=MLPSpecialFunction.LOSS_CURVE_DIAGRAM.value, ) @@ -2109,13 +2099,7 @@ class ClassicalLinearRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Linear Regression algorithm to make insightful products.""" name = "Linear Regression" - special_function = [ - ClassicalLinearSpecialFunction.LINEAR_REGRESSION_FORMULA.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, - ] + special_function = [func.value for func in ClassicalLinearSpecialFunction] # [Linear Regression Formula", "2D Scatter Diagram", "3D Scatter Diagram", "2D Line Diagram", "3D Surface Diagram"] def __init__( @@ -2168,7 +2152,6 @@ def __init__( ) self.naming = ClassicalLinearRegression.name - self.func = ClassicalLinearRegression.special_function @classmethod def manual_hyper_parameters(cls) -> Dict: @@ -2203,7 +2186,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(ClassicalLinearRegression.X_test, 2) @@ -2214,7 +2197,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -2226,7 +2209,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -2236,7 +2219,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=ClassicalLinearRegression.X_test, @@ -2246,7 +2229,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -2257,7 +2240,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=ClassicalLinearRegression.X_test, @@ -2267,7 +2250,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -2426,10 +2409,7 @@ class GradientBoostingRegression(TreeWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Gradient Boosting algorithm to make insightful products.""" name = "Gradient Boosting" - special_function = [ - RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, - RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, - ] + special_function = [func.value for func in DecisionTreeSpecialFunction] # ["Feature Importance Diagram", "Single Tree Diagram"] def __init__( @@ -2702,7 +2682,6 @@ def __init__( ) self.naming = GradientBoostingRegression.name - self.func = GradientBoostingRegression.special_function self.customized = True self.customized_name = "Gradient Boosting" @@ -2768,7 +2747,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.model.estimators_[0][0], @@ -2776,7 +2755,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @dispatch(bool) @@ -2791,7 +2770,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[0], + func_name=RegressionSpecialFunction.FEATURE_IMPORTANCE_DIAGRAM.value, ) self._plot_tree( trained_model=self.auto_model.estimators_[0][0], @@ -2799,7 +2778,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.SINGLE_TREE_DIAGRAM.value, ) @@ -2807,13 +2786,7 @@ class LassoRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Lasso to make insightful products.""" name = "Lasso Regression" - special_function = [ - LassoSpecialFunction.LASSO_REGRESSION_FORMULA.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, - ] + special_function = [func.value for func in LassoSpecialFunction] # ["Lasso Regression Formula","2D Scatter Diagram", "3D Scatter Diagram", "2D Line Diagram", "3D Surface Diagram"] def __init__( @@ -2919,7 +2892,6 @@ def __init__( ) self.naming = LassoRegression.name - self.func = LassoRegression.special_function self.customized = True self.customized_name = "Lasso" @@ -2997,7 +2969,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(LassoRegression.X_test, 2) @@ -3008,7 +2980,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3020,7 +2992,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3030,7 +3002,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=LassoRegression.X_test, @@ -3040,7 +3012,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3051,7 +3023,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=LassoRegression.X_test, @@ -3061,7 +3033,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -3092,7 +3064,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(LassoRegression.X_test, 2) @@ -3103,7 +3075,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3115,7 +3087,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3125,7 +3097,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=LassoRegression.X_test, @@ -3135,7 +3107,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3146,7 +3118,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=LassoRegression.X_test, @@ -3156,7 +3128,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -3166,13 +3138,7 @@ class ElasticNetRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Elastic Net algorithm to make insightful products.""" name = "Elastic Net" - special_function = [ - ElasticNetSpecialFunction.ELASTIC_NET_FORMULA.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, - ] + special_function = [func.value for func in ElasticNetSpecialFunction] # ["Elastic Net Formula", "2D Scatter Diagram", "3D Scatter Diagram", "2D Line Diagram", "3D Surface Diagram"] def __init__( @@ -3284,7 +3250,6 @@ def __init__( ) self.naming = ElasticNetRegression.name - self.func = ElasticNetRegression.special_function self.customized = True self.customized_name = "Elastic Net" @@ -3363,7 +3328,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(ElasticNetRegression.X_test, 2) @@ -3374,7 +3339,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3386,7 +3351,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3396,7 +3361,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=ElasticNetRegression.X_test, @@ -3406,7 +3371,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3417,7 +3382,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=ElasticNetRegression.X_test, @@ -3427,7 +3392,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -3458,7 +3423,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(ElasticNetRegression.X_test, 2) @@ -3469,7 +3434,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3481,7 +3446,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3491,7 +3456,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=ElasticNetRegression.X_test, @@ -3501,7 +3466,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3512,7 +3477,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=ElasticNetRegression.X_test, @@ -3522,7 +3487,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -3532,13 +3497,7 @@ class SGDRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Stochastic Gradient Descent - SGD algorithm to make insightful products.""" name = "SGD Regression" - special_function = [ - SGDSpecialFunction.SGD_REGRESSION_FORMULA.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, - ] + special_function = [func.value for func in SGDSpecialFunction] # ["SGD Regression Formula", "2D Scatter Diagram", "3D Scatter Diagram", "2D Line Diagram", "3D Surface Diagram"] def __init__( @@ -3749,7 +3708,6 @@ def __init__( ) self.naming = SGDRegression.name - self.func = SGDRegression.special_function self.customized = True self.customized_name = "SGD Regression" @@ -3833,7 +3791,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(SGDRegression.X_test, 2) @@ -3844,7 +3802,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3856,7 +3814,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3866,7 +3824,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=SGDRegression.X_test, @@ -3876,7 +3834,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3887,7 +3845,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=SGDRegression.X_test, @@ -3897,7 +3855,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -3928,7 +3886,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(SGDRegression.X_test, 2) @@ -3939,7 +3897,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -3951,7 +3909,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -3961,7 +3919,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=SGDRegression.X_test, @@ -3971,7 +3929,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -3982,7 +3940,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=SGDRegression.X_test, @@ -3992,7 +3950,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -4171,13 +4129,7 @@ class RidgeRegression(LinearWorkflowMixin, RegressionWorkflowBase): """The automation workflow of using Lasso to make insightful products.""" name = "Ridge Regression" - special_function = [ - RidgeSpecialFunction.RIDGE_REGRESSION_FORMULA.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, - RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, - RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, - ] + special_function = [func.value for func in RidgeSpecialFunction] # ["Ridge Regression Formula", "2D Scatter Diagram", "3D Scatter Diagram", "2D Line Diagram", "3D Surface Diagram"] def __init__( @@ -4326,7 +4278,6 @@ def __init__( ) self.naming = RidgeRegression.name - self.func = RidgeRegression.special_function self.customized = True self.customized_name = "Ridge" @@ -4405,7 +4356,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(RidgeRegression.X_test, 2) @@ -4416,7 +4367,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -4428,7 +4379,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -4438,7 +4389,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=RidgeRegression.X_test, @@ -4448,7 +4399,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -4459,7 +4410,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=RidgeRegression.X_test, @@ -4469,7 +4420,7 @@ def special_components(self, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass @@ -4500,7 +4451,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # choose two of dimensions to draw three_dimen_axis_index, three_dimen_data = self.choose_dimension_data(RidgeRegression.X_test, 2) @@ -4511,7 +4462,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) elif columns_num == 2: # choose one of dimensions to draw @@ -4523,7 +4474,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) # no need to choose self._plot_3d_scatter_diagram( @@ -4533,7 +4484,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[2], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_3d_surface_diagram( feature_data=RidgeRegression.X_test, @@ -4543,7 +4494,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[4], + func_name=RegressionSpecialFunction.THREE_DIMENSIONAL_SURFACE_DIAGRAM.value, ) elif columns_num == 1: # no need to choose @@ -4554,7 +4505,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[1], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_SCATTER_DIAGRAM.value, ) self._plot_2d_line_diagram( feature_data=RidgeRegression.X_test, @@ -4564,7 +4515,7 @@ def special_components(self, is_automl: bool, **kwargs) -> None: algorithm_name=self.naming, local_path=GEOPI_OUTPUT_ARTIFACTS_IMAGE_MODEL_OUTPUT_PATH, mlflow_path=MLFLOW_ARTIFACT_IMAGE_MODEL_OUTPUT_PATH, - func_name=self.func[3], + func_name=RegressionSpecialFunction.TWO_DIMENSIONAL_LINE_DIAGRAM.value, ) else: pass