| Title: | Node Harvest for Regression and Classification |
|---|---|
| Description: | Node harvest is a simple interpretable tree-like estimator for high-dimensional regression and classification. A few nodes are selected from an initially large ensemble of nodes, each associated with a positive weight. New observations can fall into one or several nodes and predictions are the weighted average response across all these groups. The package offers visualization of the estimator. Predictions can return the nodes a new observation fell into, along with the mean response of training observations in each node, offering a simple explanation of the prediction. Compatibility updates by Renova. |
| Authors: | Nicolai Meinshausen [aut, cre] |
| Maintainer: | Nicolai Meinshausen <[email protected]> |
| License: | GPL-3 |
| Version: | 0.7.3.9001 |
| Built: | 2026-11-15 20:39:02 UTC |
| Source: | https://github.com/renova-r/nodeHarvest |
Housing data for 506 census tracts of Boston from the 1970 census. The dataframe 'BostonHousing' contains the original data by Harrison and Rubinfeld (1979), the dataframe 'BostonHousing2' the corrected version with additional spatial information (see references below).
data(BostonHousing)data(BostonHousing)
The original data are 506 observations on 14 variables, 'medv' being the target variable:
crimper capita crime rate by town
znproportion of residential land zoned for lots over 25,000 sq.ft
indusproportion of non-retail business acres per town
chasCharles River dummy variable (= 1 if tract bounds river; 0 otherwise)
noxnitric oxides concentration (parts per 10 million)
rmaverage number of rooms per dwelling
ageproportion of owner-occupied units built prior to 1940
disweighted distances to five Boston employment centres
radindex of accessibility to radial highways
taxfull-value property-tax rate per USD 10,000
ptratiopupil-teacher ratio by town
b1000(B - 0.63)^2 where B is the proportion of blacks by town
lstatpercentage of lower status of the population
medvmedian value of owner-occupied homes in USD 1000's
The original data have been taken from the UCI Repository Of Machine Learning Databases at
http://www.ics.uci.edu/~mlearn/MLRepository.html,
See Statlib and references there for details on the corrections. Converted to R format by Friedrich Leisch.
Harrison, D. and Rubinfeld, D.L. (1978). Hedonic prices and the demand for clean air. _Journal of Environmental Economics and Management_, *5*, 81-102.
Gilley, O.W., and R. Kelley Pace (1996). On the Harrison and Rubinfeld Data. _Journal of Environmental Economics and Management_, *31*, 403-405. [Provided corrections and examined censoring.]
Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998). UCI Repository of machine learning databases [http://www.ics.uci.edu/~mlearn/MLRepository.html]. Irvine, CA: University of California, Department of Information and Computer Science.
Pace, R. Kelley, and O.W. Gilley (1997). Using the Spatial Configuration of the Data to Improve Estimation. _Journal of the Real Estate Finance and Economics_, *14*, 333-340. [Added georeferencing and spatial estimation.]
Computes the node harvest estimator
nodeHarvest(X, Y, nodesize = 10, nodes = 1000, maxinter = 2, mode = "mean", lambda = Inf, addto = NULL, onlyinter = NULL, silent = FALSE, biascorr = FALSE)nodeHarvest(X, Y, nodesize = 10, nodes = 1000, maxinter = 2, mode = "mean", lambda = Inf, addto = NULL, onlyinter = NULL, silent = FALSE, biascorr = FALSE)
X |
A n x p - dimensional data matrix, where n is sample size and p is the dimensionality of the predictor variable. Factorial variables are currently converted to numerical variables (will be changed in the future). Missing values are supported. |
Y |
A numerical vector of length n, containing the observations of the response variable. Can be continuous (regression) or binary 0/1 (classification). |
nodesize |
Minimal number of samples in each node. |
nodes |
Number of nodes in the initial large ensemble of nodes. |
maxinter |
Maximal interaction depth (1 = only main effects; 2 = two-factor interactions etc). |
mode |
If mode is equal to |
lambda |
Optional upper bound on the inverse of the average weighted fraction of samples within each node. |
addto |
A previous node harvest estimator to which additional nodes should be attached (useful for iterative growth of the estimator when hitting memory constraints). |
onlyinter |
Allow interactions only for this list of variables. |
silent |
If |
biascorr |
Use bias correction? Experimental. Can be useful for high signal-to-noise ratio data. |
The number of nodes should be chosen as large as possible under the available computational resources.
If these resources are limited, an estimator can be build by iteratively calling the function, adding the previous
estimator via the addto argument.
Feedback and feature requests are more than welcome (email below).
A list with entries
nodes |
A list of all selected nodes |
predicted |
Predicted values on training data |
connection |
Connectivity matrix between selected nodes (used for plotting) |
varnames |
Variable names |
Y |
The original observations |
Nicolai Meinshausen [email protected]
http://www.stats.ox.ac.uk/~meinshau
Node harvest: simple and interpretable regression and classification' (arxiv:0910.2145)
http://arxiv.org/abs/0910.2145
predict.nodeHarvest,
plot.nodeHarvest
## Load Boston Housing dataset data(BostonHousing) X <- BostonHousing[,1:13] Y <- BostonHousing[,14] ## Divide data into training and test data n <- nrow(X) training <- sample(1:n,round(n/2)) testing <- (1:n)[-training] ## Train Node Harvest and plot and print the estimator NH <- nodeHarvest( X[training,], Y[training], nodes=500 ) plot(NH) print(NH, nonodes=6) ## Predict on test data and explain prediction of the first sample in the test set predicttest <- predict(NH, X[testing,], explain=1) plot( predicttest, Y[testing] )## Load Boston Housing dataset data(BostonHousing) X <- BostonHousing[,1:13] Y <- BostonHousing[,14] ## Divide data into training and test data n <- nrow(X) training <- sample(1:n,round(n/2)) testing <- (1:n)[-training] ## Train Node Harvest and plot and print the estimator NH <- nodeHarvest( X[training,], Y[training], nodes=500 ) plot(NH) print(NH, nonodes=6) ## Predict on test data and explain prediction of the first sample in the test set predicttest <- predict(NH, X[testing,], explain=1) plot( predicttest, Y[testing] )
Node Harvest visualization. Each node with a non-zero weight is plotted (weights is proportional to area of node). The average response in each node is shown on the horizontal axis. The number of observations in each node is shown on the vertical axis.
## S3 method for class 'nodeHarvest' plot(x, XTEST = NULL, highlight = NULL, varnames = NULL, yoffset = 0.12, labels = "all", cexfaclab = 1, ...)## S3 method for class 'nodeHarvest' plot(x, XTEST = NULL, highlight = NULL, varnames = NULL, yoffset = 0.12, labels = "all", cexfaclab = 1, ...)
x |
An object of class |
XTEST |
New observations (for highlighting relevant nodes). |
highlight |
The nodes of this observation in |
varnames |
The variable names can be changed here. |
yoffset |
The vertical offset in the annotation of interaction nodes. |
labels |
If ‘none’, no annotation is made. If ‘all’, all nodes are annotated. Otherwise the nodes given in highlight are annotated only. |
cexfaclab |
Character expansion factor for node annotation. |
... |
Additional arguments passed to |
None.
Nicolai Meinshausen [email protected]
http://www.stats.ox.ac.uk/~meinshau
Given new observations, compute the prediction of a node harvest estimator.
## S3 method for class 'nodeHarvest' predict(object, newdata = NULL, explain = NULL, maxshow = 5, weight = sapply(object[["nodes"]], attr, "weight"), ...)## S3 method for class 'nodeHarvest' predict(object, newdata = NULL, explain = NULL, maxshow = 5, weight = sapply(object[["nodes"]], attr, "weight"), ...)
object |
An object of class |
newdata |
A data matrix with predictor variables. If missing, the predictions on the training data are returned. |
explain |
Row numbers for |
maxshow |
When explaining a prediction, show at most this many nodes (the most important ones). |
weight |
Optional changed weight vector for the nodes. |
... |
Additional arguments passed to |
If explains is equal to NULL, no output is printed.
If explain is a numeric vector (with values in 1 to the number of samples in newdata), for each observation in newdata with a sample number in vector explain, the following is done:
all nodes that the observation belongs to are printed on screen, along with their node mean (the mean of all training observations who fell into this node) and weight. The prediction for this new observation is the weighted average across these node means. The number of nodes show is given in descending order of their importance (weight) and the number of nodes shown is limited to maxshow.
A numeric vector with the predicted response.
Nicolai Meinshausen [email protected]
http://www.stats.ox.ac.uk/~meinshau