Packages

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.

Linear Supertypes
Error, Predictor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Perceptron
  2. Error
  3. Predictor
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

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

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

  2. def coefficient: VectoD

    Return the vector of coefficient/parameter values.

    Return the vector of coefficient/parameter values.

    Definition Classes
    Predictor
  3. 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

  4. 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
  5. def fitLabels: Seq[String]

    Return the labels for the fit.

    Return the labels for the fit. Override when necessary.

    Definition Classes
    Predictor
  6. final def flaw(method: String, message: String): Unit
    Definition Classes
    Error
  7. 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

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

  9. 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
    PerceptronPredictor
  10. 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
  11. def reset(eta_: Double): Unit

    Reset the leaning rate 'eta'.

  12. def residual: VectoD

    Return the vector of residuals/errors.

    Return the vector of residuals/errors.

    Definition Classes
    Predictor
  13. 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

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

  15. 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
    PerceptronPredictor
  16. 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
    PerceptronPredictor