The SimpleRegression
class supports simple linear regression. In this case, the vector x consists of the constant one and a single variable x1, i.e., (1, x1). Fit the parameter vector 'b' in the regression equation y = b dot x + e = [b0, b1] dot [1, x1] + e = b0 + b1 * x1 + e where e represents the residuals (the part not explained by the model).
Value parameters
- fname_
-
the feature/variable names (only use the first two names)(defaults to null)
- x
-
the data/input matrix augmented with a first column of ones (only use the first two columns [1, x1])
- y
-
the response/output vector
Attributes
Members list
Type members
Inherited classlikes
The BestStep
is used to record the best improvement step found so far.
The BestStep
is used to record the best improvement step found so far.
Value parameters
- col
-
the column/variable to ADD/REMOVE for this step
- mod
-
the model including selected features/variables for this step
- qof
-
the Quality of Fit (QoF) for this step
Attributes
- Inherited from:
- Predictor
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Compute the confidence intervals for the parameters b_0 and b_1, returning their interval half widths.
Compute the confidence intervals for the parameters b_0 and b_1, returning their interval half widths.
Value parameters
- p
-
the confidence level
- x_
-
the training/full data/input matrix
Attributes
Produce a QoF summary for a model with diagnostics for each predictor 'x_0', 'x_1', and the overall Quality of Fit (QoF).
Produce a QoF summary for a model with diagnostics for each predictor 'x_0', 'x_1', and the overall Quality of Fit (QoF).
Value parameters
- b_
-
the parameters/coefficients for the model
- fname_
-
the array of feature/variable names
- vifs
-
the Variance Inflation Factors (VIFs)
- x_
-
the testing/full data/input matrix
Attributes
- Definition Classes
Test a predictive model y_ = f(x_) + e and return its QoF vector. Testing may be be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train before test.
Test a predictive model y_ = f(x_) + e and return its QoF vector. Testing may be be in-sample (on the training set) or out-of-sample (on the testing set) as determined by the parameters passed in. Note: must call train before test.
Value parameters
- x_
-
the testing/full data/input matrix (defaults to full x)
- y_
-
the testing/full response/output vector (defaults to full y)
Attributes
Train the predictor by fitting the parameter vector (b-vector) in the simple regression equation y = b dot x + e = [b0, b1] dot [1, x1] + e using the least squares method.
Train the predictor by fitting the parameter vector (b-vector) in the simple regression equation y = b dot x + e = [b0, b1] dot [1, x1] + e using the least squares method.
Value parameters
- x_
-
the training/full data/input matrix
- y_
-
the training/full response/output vector
Attributes
- See also
Inherited methods
Perform backward elimination to find the least predictive variable to remove from the existing model, returning the variable to eliminate, the new parameter vector and the new Quality of Fit (QoF). May be called repeatedly.
Perform backward elimination to find the least predictive variable to remove from the existing model, returning the variable to eliminate, the new parameter vector and the new Quality of Fit (QoF). May be called repeatedly.
Value parameters
- cols
-
the columns of matrix x currently included in the existing model
- first
-
first variable to consider for elimination (default (1) assume intercept x_0 will be in any model)
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Perform backward elimination to find the least predictive variables to remove from the full model, returning the variables left and the new Quality of Fit (QoF) measures for all steps.
Perform backward elimination to find the least predictive variables to remove from the full model, returning the variables left and the new Quality of Fit (QoF) measures for all steps.
Value parameters
- cross
-
whether to include the cross-validation QoF measure
- first
-
first variable to consider for elimination
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Build a sub-model that is restricted to the given columns of the data matrix. Must be implemented for models that support feature selection. NOT SUPPORTED for this model, so throw an EXCEPTION.
Build a sub-model that is restricted to the given columns of the data matrix. Must be implemented for models that support feature selection. NOT SUPPORTED for this model, so throw an EXCEPTION.
Value parameters
- x_cols
-
the columns that the new model is restricted to
Attributes
- Inherited from:
- NoSubModels
Attributes
- Inherited from:
- Predictor
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.
Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.
Value parameters
- w
-
the weights on the instances (defaults to null)
- y
-
the actual response/output vector to use (test/full)
- yp
-
the predicted response/output vector (test/full)
Attributes
- See also
-
Regression_WLS
- Definition Classes
- Inherited from:
- Fit
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Return the Quality of Fit (QoF) measures corresponding to the labels given. Note, if sse > sst, the model introduces errors and the rSq may be negative, otherwise, R^2 (rSq) ranges from 0 (weak) to 1 (strong). Override to add more quality of fit measures.
Attributes
- Inherited from:
- Fit
Perform forward selection to find the most predictive variable to add the existing model, returning the variable to add and the new model. May be called repeatedly.
Perform forward selection to find the most predictive variable to add the existing model, returning the variable to add and the new model. May be called repeatedly.
Value parameters
- cols
-
the columns of matrix x currently included in the existing model
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Perform forward selection to find the most predictive variables to have in the model, returning the variables added and the new Quality of Fit (QoF) measures for all steps.
Perform forward selection to find the most predictive variables to have in the model, returning the variables added and the new Quality of Fit (QoF) measures for all steps.
Value parameters
- cross
-
whether to include the cross-validation QoF measure
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Return the best model found from feature selection.
Return the feature/variable names.
Return the used data matrix x. Mainly for derived classes where x is expanded from the given columns in x_, e.g., SymbolicRegression.quadratic
adds squared columns.
Return the used data matrix x. Mainly for derived classes where x is expanded from the given columns in x_, e.g., SymbolicRegression.quadratic
adds squared columns.
Attributes
- Inherited from:
- Predictor
Return the used response vector y. Mainly for derived classes where y is transformed, e.g., TranRegression
, ARX
.
Return the used response vector y. Mainly for derived classes where y is transformed, e.g., TranRegression
, ARX
.
Attributes
- Inherited from:
- Predictor
Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit
trait. Override to correspond to fitLabel.
Return the help string that describes the Quality of Fit (QoF) measures provided by the Fit
trait. Override to correspond to fitLabel.
Attributes
- Inherited from:
- Fit
Return the hyper-parameters.
Return the relative importance of selected variables, ordered highest to lowest, rescaled so the highest is one.
Return the relative importance of selected variables, ordered highest to lowest, rescaled so the highest is one.
Value parameters
- cols
-
the selected columns/features/variables
- rSq
-
the matrix R^2 values (stand in for sse)
Attributes
- Inherited from:
- Predictor
The log-likelihood function times -2. Override as needed.
The log-likelihood function times -2. Override as needed.
Value parameters
- ms
-
raw Mean Squared Error
- s2
-
MLE estimate of the population variance of the residuals
Attributes
- See also
- Inherited from:
- Fit
Return the mean of the squares for error (sse / df). Must call diagnose first.
Return the mean of the squares for error (sse / df). Must call diagnose first.
Attributes
- Inherited from:
- Fit
Return the number of terms/parameters in the model, e.g., b_0 + b_1 x_1 + b_2 x_2 has three terms.
Return the number of terms/parameters in the model, e.g., b_0 + b_1 x_1 + b_2 x_2 has three terms.
Attributes
- Inherited from:
- Predictor
Return the vector of parameter/coefficient values.
Predict the value of vector y = f(x_, b), e.g., x_ * b for Regression
. May override for efficiency.
Predict the value of vector y = f(x_, b), e.g., x_ * b for Regression
. May override for efficiency.
Value parameters
- x_
-
the matrix to use for making predictions, one for each row
Attributes
- Inherited from:
- Predictor
Predict the value of y = f(z) by evaluating the formula y = b dot z, e.g., (b_0, b_1, b_2) dot (1, z_1, z_2). Must override when using transformations, e.g., ExpRegression
.
Predict the value of y = f(z) by evaluating the formula y = b dot z, e.g., (b_0, b_1, b_2) dot (1, z_1, z_2). Must override when using transformations, e.g., ExpRegression
.
Value parameters
- z
-
the new vector to predict
Attributes
- Inherited from:
- Predictor
Return the coefficient of determination (R^2). Must call diagnose first.
Return the coefficient of determination (R^2). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Return a basic report on a trained and tested multi-variate model.
Return a basic report on a trained and tested multi-variate model.
Value parameters
- ftMat
-
the matrix of qof values produced by the
Fit
trait
Attributes
- Inherited from:
- Model
Return a basic report on a trained and tested model.
Return a basic report on a trained and tested model.
Value parameters
- ftVec
-
the vector of qof values produced by the
Fit
trait
Attributes
- Inherited from:
- Model
Reset the best-step to default
Reset the degrees of freedom to the new updated values. For some models, the degrees of freedom is not known until after the model is built.
Reset the degrees of freedom to the new updated values. For some models, the degrees of freedom is not known until after the model is built.
Value parameters
- df_update
-
the updated degrees of freedom (model, error)
Attributes
- Inherited from:
- Fit
Return the vector of residuals/errors.
Perform feature selection to find the most predictive variables to have in the model, returning the variables added and the new Quality of Fit (QoF) measures for all steps.
Perform feature selection to find the most predictive variables to have in the model, returning the variables added and the new Quality of Fit (QoF) measures for all steps.
Value parameters
- cross
-
whether to include the cross-validation QoF measure
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
- tech
-
the feature selection technique to apply
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Return the sum of the squares for error (sse). Must call diagnose first.
Return the sum of the squares for error (sse). Must call diagnose first.
Attributes
- Inherited from:
- FitM
Perform stepwise regression to find the most predictive variables to have in the model, returning the variables left and the new Quality of Fit (QoF) measures for all steps. At each step it calls forwardSel and backwardElim and takes the best of the two actions. Stops when neither action yields improvement.
Perform stepwise regression to find the most predictive variables to have in the model, returning the variables left and the new Quality of Fit (QoF) measures for all steps. At each step it calls forwardSel and backwardElim and takes the best of the two actions. Stops when neither action yields improvement.
Value parameters
- cross
-
whether to include the cross-validation QoF measure
- idx_q
-
index of Quality of Fit (QoF) to use for comparing quality
Attributes
- See also
-
Fit
for index of QoF measures. - Inherited from:
- Predictor
Return the indices for the test-set.
Return the indices for the test-set.
Value parameters
- n_test
-
the size of test-set
- rando
-
whether to select indices randomly or in blocks
Attributes
- See also
-
scalation.mathstat.TnT_Split
- Inherited from:
- Predictor
The train2 method should work like the train method, but should also optimize hyper-parameters (e.g., shrinkage or learning rate). Only implementing classes needing this capability should override this method.
The train2 method should work like the train method, but should also optimize hyper-parameters (e.g., shrinkage or learning rate). Only implementing classes needing this capability should override this method.
Value parameters
- x_
-
the training/full data/input matrix (defaults to full x)
- y_
-
the training/full response/output vector (defaults to full y)
Attributes
- Inherited from:
- Predictor
Train and test the predictive model y_ = f(x_) + e and report its QoF and plot its predictions. Return the predictions and QoF. FIX - currently must override if y is transformed, @see TranRegression
Train and test the predictive model y_ = f(x_) + e and report its QoF and plot its predictions. Return the predictions and QoF. FIX - currently must override if y is transformed, @see TranRegression
Value parameters
- x_
-
the training/full data/input matrix (defaults to full x)
- xx
-
the testing/full data/input matrix (defaults to full x)
- y_
-
the training/full response/output vector (defaults to full y)
- yy
-
the testing/full response/output vector (defaults to full y)
Attributes
- Inherited from:
- Predictor
Attributes
- Inherited from:
- Predictor
Compute the Variance Inflation Factor (VIF) for each variable to test for multi-collinearity by regressing x_j against the rest of the variables. A VIF over 50 indicates that over 98% of the variance of x_j can be predicted from the other variables, so x_j may be a candidate for removal from the model. Note: override this method to use a superior regression technique.
Compute the Variance Inflation Factor (VIF) for each variable to test for multi-collinearity by regressing x_j against the rest of the variables. A VIF over 50 indicates that over 98% of the variance of x_j can be predicted from the other variables, so x_j may be a candidate for removal from the model. Note: override this method to use a superior regression technique.
Value parameters
- skip
-
the number of columns of x at the beginning to skip in computing VIF
Attributes
- Inherited from:
- Predictor
Inherited fields
The optional reference to an ontological concept