Package 'tigerTree'

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

Help Index


Distribution at Nodes

Description

Easily find the distribtution of the response variable at each of the nodes of a classification tree.

Usage

distAtNodes(mod, df, resp_varname)

Arguments

mod

A tree model constructed by the tree package.

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.

Value

A table object.

Note

For more details on use, consult http://statistics.rainandrhino.org/tigerTree/distAtNodes.html

Examples

## 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)

Train-Test Splitting

Description

Divide a data frame into training and test set, or training, quiz and test set.

Usage

divideTrainTest(seed = NULL, prop.train = 0.6, prop.quiz = NULL, data)

Arguments

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 NULL by default.

data

The data frame to be split.

Value

A list with elements named test and train, or with elements named train and quiz and test.

Note

For more details on use, consult http://statistics.rainandrhino.org/tigerTree/divideTrainTest.html


Functions for Working with Trees in Elementary Data Analysis

Description

For use by elementary students in statistics and data analysis.


Tree-Detective

Description

Yes-No questions guide the user through a classification or regression tree.

Usage

treeDetective(mod, data, rowname = "1")

Arguments

mod

A tree model constructed by the tree package.

data

Data frame used to construct the model.

rowname

Character indicating the initial row name in mod$frame. Set to "1" by default.

Value

Side-effects to console.

Note

For more details on use, consult http://statistics.rainandrhino.org/tigerTree/treeDetective.html

Examples

## Not run: 
tr.mod <- tree(Species ~ ., data = iris)
treeDetective(tr.mod, iris)

## End(Not run)

Predict with a Tree

Description

Predict with a Tree

Usage

tryTree(mod, testSet, truth, printOut = TRUE)

Arguments

mod

A tree model constructed by package tree.

testSet

The test set (a data frame).

truth

Correct values of the response variable.

printOut

If TRUE, provide a printout to the console.

Value

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).

Note

For more details on use, consult http://statistics.rainandrhino.org/tigerTree/divideTrainTest.html

Examples

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

Description

Hand-Tune a Tree Model

Usage

tuneTree(formula, data, testSet, truth)

Arguments

formula

formula for tree.

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

Value

No values returned

Note

For more details on use, consult http://statistics.rainandrhino.org/tigerTree/tuneTree.html