CNN_2D

scalation.modeling.neuralnet.CNN_2D
See theCNN_2D companion object
class CNN_2D(x: TensorD, y: MatrixD, fname_: Array[String], nf: Int, nc: Int, hparam: HyperParameter, f: AFF, f1: AFF, val itran: FunctionM2M) extends Model, Fit

The CNN_2D class implements a Convolutionsl Network model. The model is trained using a data matrix x and response matrix y.

Value parameters

f

the activation function family for layers 1->2 (input to hidden)

f1

the activation function family for layers 2->3 (hidden to output)

fname_

the feature/variable names (defaults to null)

hparam

the hyper-parameters for the model/network

itran

the inverse transformation function returns responses to original scale

nc

the width of the filters (size of cofilters)

nf

the number of filters for this convolutional layer

x

the input/data matrix with instances stored in rows

y

the output/response matrix, where y_i = response for row i of matrix x

Attributes

Companion
object
Graph
Supertypes
trait Fit
trait FitM
trait Model
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def buildModel(x_cols: TensorD): CNN_2D

Build a sub-model that is restricted to the given columns of the data matrix.

Build a sub-model that is restricted to the given columns of the data matrix.

Value parameters

x_cols

the columns that the new model is restricted to

Attributes

def crossValidate(k: Int, rando: Boolean): Array[Statistic]

As seen from class CNN_2D, the missing signatures are as follows. For convenience, these are usable as stub implementations. FIX - put in new trait

As seen from class CNN_2D, the missing signatures are as follows. For convenience, these are usable as stub implementations. FIX - put in new trait

Attributes

def filter(i: Int, f: Int): MatrixD

Filter the i-th input vector with the f-th filter.

Filter the i-th input vector with the f-th filter.

Value parameters

f

the index of the f-th filter

i

the index of the i-th row of the matrix

Attributes

def getFname: Array[String]

Return the feature/variable names.

Return the feature/variable names.

Attributes

def getX: MatrixD

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

def getY: VectorD

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

Return the model hyper-parameters (if none, return null). Hyper-parameters may be used to regularize parameters or tune the optimizer.

Return the model hyper-parameters (if none, return null). Hyper-parameters may be used to regularize parameters or tune the optimizer.

Attributes

Return the vector of model parameter/coefficient values. Single output models have VectorD parameters, while multi-output models have MatrixD.

Return the vector of model parameter/coefficient values. Single output models have VectorD parameters, while multi-output models have MatrixD.

Attributes

Return the parameters c and b.

Return the parameters c and b.

Attributes

def predict(z: VectorD): Double | VectorD

Predict the value of y = f(z) by evaluating the model equation. Single output models return Double, while multi-output models return VectorD.

Predict the value of y = f(z) by evaluating the model equation. Single output models return Double, while multi-output models return VectorD.

Value parameters

z

the new vector to predict

Attributes

Given a new input vector z, predict the output/response vector f(z).

Given a new input vector z, predict the output/response vector f(z).

Value parameters

z

the new input vector

Attributes

Given an input matrix z, predict the output/response matrix f(z).

Given an input matrix z, predict the output/response matrix f(z).

Value parameters

z

the input matrix

Attributes

def test(x_: MatrixD, y_: VectorD): (VectorD, VectorD)

Test/evaluate the model's Quality of Fit (QoF) and return the predictions and QoF vectors. This may include the importance of its parameters (e.g., if 0 is in a parameter's confidence interval, it is a candidate for removal from the model). Extending traits and classess should implement various diagnostics for the test and full (training + test) datasets.

Test/evaluate the model's Quality of Fit (QoF) and return the predictions and QoF vectors. This may include the importance of its parameters (e.g., if 0 is in a parameter's confidence interval, it is a candidate for removal from the model). Extending traits and classess should implement various diagnostics for the test and full (training + test) datasets.

Value parameters

x_

the testiing/full data/input matrix (impl. classes may default to x)

y_

the testiing/full response/output vector (impl. classes may default to y)

Attributes

def test(x_: TensorD, y_: MatrixD): (MatrixD, MatrixD)

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 matrix (defaults to full y)

Attributes

def train(x_: MatrixD, y_: VectorD): Unit

Train the model 'y_ = f(x_) + e' on a given dataset, by optimizing the model parameters in order to minimize error '||e||' or maximize log-likelihood 'll'.

Train the model 'y_ = f(x_) + e' on a given dataset, by optimizing the model parameters in order to minimize error '||e||' or maximize log-likelihood 'll'.

Value parameters

x_

the training/full data/input matrix (impl. classes may default to x)

y_

the training/full response/output vector (impl. classes may default to y)

Attributes

def train(x_: TensorD, y_: MatrixD): Unit

Given training data x_ and y_, fit the parametera c and b. This is a simple algorithm that iterates over several epochs using gradient descent. It does not use batching nor a sufficient stopping rule. In practice, use the train2 method that uses a better optimizer.

Given training data x_ and y_, fit the parametera c and b. This is a simple algorithm that iterates over several epochs using gradient descent. It does not use batching nor a sufficient stopping rule. In practice, use the train2 method that uses a better optimizer.

Value parameters

x_

the training/full data/input matrix

y_

the training/full response/output matrix

Attributes

def train2(x_: TensorD, y_: MatrixD): Unit

Given training data x_ and y_, fit the parameters c and b. Iterate over several epochs, where each epoch divides the training set into batches. Each batch is used to update the weights. FIX - to be implemented

Given training data x_ and y_, fit the parameters c and b. Iterate over several epochs, where each epoch divides the training set into batches. Each batch is used to update the weights. FIX - to be implemented

Value parameters

x_

the training/full data/input matrix

y_

the training/full response/output matrix

Attributes

def updateFilterParams(f: Int, mat2: MatrixD): Unit

Update filter f's parameters.

Update filter f's parameters.

Value parameters

f

the index for the filter

mat2

the new paramters for the filter's vector

Attributes

Inherited methods

override def diagnose(y_: VectorD, yp_: VectorD, w: VectorD): VectorD

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
Fit -> FitM
Inherited from:
Fit
def diagnose_(y: VectorD, yp: VectorD, low: VectorD, up: VectorD, alpha: Double, w: VectorD): VectorD

Diagnose the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. Include interval measures. Note: wis should be computed separately.

Diagnose the health of the model by computing the Quality of Fit (QoF) metrics/measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted. Include interval measures. Note: wis should be computed separately.

Value parameters

alpha

the nominal level of uncertainty (alpha) (defaults to 0.9, 90%)

low

the predicted lower bound

up

the predicted upper bound

w

the weights on the instances (defaults to null)

y

the actual response/output vector to use (test/full)

yp

the point prediction mean/median

Attributes

See also

Regression_WLS

Inherited from:
Fit
def diagnose_wis(y: VectorD, yp: VectorD, low: MatrixD, up: MatrixD, alphas: Array[Double]): Double

Diagnose the health of the model by computing the Quality of Fit (QoF) measures,

Diagnose the health of the model by computing the Quality of Fit (QoF) measures,

Value parameters

alphas

the array of prediction levels

low

the lower bounds for various alpha levels

up

the upper bounds for various alpha levels

y

the given time-series (must be aligned with the interval forecast)

yp

the point prediction mean/median

Attributes

Inherited from:
Fit
override def fit: VectorD

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

Definition Classes
Fit -> FitM
Inherited from:
Fit

Return the the y-transformation.

Return the the y-transformation.

Attributes

Inherited from:
Fit
def getYY: MatrixD

Return the used response matrix y, if needed.

Return the used response matrix y, if needed.

Attributes

See also

neuralnet.PredictorMV

Inherited from:
Model
override def help: String

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

Definition Classes
Fit -> FitM
Inherited from:
Fit
def ll(ms: Double, s2: Double, m2: Int): Double

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
def mse_: Double

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
def rSq0_: Double

Attributes

Inherited from:
FitM
def rSq_: Double

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
def report(ftMat: MatrixD): String

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
def report(ftVec: VectorD): String

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
def resetDF(df_update: (Double, Double)): Unit

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
def show_interval_forecasts(yy: VectorD, yfh: VectorD, low: VectorD, up: VectorD, qof_all: VectorD, h: Int): Unit

Show the prediction interval forecasts and relevant QoF metrics/measures.

Show the prediction interval forecasts and relevant QoF metrics/measures.

Value parameters

h

the forecasting horizon

low

the predicted lower bound

qof_all

all the QoF metrics (for point and interval forecasts)

up

the predicted upper bound

yfh

the forecasts for horizon h

yy

the aligned actual response/output vector to use (test/full)

Attributes

Inherited from:
Fit
inline def smapeF(y: VectorD, yp: VectorD, e_: VectorD): Double

Return the symmetric Mean Absolute Percentage Error (sMAPE) score. Caveat: y_i = yp_i = 0 => no error => no percentage error

Return the symmetric Mean Absolute Percentage Error (sMAPE) score. Caveat: y_i = yp_i = 0 => no error => no percentage error

Value parameters

e_

the error/residual vector (if null, recompute)

y

the given time-series (must be aligned with the forecast)

yp

the forecasted time-series

Attributes

Inherited from:
FitM
def sse_: Double

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
override def summary(x_: MatrixD, fname: Array[String], b: VectorD, vifs: VectorD): String

Produce a QoF summary for a model with diagnostics for each predictor x_j and the overall Quality of Fit (QoF). Note: `Fac_Cholesky is used to compute the inverse of xtx.

Produce a QoF summary for a model with diagnostics for each predictor x_j and the overall Quality of Fit (QoF). Note: `Fac_Cholesky is used to compute the inverse of xtx.

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
Fit -> FitM
Inherited from:
Fit

Concrete fields

Inherited fields

var modelConcept: URI

The optional reference to an ontological concept

The optional reference to an ontological concept

Attributes

Inherited from:
Model
var modelName: String

The name for the model (or modeling technique).

The name for the model (or modeling technique).

Attributes

Inherited from:
Model