Title: | Functions for Working with Trees in Elementary Data Analysis |
---|---|
Description: | For use by elementary students in statistics or data analysis. |
Authors: | Homer White <[email protected]> |
Maintainer: | Homer White <[email protected]> |
License: | GPL (>=3) |
Version: | 0.2.1 |
Built: | 2024-11-24 22:21:51 UTC |
Source: | https://github.com/homerhanumat/tigerTree |
Easily find the distribtution of the response variable at each of the nodes of a classification tree.
distAtNodes(mod, df, resp_varname)
distAtNodes(mod, df, resp_varname)
mod |
A tree model constructed by the |
df |
A data frame (usually the training set, quiz set or test set). |
resp_varname |
The name of the response variable, as a character string. |
A table object.
For more details on use, consult http://statistics.rainandrhino.org/tigerTree/distAtNodes.html
## Not run: dfs <- divideTrainTest(seed = 3030, prop.train = 0.67, data = iris) irisTrain <- dfs$train irisTest <- dfs$test tr.mod <- tree(Species ~ ., data = irisTrain) distAtNodes(tr.mod, df = irisTest, resp_varname = "Species") ## End(Not run)
## Not run: dfs <- divideTrainTest(seed = 3030, prop.train = 0.67, data = iris) irisTrain <- dfs$train irisTest <- dfs$test tr.mod <- tree(Species ~ ., data = irisTrain) distAtNodes(tr.mod, df = irisTest, resp_varname = "Species") ## End(Not run)
Divide a data frame into training and test set, or training, quiz and test set.
divideTrainTest(seed = NULL, prop.train = 0.6, prop.quiz = NULL, data)
divideTrainTest(seed = NULL, prop.train = 0.6, prop.quiz = NULL, data)
seed |
A seed for randomization (recommended). |
prop.train |
Proportion of the data to include in the training set. |
prop.quiz |
Proportion of the data to include in a quiz set (if any).
Set to |
data |
The data frame to be split. |
A list with elements named test
and train
, or with
elements named train
and quiz
and test
.
For more details on use, consult http://statistics.rainandrhino.org/tigerTree/divideTrainTest.html
For use by elementary students in statistics and data analysis.
Yes-No questions guide the user through a classification or regression tree.
treeDetective(mod, data, rowname = "1")
treeDetective(mod, data, rowname = "1")
mod |
A tree model constructed by the |
data |
Data frame used to construct the model. |
rowname |
Character indicating the initial row name in |
Side-effects to console.
For more details on use, consult http://statistics.rainandrhino.org/tigerTree/treeDetective.html
## Not run: tr.mod <- tree(Species ~ ., data = iris) treeDetective(tr.mod, iris) ## End(Not run)
## Not run: tr.mod <- tree(Species ~ ., data = iris) treeDetective(tr.mod, iris) ## End(Not run)
Predict with a Tree
tryTree(mod, testSet, truth, printOut = TRUE)
tryTree(mod, testSet, truth, printOut = TRUE)
mod |
A tree model constructed by package |
testSet |
The test set (a data frame). |
truth |
Correct values of the response variable. |
printOut |
If TRUE, provide a printout to the console. |
A list containing: deviance
and residMeanDev
(residual mean deviance). If mod
is a classification tree, then the list
also contains error.rate
, misclass
(number of misclassifications
at terminal nodes), and confusion
(the confusion matrix).
For more details on use, consult http://statistics.rainandrhino.org/tigerTree/divideTrainTest.html
dfs <- divideTrainTest(seed = 3030, prop.train = 0.67, data = iris) irisTrain <- dfs$train irisTest <- dfs$test tr.mod <- tree(Species ~ ., data = irisTrain) summary(tr.mod) tryTree(mod = tr.mod, testSet = irisTest, truth = irisTest$Species)
dfs <- divideTrainTest(seed = 3030, prop.train = 0.67, data = iris) irisTrain <- dfs$train irisTest <- dfs$test tr.mod <- tree(Species ~ ., data = irisTrain) summary(tr.mod) tryTree(mod = tr.mod, testSet = irisTest, truth = irisTest$Species)
Hand-Tune a Tree Model
tuneTree(formula, data, testSet, truth)
tuneTree(formula, data, testSet, truth)
formula |
formula for |
data |
training data to make the tree models |
testSet |
quiz data to try the models on |
truth |
values of response variable in the quiz data |
No values returned
For more details on use, consult http://statistics.rainandrhino.org/tigerTree/tuneTree.html