linearrf 1.2.3__tar.gz → 1.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linearrf
3
- Version: 1.2.3
3
+ Version: 1.2.5
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.3"
7
+ version = "1.2.5"
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
3
+ Version: 1.2.5
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
@@ -160,8 +160,10 @@ class _LinearRandomForest:
160
160
  imp = self._calc_imp(node.left_node, imp)
161
161
  imp = self._calc_imp(node.right_node, imp)
162
162
  else:
163
- np.add(imp, np.abs(node.model.coef_[1:]), out=imp)
164
-
163
+ if self.linear_model is None:
164
+ np.add(imp, np.abs(node.model.coef_[1:]), out=imp)
165
+ else:
166
+ np.add(imp, np.abs(node.model.coef_), out=imp)
165
167
  return imp
166
168
 
167
169
  @staticmethod
@@ -379,8 +381,13 @@ class _LinearRandomForest:
379
381
  txt += self._node_to_text(node=node.right_node, column_names=column_names, ndigits=ndigits)
380
382
 
381
383
  else:
382
- intercept = node.model.coef_[0]
383
- weights = node.model.coef_[1:]
384
+ if self.linear_model is None:
385
+ intercept = node.model.coef_[0]
386
+ weights = node.model.coef_[1:]
387
+ else:
388
+ intercept = node.model.intercept_
389
+ weights = node.model.coef_
390
+
384
391
  weights = ['+' + str(round(w, ndigits)) if w > 0 else str(round(w, ndigits)) for w in weights]
385
392
  if column_names is None:
386
393
  cols = ['col_{}'.format(i) for i in range(len(weights))]
@@ -163,7 +163,8 @@ class LRFClassifier(_LinearRandomForest):
163
163
  x = x.to_numpy()
164
164
 
165
165
  # add intercept here and not inside linear model for performance reasons
166
- x = np.insert(x, 0, 1, axis=1)
166
+ if self.linear_model is None:
167
+ x = np.insert(x, 0, 1, axis=1)
167
168
 
168
169
  # add columns with row index for sorting after multiprocessing
169
170
  x = np.insert(x, 0, np.arange(x.shape[0]), axis=1)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes