class Perceptron extends Predictor with Error
The Perceptron
class supports single-output, 2-layer (input and output)
Neural-Networks. Although perceptrons are typically used for classification,
this class is used for prediction. Given several input vectors and output
values (training data), fit the weights/parameters 'b' connecting the layers,
so that for a new input vector 'z', the net can predict the output value, i.e.,
z = f (b dot z)
The parameter vector 'b' (w) gives the weights between input and output layers. Note, b0 is treated as the bias, so x0 must be 1.0.
- Alphabetic
- By Inheritance
- Perceptron
- Error
- Predictor
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Perceptron(x: MatrixD, y: VectorD, eta: Double = 1.0, afunc: FunctionS2S = sigmoid, afuncV: FunctionV_2V = sigmoidV)
- x
the input matrix (training data consisting of m input vectors)
- y
the output vector (training data consisting of m output values)
- eta
the learning/convergence rate (typically less than 1.0)
- afunc
the activation function (mapping scalar => scalar)
- afuncV
the activation function (mapping vector => vector)
Value Members
-
def
check(yy: VectoD): Unit
Given training data 'x' and 'yy', fit the parameter/weight vector 'b'.
Given training data 'x' and 'yy', fit the parameter/weight vector 'b'.
- yy
the output vector
-
def
coefficient: VectoD
Return the vector of coefficient/parameter values.
Return the vector of coefficient/parameter values.
- Definition Classes
- Predictor
-
def
diagnose(yy: VectoD): Unit
Compute diagostics for the predictor.
Compute diagostics for the predictor. Override to add more diagostics. Note, for 'rmse', 'sse' is divided by the number of instances 'm' rather than degrees of freedom.
- yy
the response vector
- Definition Classes
- Predictor
- See also
en.wikipedia.org/wiki/Mean_squared_error
-
def
fit: VectoD
Return the quality of fit including 'sse', 'mae', rmse' and 'rSq'.
Return the quality of fit including 'sse', 'mae', rmse' and 'rSq'. Override to add more quality of fit measures.
- Definition Classes
- Predictor
-
def
fitLabels: Seq[String]
Return the labels for the fit.
Return the labels for the fit. Override when necessary.
- Definition Classes
- Predictor
-
final
def
flaw(method: String, message: String): Unit
- Definition Classes
- Error
-
def
minimizeError(yy: VectoD): Unit
Minimize the error in the prediction by adjusting the weight vector 'b'.
Minimize the error in the prediction by adjusting the weight vector 'b'. The error 'e' is simply the difference between the target value 'yy' and the predicted value 'yp'. Minimize 1/2 of the dot product of error with itself using gradient-descent. The gradient is '-x.t * (e * yp * (_1 - yp))', so move in the opposite direction of the gradient.
- yy
the output vector
-
def
predict(z: MatriD): VectoD
Given a new input vector 'z', predict the output/response value 'f(z)'.
Given a new input vector 'z', predict the output/response value 'f(z)'.
- z
the new input vector
-
def
predict(z: VectoD): Double
Given a new input vector 'z', predict the output/response value 'f(z)'.
Given a new input vector 'z', predict the output/response value 'f(z)'.
- z
the new input vector
- Definition Classes
- Perceptron → Predictor
-
def
predict(z: VectoI): Double
Given a new discrete data vector z, predict the y-value of f(z).
Given a new discrete data vector z, predict the y-value of f(z).
- z
the vector to use for prediction
- Definition Classes
- Predictor
-
def
reset(eta_: Double): Unit
Reset the leaning rate 'eta'.
-
def
residual: VectoD
Return the vector of residuals/errors.
Return the vector of residuals/errors.
- Definition Classes
- Predictor
-
def
setWeights(stream: Int = 0): Unit
Set the initial weight vector 'b' with values in (0, 1) before training.
Set the initial weight vector 'b' with values in (0, 1) before training.
- stream
the random number stream to use
-
def
setWeights(w0: VectorD): Unit
Set the initial weight vector 'b' manually before training.
Set the initial weight vector 'b' manually before training.
- w0
the initial weights for b
-
def
train(): Unit
Given training data 'x' and 'y', fit the parameter/weight vector 'b'.
Given training data 'x' and 'y', fit the parameter/weight vector 'b'.
- Definition Classes
- Perceptron → Predictor
-
def
train(yy: VectoD): Unit
Given training data 'x' and 'yy', fit the parameter/weight vector 'b'.
Given training data 'x' and 'yy', fit the parameter/weight vector 'b'.
- yy
the output vector
- Definition Classes
- Perceptron → Predictor