Skip to content

Commit 506eeea

Browse files
10.8.0
1 parent db1f7ef commit 506eeea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+174
-21963
lines changed

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- name: Build wheels
13-
uses: pypa/cibuildwheel@v2.17.0
13+
uses: pypa/cibuildwheel@v2.22.0
1414
env:
1515
CIBW_SKIP: "*musllinux*"
1616
CIBW_ENVIRONMENT: MACOSX_DEPLOYMENT_TARGET=10.14

API_REFERENCE_FOR_CLASSIFICATION.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Specifies the maximum allowed depth of interaction terms. ***0*** means that int
3232
The maximum number of interactions allowed in each underlying model. A lower value may be used to reduce computational time or to increase interpretability.
3333

3434
#### min_observations_in_split (default = 4)
35-
The minimum effective number of observations that a term in the model must rely on. This hyperparameter should be tuned. Larger values are more appropriate for larger datasets. Larger values result in more robust models (lower variance), potentially at the expense of increased bias.
35+
The minimum effective number of observations that a term in the model must rely on as well as the minimum number of boundary value observations where there cannot be splits. This hyperparameter should be tuned. Larger values are more appropriate for larger datasets. Larger values result in more robust models (lower variance), potentially at the expense of increased bias.
3636

3737
#### ineligible_boosting_steps_added (default = 15)
3838
Controls how many boosting steps a term that becomes ineligible has to remain ineligible. The default value works well according to empirical results. This hyperparameter is intended for reducing computational costs.
@@ -62,7 +62,7 @@ Specifies a penalty in the range [0.0, 1.0] on interaction terms. A higher value
6262
Restricts the maximum number of terms in any of the underlying models trained to ***max_terms***. The default value of 0 means no limit. After the limit is reached, the remaining boosting steps are used to further update the coefficients of already included terms. An optional tuning objective could be to find the lowest positive value of ***max_terms*** that does not increase the prediction error significantly. Low positive values can speed up the training process significantly. Setting a limit with ***max_terms*** may require a higher learning rate for best results.
6363

6464

65-
## Method: fit(X:FloatMatrix, y:List[str], sample_weight:FloatVector = np.empty(0), X_names:List[str] = [], cv_observations:IntMatrix = np.empty([0, 0]), prioritized_predictors_indexes:List[int] = [], monotonic_constraints:List[int] = [], interaction_constraints:List[List[int]] = [], predictor_learning_rates:List[float] = [], predictor_penalties_for_non_linearity:List[float] = [], predictor_penalties_for_interactions:List[float] = [])
65+
## Method: fit(X:FloatMatrix, y:List[str], sample_weight:FloatVector = np.empty(0), X_names:List[str] = [], cv_observations:IntMatrix = np.empty([0, 0]), prioritized_predictors_indexes:List[int] = [], monotonic_constraints:List[int] = [], interaction_constraints:List[List[int]] = [], predictor_learning_rates:List[float] = [], predictor_penalties_for_non_linearity:List[float] = [], predictor_penalties_for_interactions:List[float] = [], predictor_min_observations_in_split: List[int] = [])
6666

6767
***This method fits the model to data.***
6868

@@ -101,6 +101,9 @@ An optional list of floats specifying penalties for non-linearity for each predi
101101
#### predictor_penalties_for_interactions
102102
An optional list of floats specifying interaction penalties for each predictor. If provided then this supercedes ***penalty_for_interactions***. For example, if there are two predictors in ***X***, then predictor_penalties_for_interactions = [0.1,0.2] means that all terms using the first predictor in ***X*** as a main effect will have an interaction penalty of 0.1 and that all terms using the second predictor in ***X*** as a main effect will have an interaction penalty of 0.2.
103103

104+
#### predictor_min_observations_in_split
105+
An optional list of integers specifying the minimum effective number of observations in a split for each predictor. If provided then this supercedes ***min_observations_in_split***.
106+
104107

105108
## Method: predict_class_probabilities(X:FloatMatrix, cap_predictions_to_minmax_in_training:bool = False)
106109

API_REFERENCE_FOR_REGRESSION.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Specifies the maximum allowed depth of interaction terms. ***0*** means that int
3535
The maximum number of interactions allowed in each underlying model. A lower value may be used to reduce computational time or to increase interpretability.
3636

3737
#### min_observations_in_split (default = 4)
38-
The minimum effective number of observations that a term in the model must rely on. This hyperparameter should be tuned. Larger values are more appropriate for larger datasets. Larger values result in more robust models (lower variance), potentially at the expense of increased bias.
38+
The minimum effective number of observations that a term in the model must rely on as well as the minimum number of boundary value observations where there cannot be splits. This hyperparameter should be tuned. Larger values are more appropriate for larger datasets. Larger values result in more robust models (lower variance), potentially at the expense of increased bias.
3939

4040
#### ineligible_boosting_steps_added (default = 15)
4141
Controls how many boosting steps a term that becomes ineligible has to remain ineligible. The default value works well according to empirical results. This hyperparameter is intended for reducing computational costs.
@@ -130,7 +130,7 @@ Specifies a penalty in the range [0.0, 1.0] on interaction terms. A higher value
130130
Restricts the maximum number of terms in any of the underlying models trained to ***max_terms***. The default value of 0 means no limit. After the limit is reached, the remaining boosting steps are used to further update the coefficients of already included terms. An optional tuning objective could be to find the lowest positive value of ***max_terms*** that does not increase the prediction error significantly. Low positive values can speed up the training process significantly. Setting a limit with ***max_terms*** may require a higher learning rate for best results.
131131

132132

133-
## Method: fit(X:FloatMatrix, y:FloatVector, sample_weight:FloatVector = np.empty(0), X_names:List[str] = [], cv_observations:IntMatrix = np.empty([0, 0]), prioritized_predictors_indexes:List[int] = [], monotonic_constraints:List[int] = [], group:FloatVector = np.empty(0), interaction_constraints:List[List[int]] = [], other_data:FloatMatrix = np.empty([0, 0]), predictor_learning_rates:List[float] = [], predictor_penalties_for_non_linearity:List[float] = [], predictor_penalties_for_interactions:List[float] = [])
133+
## Method: fit(X:FloatMatrix, y:FloatVector, sample_weight:FloatVector = np.empty(0), X_names:List[str] = [], cv_observations:IntMatrix = np.empty([0, 0]), prioritized_predictors_indexes:List[int] = [], monotonic_constraints:List[int] = [], group:FloatVector = np.empty(0), interaction_constraints:List[List[int]] = [], other_data:FloatMatrix = np.empty([0, 0]), predictor_learning_rates:List[float] = [], predictor_penalties_for_non_linearity:List[float] = [], predictor_penalties_for_interactions:List[float] = [], predictor_min_observations_in_split: List[int] = [])
134134

135135
***This method fits the model to data.***
136136

@@ -175,6 +175,9 @@ An optional list of floats specifying penalties for non-linearity for each predi
175175
#### predictor_penalties_for_interactions
176176
An optional list of floats specifying interaction penalties for each predictor. If provided then this supercedes ***penalty_for_interactions***. For example, if there are two predictors in ***X***, then predictor_penalties_for_interactions = [0.1,0.2] means that all terms using the first predictor in ***X*** as a main effect will have an interaction penalty of 0.1 and that all terms using the second predictor in ***X*** as a main effect will have an interaction penalty of 0.2.
177177

178+
#### predictor_min_observations_in_split
179+
An optional list of integers specifying the minimum effective number of observations in a split for each predictor. If provided then this supercedes ***min_observations_in_split***.
180+
178181

179182
## Method: predict(X:FloatMatrix, cap_predictions_to_minmax_in_training:bool = True)
180183

aplr/aplr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def fit(
196196
predictor_learning_rates: List[float] = [],
197197
predictor_penalties_for_non_linearity: List[float] = [],
198198
predictor_penalties_for_interactions: List[float] = [],
199+
predictor_min_observations_in_split: List[int] = [],
199200
):
200201
self.__set_params_cpp()
201202
self.APLRRegressor.fit(
@@ -212,6 +213,7 @@ def fit(
212213
predictor_learning_rates,
213214
predictor_penalties_for_non_linearity,
214215
predictor_penalties_for_interactions,
216+
predictor_min_observations_in_split,
215217
)
216218

217219
def predict(
@@ -447,6 +449,7 @@ def fit(
447449
predictor_learning_rates: List[float] = [],
448450
predictor_penalties_for_non_linearity: List[float] = [],
449451
predictor_penalties_for_interactions: List[float] = [],
452+
predictor_min_observations_in_split: List[int] = [],
450453
):
451454
self.__set_params_cpp()
452455
self.APLRClassifier.fit(
@@ -461,6 +464,7 @@ def fit(
461464
predictor_learning_rates,
462465
predictor_penalties_for_non_linearity,
463466
predictor_penalties_for_interactions,
467+
predictor_min_observations_in_split,
464468
)
465469
# For sklearn
466470
self.classes_ = np.arange(len(self.APLRClassifier.get_categories()))

cpp/APLRClassifier.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class APLRClassifier
6666
const std::vector<size_t> &prioritized_predictors_indexes = {}, const std::vector<int> &monotonic_constraints = {},
6767
const std::vector<std::vector<size_t>> &interaction_constraints = {}, const std::vector<double> &predictor_learning_rates = {},
6868
const std::vector<double> &predictor_penalties_for_non_linearity = {},
69-
const std::vector<double> &predictor_penalties_for_interactions = {});
69+
const std::vector<double> &predictor_penalties_for_interactions = {},
70+
const std::vector<size_t> &predictor_min_observations_in_split = {});
7071
MatrixXd predict_class_probabilities(const MatrixXd &X, bool cap_predictions_to_minmax_in_training = false);
7172
std::vector<std::string> predict(const MatrixXd &X, bool cap_predictions_to_minmax_in_training = false);
7273
MatrixXd calculate_local_feature_contribution(const MatrixXd &X);
@@ -123,7 +124,8 @@ void APLRClassifier::fit(const MatrixXd &X, const std::vector<std::string> &y, c
123124
const MatrixXi &cv_observations, const std::vector<size_t> &prioritized_predictors_indexes,
124125
const std::vector<int> &monotonic_constraints, const std::vector<std::vector<size_t>> &interaction_constraints,
125126
const std::vector<double> &predictor_learning_rates, const std::vector<double> &predictor_penalties_for_non_linearity,
126-
const std::vector<double> &predictor_penalties_for_interactions)
127+
const std::vector<double> &predictor_penalties_for_interactions,
128+
const std::vector<size_t> &predictor_min_observations_in_split)
127129
{
128130
initialize();
129131
find_categories(y);
@@ -145,7 +147,8 @@ void APLRClassifier::fit(const MatrixXd &X, const std::vector<std::string> &y, c
145147
logit_models[categories[0]].max_terms = max_terms;
146148
logit_models[categories[0]].fit(X, response_values[categories[0]], sample_weight, X_names, cv_observations, prioritized_predictors_indexes,
147149
monotonic_constraints, VectorXi(0), interaction_constraints, MatrixXd(0, 0), predictor_learning_rates,
148-
predictor_penalties_for_non_linearity, predictor_penalties_for_interactions);
150+
predictor_penalties_for_non_linearity, predictor_penalties_for_interactions,
151+
predictor_min_observations_in_split);
149152

150153
logit_models[categories[1]] = logit_models[categories[0]];
151154
invert_second_model_in_two_class_case(logit_models[categories[1]]);
@@ -166,7 +169,8 @@ void APLRClassifier::fit(const MatrixXd &X, const std::vector<std::string> &y, c
166169
logit_models[category].max_terms = max_terms;
167170
logit_models[category].fit(X, response_values[category], sample_weight, X_names, cv_observations, prioritized_predictors_indexes,
168171
monotonic_constraints, VectorXi(0), interaction_constraints, MatrixXd(0, 0), predictor_learning_rates,
169-
predictor_penalties_for_non_linearity, predictor_penalties_for_interactions);
172+
predictor_penalties_for_non_linearity, predictor_penalties_for_interactions,
173+
predictor_min_observations_in_split);
170174
}
171175
}
172176

0 commit comments

Comments
 (0)