fit_and_score: Fit and Score

Description Usage Arguments Value

View source: R/utils.R

Description

Fits a linear regression model to the data and scores the relative quality of the model using r-squared, aic, or bic.

Usage

1
fit_and_score(S, feature, algorithm, X_train, y_train, X_val, y_val, criterion)

Arguments

S

A vector representing the list of selected features in 'forward()' and 'backward()'

feature

Feature to add or drop, expressed as an integer.

algorithm

Direction of feature selection. One of: 'forward', 'backward'.

X_train

Training data. Represented as a 2D matrix of (observations, features).

y_train

Target class for training data. Represented as a 1D vector of target classes for X_train.

X_val

Validation data. Represented as a 2D matrix of (observations, features).

y_val

Target class for validation data. Represented as a 1D vector of target classes for X_val.

criterion

Model selection criterion to measure relative model quality. Can be one of:

  • 'aic': use Akaike Information Criterion

  • 'bic': use Akaike Information Criterion

  • 'r-squared': use coefficient of determination

Value

Score of the model (as a float).


UBC-MDS/punisheR documentation built on May 25, 2019, 1:36 p.m.