-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from ZJUEarthData/dev/liaojunchi
feat: add RidgeRegression algorithm
- Loading branch information
Showing
4 changed files
with
416 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
geochemistrypi/data_mining/model/func/algo_regression/_ridge_regression.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from typing import Dict | ||
|
||
from rich import print | ||
|
||
from ....constants import SECTION | ||
from ....data.data_readiness import bool_input, float_input, num_input | ||
|
||
|
||
def ridge_regression_manual_hyper_parameters() -> Dict: | ||
"""Manually set hyperparameters. | ||
Returns | ||
------- | ||
hyper_parameters : dict | ||
""" | ||
print("Alpha: This hyperparameter represents the coefficient of the norm, which controls the degree of contraction constraint.") | ||
print("Please indicate the coefficient of alpha. A good starting range could be between 0.001 and 2, such as 1.") | ||
alpha = float_input(0.01, SECTION[2], "@Alpha: ") | ||
print("Fit Intercept: This hyperparameter represents whether the model is evaluated with constant terms.") | ||
print("Please indicate whether there is a parameter entry. It is generally recommended to leave it set to True.") | ||
fit_intercept = bool_input(SECTION[2]) | ||
print("Max Iter: This hyperparameter represents the maximum number of iterations for the solver to converge.") | ||
print("Please indicate the maximum number of iterations. A good starting range could be between 1000 and 10000, such as 1000.") | ||
max_iter = num_input(SECTION[2], "@Max Iter: ") | ||
print("Tolerance: This hyperparameter represents the tolerance of the optimization method.") | ||
print("Please indicate the tolerance. A good starting range could be between 0.0001 and 0.001, such as 0.0001.") | ||
tol = float_input(0.0001, SECTION[2], "@Tolerance: ") | ||
# print("Selection: This hyperparameter represents the method of selecting the regularization coefficient.") | ||
# print("Please indicate the method of selecting the regularization coefficient. It is generally recommended to leave it set to 'cyclic'.") | ||
# selections = ["cyclic", "random"] | ||
# selection = str_input(selections, SECTION[2]) | ||
hyper_parameters = { | ||
"alpha": alpha, | ||
"fit_intercept": fit_intercept, | ||
"max_iter": max_iter, | ||
"tol": tol, | ||
} | ||
return hyper_parameters |
Oops, something went wrong.