Comments (5)
It looks like this was actually caused by an outdated version of glmnet and not by forestry itself.
from rforestry.
Actually it seems it is not related to glment version, rather the error is intermittent because it depends on the seed used to construct the forest. I think it probably arises when a tree contains leaves that are grown to purity, which causes glmnet to fail when called in the plotting method. This could be fixed by patching the plotting function to not call glmnet when the variance of the outcome in a leaf is zero.
from rforestry.
For the case where you have this error:
Error in if (any(lambda < 0)) stop("lambdas should be non-negative") :
missing value where TRUE/FALSE needed
The cause is:
Lines 238 to 252 in cecf729
As you said, y_leaf
is a single element vector. sd(y_leaf) = NA
, causing lambda = NA
.
Browse[1]> n
debug at C:/Users/Linan Qiu/Desktop/temp.R#227: plm <- glmnet::glmnet(x = remat, y = y_leaf, lambda = forestry_tree@overfitPenalty *
sd(y_leaf)/nrow(remat), alpha = 0)
Browse[2]> forestry_tree@overfitPenalty * sd(y_leaf)/nrow(remat)
[1] NA
Browse[2]> sd(y_leaf)
[1] NA
Browse[2]> y_leaf
[1] -19.65548
from rforestry.
For the case where you have the other error:
Error in elnet(xd, is.sparse, ix, jx, y, weights, offset, type.gaussian, :
y is constant; gaussian glmnet fails at standardization step
The cause is still that couple of lines, but that's when y_leaf
has length > 1 but consist of all the same elements:
# added these print statements to the if block above:
# message(glue('overfitPenalty: {forestry_tree@overfitPenalty}'))
# message(glue('y_leaf: {paste0(y_leaf, collapse = ", ")}, sd(y_leaf): {sd(y_leaf)}'))
# message(glue('nrow(remat): {nrow(remat)}'))
overfitPenalty: 1
y_leaf: -9.56037240704544, -9.56037240704544, -9.56037240704544, sd(y_leaf): 0
nrow(remat): 3
Y is constant, which is what glmnet is complaining about. Could be because glmnet does some standardization (https://stackoverflow.com/questions/54755857/glmnet-error-nulldev-0-stopy-is-constant-gaussian-glmnet-fails-at-standa) and fails at sd(y_leaf) = 0
These two cases seem to exhaust the errors I've seen by clicking source a dozen times 😛
Seems like the right thing to do for a linear aggregator at leaf in these cases is just to return Y?
from rforestry.
This LGTM, Linan! :)
from rforestry.
Related Issues (20)
- Getting weights variables HOT 1
- Clean up README for Python Package
- Training data column with only NAs
- `has_nas` method defined, but not used
- Export model to JSON string
- Add coverage report for unittests
- `seed` same in different objects HOT 3
- :no_good: Branch `bptest/test` has an incorrect name
- Implement Custom Sampling in Python
- Allow all NA or same value columns with scaling HOT 1
- Change linFeats to be 1-indexed instead of 0-indexed
- Python package documentation is outdated
- Fix authentication issue preventing python build pipeline to access docker image
- Build R package and upload it as pipeline artifact
- R release on CRAN - resolve std::cout?
- Add pipeline step for cross language tests / Python pipeline
- Floating point imprecision HOT 3
- Python Predictions not being rescaled when forest is trained with scale = True
- Compatibility with sklearn estimators HOT 6
- segmentation faults when splitratio = 0.5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rforestry.