lrtree.logreg
implements segment-specific, possibly single-class, logistic regression
- class lrtree.logreg.PossiblyOneClassReg(**kwargs)[source]
One class logistic regression (e.g. when a leaf is pure)
Methods
decision_function
(X)Predict confidence scores for samples.
densify
()Convert coefficient matrix to dense array format.
fit
(X, y[, weights])Fit the one class regression: put the label of the single class and the number of features
get_params
([deep])Get parameters for this estimator.
predict
(X)Predict the single class if there's only one class, or predicts
predict_log_proba
(X)Predict logarithm of probability estimates.
Predict the single class with a 1 probability
score
(X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_params
(**params)Set the parameters of this estimator.
sparsify
()Convert coefficient matrix to sparse format.
- fit(X: np.ndarray | pd.DataFrame, y: np.ndarray, weights: np.ndarray = None)[source]
Fit the one class regression: put the label of the single class and the number of features
- predict(X: np.ndarray | pd.DataFrame) np.ndarray [source]
Predict the single class if there’s only one class, or predicts
- Parameters
X (numpy.ndarray or pandas.DataFrame) –
- Returns
column of class prediction
- Return type
- predict_proba(X: np.ndarray | pd.DataFrame)[source]
Predict the single class with a 1 probability
- Parameters
X (numpy.ndarray or pandas.DataFrame) –
- Returns
two columns, one of which full of ones
- Return type
- class lrtree.logreg.LogRegSegment(**kwargs)[source]
Logistic Regression for a given segment; fine-tuned PossiblyOneClassReg, itself from sklearn.LogisticRegression, allowing (1) to have only one class and (2) to embed data processing (merging, discretization).
Methods
decision_function
(X)Predict confidence scores for samples.
densify
()Convert coefficient matrix to dense array format.
fit
(**kwargs)Fits the LogRegSegment by preprocessing the data (if need be / asked for) and calling fit on sklearn
get_params
([deep])Get parameters for this estimator.
predict
(X)Predicts the LogRegSegment by preprocessing the data (if need be / asked for) and calling predict on sklearn
predict_log_proba
(X)Predict logarithm of probability estimates.
Predicts the LogRegSegment by preprocessing the data (if need be / asked for) and calling predict_proba on sklearn
score
(X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_params
(**params)Set the parameters of this estimator.
sparsify
()Convert coefficient matrix to sparse format.
- fit(**kwargs)[source]
Fits the LogRegSegment by preprocessing the data (if need be / asked for) and calling fit on sklearn
Classes
|
Logistic Regression for a given segment; fine-tuned PossiblyOneClassReg, itself from sklearn.LogisticRegression, allowing (1) to have only one class and (2) to embed data processing (merging, discretization). |
|
One class logistic regression (e.g. |