Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: perfect the enum class usage in regression algorithm. #422

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions geochemistrypi/data_mining/model/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,21 @@ class LinearWorkflowMixin:

@staticmethod
def _show_formula(
coef: np.ndarray, intercept: np.ndarray, features_name: np.ndarray, algorithm_name: str, regression_classification: str, y_train: pd.DataFrame, local_path: str, mlflow_path: str
coef: np.ndarray,
intercept: np.ndarray,
features_name: np.ndarray,
algorithm_name: str,
func_name: str,
regression_classification: str,
y_train: pd.DataFrame,
local_path: str,
mlflow_path: str,
) -> None:
"""Show the formula."""
print(f"-----* {algorithm_name} Formula *-----")
print(f"-----* {func_name} *-----")
formula = show_formula(coef, intercept, features_name, regression_classification, y_train)
formula_str = json.dumps(formula, indent=4)
save_text(formula_str, f"{algorithm_name} Formula", local_path, mlflow_path)
save_text(formula_str, f"{func_name}", local_path, mlflow_path)

@staticmethod
def _plot_2d_scatter_diagram(feature_data: pd.DataFrame, target_data: pd.DataFrame, data_name: str, algorithm_name: str, func_name: str, local_path: str, mlflow_path: str) -> None:
Expand Down
28 changes: 19 additions & 9 deletions geochemistrypi/data_mining/model/func/algo_regression/_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ class RegressionCommonFunction(Enum):
PERMUTATION_IMPORTANC_DIAGRAM = "Permutation Importance Diagram"


class RegressionSpecialFunction(Enum):
FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram"
SINGLE_TREE_DIAGRAM = "Single Tree Diagram"
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 XGBoostSpecialFunction(Enum):
FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram"

Expand Down Expand Up @@ -71,3 +62,22 @@ class RidgeSpecialFunction(Enum):
THREE_DIMENSIONAL_SCATTER_DIAGRAM = "3D Scatter Diagram"
TWO_DIMENSIONAL_LINE_DIAGRAM = "2D Line Diagram"
THREE_DIMENSIONAL_SURFACE_DIAGRAM = "3D Surface Diagram"


class ExtraTreesSpecialFunction(Enum):
FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram"
SINGLE_TREE_DIAGRAM = "Single Tree Diagram"


class RandomForestSpecialFunction(Enum):
FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram"
SINGLE_TREE_DIAGRAM = "Single Tree Diagram"


class GradientBoostingSpecialFunction(Enum):
FEATURE_IMPORTANCE_DIAGRAM = "Feature Importance Diagram"
SINGLE_TREE_DIAGRAM = "Single Tree Diagram"


class PolynomialSpecialFunction(Enum):
POLYNOMIAL_REGRESSION_FORMULA = "Polynomial Regression Formula"
Loading
Loading