Skip to content

Commit f38f7e6

Browse files
8.0.0
1 parent 490f6b0 commit f38f7e6

17 files changed

+965
-1007
lines changed

API_REFERENCE_FOR_CLASSIFICATION.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# APLRClassifier
22

3-
## class aplr.APLRClassifier(m:int=9000, v:float=0.1, random_state:int=0, n_jobs:int=0, validation_ratio:float=0.2, bins:int=300, verbosity:int=0, max_interaction_level:int=1, max_interactions:int=100000, min_observations_in_split:int=20, ineligible_boosting_steps_added:int=10, max_eligible_terms:int=5, boosting_steps_before_pruning_is_done:int = 0, boosting_steps_before_interactions_are_allowed: int = 0, monotonic_constraints_ignore_interactions: bool = False)
3+
## class aplr.APLRClassifier(m:int=9000, v:float=0.1, random_state:int=0, n_jobs:int=0, cv_folds:int=5, bins:int=300, verbosity:int=0, max_interaction_level:int=1, max_interactions:int=100000, min_observations_in_split:int=20, ineligible_boosting_steps_added:int=10, max_eligible_terms:int=5, boosting_steps_before_interactions_are_allowed: int = 0, monotonic_constraints_ignore_interactions: bool = False)
44

55
### Constructor parameters
66

@@ -11,13 +11,13 @@ The maximum number of boosting steps. If validation error does not flatten out a
1111
The learning rate. Must be greater than zero and not more than one. The higher the faster the algorithm learns and the lower ***m*** is required. However, empirical evidence suggests that ***v <= 0.1*** gives better results. If the algorithm learns too fast (requires few boosting steps to converge) then try lowering the learning rate. Computational costs can be reduced by increasing the learning rate while simultaneously decreasing ***m***, potentially at the expense of predictiveness.
1212

1313
#### random_state (default = 0)
14-
Used to randomly split training observations into training and validation if ***validation_set_indexes*** is not specified when fitting.
14+
Used to randomly split training observations into cv_folds if ***cv_observations*** is not specified when fitting.
1515

1616
#### n_jobs (default = 0)
1717
Multi-threading parameter. If ***0*** then uses all available cores for multi-threading. Any other positive integer specifies the number of cores to use (***1*** means single-threading).
1818

19-
#### validation_ratio (default = 0.2)
20-
The ratio of training observations to use for validation instead of training. The number of boosting steps is automatically tuned to minimize validation error.
19+
#### cv_folds (default = 5)
20+
The number of randomly split folds to use in cross validation. The number of boosting steps is automatically tuned to minimize cross validation error.
2121

2222
#### bins (default = 300)
2323
Specifies the maximum number of bins to discretize the data into when searching for the best split. The default value works well according to empirical results. This hyperparameter is intended for reducing computational costs. Must be greater than 1.
@@ -40,17 +40,14 @@ Controls how many boosting steps a term that becomes ineligible has to remain in
4040
#### max_eligible_terms (default = 5)
4141
Limits 1) the number of terms already in the model that can be considered as interaction partners in a boosting step and 2) how many terms remain eligible in the next boosting step. The default value works well according to empirical results. This hyperparameter is intended for reducing computational costs.
4242

43-
#### boosting_steps_before_pruning_is_done (default = 0)
44-
Specifies how many boosting steps to wait before pruning the model. If 0 (default) then pruning is not done. If for example 500 then the model will be pruned in boosting steps 500, 1000, and so on. When pruning, terms are removed as long as this reduces the training error. This can be a computationally costly operation especially if the model gets many terms. Pruning may slightly improve predictiveness.
45-
4643
#### boosting_steps_before_interactions_are_allowed (default = 0)
4744
Specifies how many boosting steps to wait before searching for interactions. If for example 800, then the algorithm will be forced to only fit main effects in the first 800 boosting steps, after which it is allowed to search for interactions (given that other hyperparameters that control interactions also allow this). The motivation for fitting main effects first may be 1) to get a cleaner looking model that puts more emphasis on main effects and 2) to speed up the algorithm since looking for interactions is computationally more demanding.
4845

4946
#### monotonic_constraints_ignore_interactions (default = False)
5047
See ***monotonic_constraints*** in the ***fit*** method.
5148

5249

53-
## Method: fit(X:npt.ArrayLike, y:List[str], sample_weight:npt.ArrayLike = np.empty(0), X_names:List[str]=[], validation_set_indexes:List[int]=[], prioritized_predictors_indexes:List[int]=[], monotonic_constraints:List[int]=[], interaction_constraints:List[List[int]]=[])
50+
## Method: fit(X:npt.ArrayLike, y:List[str], sample_weight:npt.ArrayLike = np.empty(0), X_names:List[str]=[], cv_observations: npt.ArrayLike = np.empty([0, 0]), prioritized_predictors_indexes:List[int]=[], monotonic_constraints:List[int]=[], interaction_constraints:List[List[int]]=[])
5451

5552
***This method fits the model to data.***
5653

@@ -68,8 +65,8 @@ An optional numpy vector with sample weights. If not specified then the observat
6865
#### X_names
6966
An optional list of strings containing names for each predictor in ***X***. Naming predictors may increase model readability because model terms get names based on ***X_names***.
7067

71-
#### validation_set_indexes
72-
An optional list of integers specifying the indexes of observations to be used for validation instead of training. If this is specified then ***validation_ratio*** is not used. Specifying ***validation_set_indexes*** may be useful for example when modelling time series data (you can place more recent observations in the validation set).
68+
#### cv_observations
69+
An optional list of integers specifying how each training observation is used in cross validation. If this is specified then ***cv_folds*** is not used. Specifying ***cv_observations*** may be useful for example when modelling time series data (you can place more recent observations in the holdout folds). ***cv_observations*** must contain a column for each desired fold combination. For a given column, row values equalling 1 specify that these rows will be used for training, while row values equalling -1 specify that these rows will be used for validation. Row values equalling 0 will not be used.
7370

7471
#### prioritized_predictors_indexes
7572
An optional list of integers specifying the indexes of predictors (columns) in ***X*** that should be prioritized. Terms of the prioritized predictors will enter the model as long as they reduce the training error and do not contain too few effective observations. They will also be updated more often.
@@ -102,7 +99,7 @@ If ***True*** then for each underlying logit model the predictions are capped so
10299
Parameters are the same as in ***predict_class_probabilities()***.
103100

104101

105-
## Method: calculate_local_feature_importance(X:npt.ArrayLike)
102+
## Method: calculate_local_feature_contribution(X:npt.ArrayLike)
106103

107104
***Returns a numpy matrix containing local feature importance for new data by each predictor in X.***
108105

@@ -127,21 +124,16 @@ A numpy matrix with predictor values.
127124
A string specifying the label of the category.
128125

129126

130-
## Method: get_validation_indexes()
131-
132-
***Returns a list of integers containing the indexes of the training data observations used for validation and not training.***
133-
134-
135127
## Method: get_validation_error_steps()
136128

137-
***Returns a numpy vector containing the validation error by boosting step (average of log loss for each underlying logit model). Use this to determine if the maximum number of boosting steps (m) or learning rate (v) should be changed.***
129+
***Returns a numpy matrix containing the validation error by boosting step for each cv fold (average of log loss for each underlying logit model). Use this to determine if the maximum number of boosting steps (m) or learning rate (v) should be changed.***
138130

139131

140-
## Method: get_validation_error()
132+
## Method: get_cv_error()
141133

142-
***Returns the validation error measured by the average of log loss for each underlying logit model.***
134+
***Returns the cv error measured by the average of log loss for each underlying logit model.***
143135

144136

145137
## Method: get_feature_importance()
146138

147-
***Returns a numpy vector containing the feature importance of each predictor, estimated on the validation set as an average of feature importances for the underlying logit models.***
139+
***Returns a numpy vector containing the feature importance of each predictor, estimated as an average of feature importances for the underlying logit models.***

0 commit comments

Comments
 (0)