linearrf 1.2.2__tar.gz → 1.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {linearrf-1.2.2/src/linearrf.egg-info → linearrf-1.2.3}/PKG-INFO +1 -1
- {linearrf-1.2.2 → linearrf-1.2.3}/pyproject.toml +1 -1
- {linearrf-1.2.2 → linearrf-1.2.3/src/linearrf.egg-info}/PKG-INFO +1 -1
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_criterion.py +31 -13
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/lrf.py +7 -3
- {linearrf-1.2.2 → linearrf-1.2.3}/LICENSE.md +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/MANIFEST.in +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/README.md +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/setup.cfg +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/linearrf.egg-info/SOURCES.txt +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/linearrf.egg-info/dependency_links.txt +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/linearrf.egg-info/requires.txt +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/linearrf.egg-info/top_level.txt +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/__init__.py +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_base_lrf.py +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_irls.py +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_linear_models.py +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_node.py +0 -0
- {linearrf-1.2.2 → linearrf-1.2.3}/src/lrf/_preprocessor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linearrf
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: A python libary to build Random Forests with Linear Models at the leaves.
|
|
5
5
|
Author-email: Marian Biermann <marianbiermann@gmx.de>
|
|
6
6
|
Project-URL: homepage, https://github.com/marianbiermann/lrf
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "linearrf"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.3"
|
|
8
8
|
description = "A python libary to build Random Forests with Linear Models at the leaves."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Marian Biermann", email = "marianbiermann@gmx.de" }]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linearrf
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: A python libary to build Random Forests with Linear Models at the leaves.
|
|
5
5
|
Author-email: Marian Biermann <marianbiermann@gmx.de>
|
|
6
6
|
Project-URL: homepage, https://github.com/marianbiermann/lrf
|
|
@@ -82,43 +82,61 @@ def neg_mcc(y_true: np.ndarray, y_pred: np.ndarray):
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def neg_roc_auc(y_true: np.ndarray, y_pred: np.ndarray):
|
|
85
|
-
# Rank-based ROC AUC in O(n log n). Sort by descending score
|
|
86
|
-
#
|
|
87
|
-
#
|
|
85
|
+
# Rank-based ROC AUC in O(n log n). Sort by descending score, then evaluate
|
|
86
|
+
# TPR/FPR only at distinct-score endpoints — collapsing each tied group
|
|
87
|
+
# into a single point. Without this, tied predictions produce results that
|
|
88
|
+
# depend on the (arbitrary) within-tie sort order.
|
|
88
89
|
y_true = np.asarray(y_true)
|
|
89
90
|
y_pred = np.asarray(y_pred)
|
|
90
91
|
|
|
91
92
|
order = np.argsort(-y_pred, kind='stable')
|
|
92
93
|
y_sorted = y_true[order].astype(np.float64)
|
|
94
|
+
pred_sorted = y_pred[order]
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
tps_full = np.cumsum(y_sorted)
|
|
97
|
+
fps_full = np.arange(1, y_sorted.size + 1, dtype=np.float64) - tps_full
|
|
98
|
+
|
|
99
|
+
# End of each tied group: positions where the next prediction differs,
|
|
100
|
+
# plus the very last position.
|
|
101
|
+
endpoints = np.concatenate((np.where(np.diff(pred_sorted))[0],
|
|
102
|
+
[y_sorted.size - 1]))
|
|
103
|
+
tps = tps_full[endpoints]
|
|
104
|
+
fps = fps_full[endpoints]
|
|
105
|
+
|
|
106
|
+
positives, negatives = tps[-1], fps[-1]
|
|
96
107
|
if positives == 0 or negatives == 0:
|
|
97
108
|
return 0.0
|
|
98
109
|
|
|
99
|
-
tpr = np.concatenate(([0.0],
|
|
100
|
-
fpr = np.concatenate(([0.0],
|
|
110
|
+
tpr = np.concatenate(([0.0], tps / positives))
|
|
111
|
+
fpr = np.concatenate(([0.0], fps / negatives))
|
|
101
112
|
|
|
102
113
|
# negated so the caller minimizes AUC (matches the previous convention)
|
|
103
114
|
return -_trapz(tpr, fpr)
|
|
104
115
|
|
|
105
116
|
|
|
106
117
|
def neg_pr_auc(y_true: np.ndarray, y_pred: np.ndarray):
|
|
107
|
-
# Rank-based PR AUC in O(n log n)
|
|
118
|
+
# Rank-based PR AUC in O(n log n). Same tie-collapsing as neg_roc_auc.
|
|
108
119
|
y_true = np.asarray(y_true)
|
|
109
120
|
y_pred = np.asarray(y_pred)
|
|
110
121
|
|
|
111
122
|
order = np.argsort(-y_pred, kind='stable')
|
|
112
123
|
y_sorted = y_true[order].astype(np.float64)
|
|
124
|
+
pred_sorted = y_pred[order]
|
|
125
|
+
|
|
126
|
+
tps_full = np.cumsum(y_sorted)
|
|
127
|
+
fps_full = np.arange(1, y_sorted.size + 1, dtype=np.float64) - tps_full
|
|
128
|
+
|
|
129
|
+
endpoints = np.concatenate((np.where(np.diff(pred_sorted))[0],
|
|
130
|
+
[y_sorted.size - 1]))
|
|
131
|
+
tps = tps_full[endpoints]
|
|
132
|
+
fps = fps_full[endpoints]
|
|
113
133
|
|
|
114
|
-
positives =
|
|
134
|
+
positives = tps[-1]
|
|
115
135
|
if positives == 0:
|
|
116
136
|
return 0.0
|
|
117
137
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
precision = pos_cum / ranks
|
|
121
|
-
recall = pos_cum / positives
|
|
138
|
+
precision = tps / (tps + fps)
|
|
139
|
+
recall = tps / positives
|
|
122
140
|
|
|
123
141
|
return -_trapz(precision, recall)
|
|
124
142
|
|
|
@@ -21,6 +21,9 @@ class LRFRegressor(_LinearRandomForest):
|
|
|
21
21
|
self.preprocessing = preprocessing
|
|
22
22
|
self._estimator_type = 'regressor'
|
|
23
23
|
|
|
24
|
+
if criterion not in ('mse', 'rmse', 'mae', 'mape', 'wape', 'neg_explained_variance', 'neg_r2'):
|
|
25
|
+
print(' Metric "{}" is not implemented, MSE is used instead.'.format(criterion))
|
|
26
|
+
|
|
24
27
|
if linear_model is None:
|
|
25
28
|
linear_model = Regressor(alpha=self.alpha, preprocessing=self.preprocessing, intercept_in_input=True)
|
|
26
29
|
else:
|
|
@@ -83,7 +86,6 @@ class LRFRegressor(_LinearRandomForest):
|
|
|
83
86
|
elif self.criterion == 'neg_r2':
|
|
84
87
|
val = neg_r2(y_true=y_true, y_pred=y_pred)
|
|
85
88
|
else:
|
|
86
|
-
print(' Metric "{}" is not implemented, MSE is used instead.'.format(self.criterion))
|
|
87
89
|
val = mse(y_true=y_true, y_pred=y_pred)
|
|
88
90
|
|
|
89
91
|
return val
|
|
@@ -114,6 +116,10 @@ class LRFClassifier(_LinearRandomForest):
|
|
|
114
116
|
self.preprocessing = preprocessing
|
|
115
117
|
self._estimator_type = 'classifier'
|
|
116
118
|
|
|
119
|
+
if criterion not in ('hamming', 'cross_entropy', 'neg_mcc', 'neg_roc_auc', 'neg_pr_auc'):
|
|
120
|
+
print(' Metric "{}" is not implemented, negative Matthews Correlation Coefficient is used instead.'
|
|
121
|
+
.format(criterion))
|
|
122
|
+
|
|
117
123
|
if linear_model is None:
|
|
118
124
|
linear_model = Classifier(C=self.C, preprocessing=self.preprocessing, intercept_in_input=True)
|
|
119
125
|
else:
|
|
@@ -213,8 +219,6 @@ class LRFClassifier(_LinearRandomForest):
|
|
|
213
219
|
elif self.criterion == 'neg_roc_auc':
|
|
214
220
|
val = neg_roc_auc(y_true=y_true, y_pred=y_pred)
|
|
215
221
|
else:
|
|
216
|
-
print(' Metric "{}" is not implemented, the negative Matthews Correlation Coefficient is used '
|
|
217
|
-
'instead.'.format(self.criterion))
|
|
218
222
|
val = neg_mcc(y_true=y_true, y_pred=y_pred)
|
|
219
223
|
|
|
220
224
|
return val
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|