linearrf 1.2.4__tar.gz → 1.2.6__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.4
3
+ Version: 1.2.6
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.4"
7
+ version = "1.2.6"
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.4
3
+ Version: 1.2.6
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
@@ -113,7 +113,8 @@ class _LinearRandomForest:
113
113
  self.min_samples_leaf = self.leaf_samples_to_features_ratio * x.shape[1]
114
114
 
115
115
  # add intercept here and not inside linear model for performance reasons
116
- x = np.insert(x, 0, 1, axis=1)
116
+ if self.linear_model is None:
117
+ x = np.insert(x, 0, 1, axis=1)
117
118
 
118
119
  # mtry is the same at every node — cache once instead of recomputing per split
119
120
  self._mtry = int(round(np.sqrt(x.shape[1] - 1)))
@@ -160,7 +161,10 @@ class _LinearRandomForest:
160
161
  imp = self._calc_imp(node.left_node, imp)
161
162
  imp = self._calc_imp(node.right_node, imp)
162
163
  else:
163
- np.add(imp, np.abs(node.model.coef_[1:]), out=imp)
164
+ if self.linear_model is None:
165
+ np.add(imp, np.abs(node.model.coef_[1:]), out=imp)
166
+ else:
167
+ np.add(imp, np.abs(node.model.coef_), out=imp)
164
168
 
165
169
  return imp
166
170
 
@@ -379,8 +383,13 @@ class _LinearRandomForest:
379
383
  txt += self._node_to_text(node=node.right_node, column_names=column_names, ndigits=ndigits)
380
384
 
381
385
  else:
382
- intercept = node.model.coef_[0]
383
- weights = node.model.coef_[1:]
386
+ if self.linear_model is None:
387
+ intercept = node.model.coef_[0]
388
+ weights = node.model.coef_[1:]
389
+ else:
390
+ intercept = node.model.intercept_
391
+ weights = node.model.coef_
392
+
384
393
  weights = ['+' + str(round(w, ndigits)) if w > 0 else str(round(w, ndigits)) for w in weights]
385
394
  if column_names is None:
386
395
  cols = ['col_{}'.format(i) for i in range(len(weights))]
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