Class RBF<T>

java.lang.Object
smile.base.rbf.RBF<T>
Type Parameters:
T - the data type of samples.
All Implemented Interfaces:
Serializable

public class RBF<T> extends Object implements Serializable
A neuron in radial basis function network. A radial basis function network is an artificial neural network that uses radial basis functions as activation functions. It is a linear combination of radial basis functions.

In its basic form, radial basis function network is in the form y(x) = Σ wi φ(||x-ci||) where the approximating function y(x) is represented as a sum of N radial basis functions φ, each associated with a different center ci, and weighted by an appropriate coefficient wi. For distance, one usually chooses Euclidean distance. The weights wi can be estimated using the matrix methods of linear least squares, because the approximating function is linear in the weights.

The centers ci can be randomly selected from training data, or learned by some clustering method (e.g. k-means), or learned together with weight parameters undergo a supervised learning processing (e.g. error-correction learning).

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    RBF(T center, RadialBasisFunction rbf, Metric<T> distance)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    f(T x)
    The activation function.
    static RBF<double[]>[]
    fit(double[][] x, int k)
    Fits Gaussian RBF function and centers on data.
    static RBF<double[]>[]
    fit(double[][] x, int k, double r)
    Fits Gaussian RBF function and centers on data.
    static RBF<double[]>[]
    fit(double[][] x, int k, int p)
    Fits Gaussian RBF function and centers on data.
    static <T> RBF<T>[]
    fit(T[] x, Metric<T> distance, int k)
    Fits Gaussian RBF function and centers on data.
    static <T> RBF<T>[]
    fit(T[] x, Metric<T> distance, int k, double r)
    Fits Gaussian RBF function and centers on data.
    static <T> RBF<T>[]
    fit(T[] x, Metric<T> distance, int k, int p)
    Fits Gaussian RBF function and centers on data.
    static <T> RBF<T>[]
    of(T[] centers, RadialBasisFunction[] basis, Metric<T> distance)
    Makes a set of RBF neurons.
    static <T> RBF<T>[]
    of(T[] centers, RadialBasisFunction basis, Metric<T> distance)
    Makes a set of RBF neurons.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RBF

      public RBF(T center, RadialBasisFunction rbf, Metric<T> distance)
      Constructor.
      Parameters:
      center - the center of neuron.
      rbf - the radial basis functions.
      distance - the distance metric functor.
  • Method Details

    • f

      public double f(T x)
      The activation function.
      Parameters:
      x - the sample.
      Returns:
      the activation function value.
    • of

      public static <T> RBF<T>[] of(T[] centers, RadialBasisFunction basis, Metric<T> distance)
      Makes a set of RBF neurons.
      Type Parameters:
      T - the data type of samples.
      Parameters:
      centers - the neuron centers.
      basis - the radial basis functions.
      distance - the distance metric functor.
      Returns:
      the RBF neurons.
    • of

      public static <T> RBF<T>[] of(T[] centers, RadialBasisFunction[] basis, Metric<T> distance)
      Makes a set of RBF neurons.
      Type Parameters:
      T - the data type of samples.
      Parameters:
      centers - the neuron centers.
      basis - the radial basis functions.
      distance - the distance metric functor.
      Returns:
      the RBF neurons.
    • fit

      public static RBF<double[]>[] fit(double[][] x, int k)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the centroids of K-Means. Let dmax be the maximum distance between the chosen centers, the standard deviation (i.e. width) of Gaussian radial basis function is dmax / sqrt(2*k), where k is number of centers. This choice would be close to the optimal solution if the data were uniformly distributed in the input space, leading to a uniform distribution of centroids.
      Parameters:
      x - the training dataset.
      k - the number of RBF neurons to learn.
      Returns:
      a Gaussian RBF function with parameter learned from data.
    • fit

      public static RBF<double[]>[] fit(double[][] x, int k, int p)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the centroids of K-Means. The standard deviation (i.e. width) of Gaussian radial basis function is estimated by the p-nearest neighbors (among centers, not all samples) heuristic. A suggested value for p is 2.
      Parameters:
      x - the training dataset.
      k - the number of RBF neurons to learn.
      p - the number of nearest neighbors of centers to estimate the width of Gaussian RBF functions.
      Returns:
      Gaussian RBF functions with parameter learned from data.
    • fit

      public static RBF<double[]>[] fit(double[][] x, int k, double r)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the centroids of K-Means. The width of Gaussian radial basis function is estimated as the width of each cluster multiplied with a given scaling parameter r.
      Parameters:
      x - the training dataset.
      k - the number of RBF neurons to learn.
      r - the scaling parameter.
      Returns:
      Gaussian RBF functions with parameter learned from data.
    • fit

      public static <T> RBF<T>[] fit(T[] x, Metric<T> distance, int k)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the medoids of CLARANS. Let dmax be the maximum distance between the chosen centers, the standard deviation (i.e. width) of Gaussian radial basis function is dmax / sqrt(2*k), where k is number of centers. In this way, the radial basis functions are not too peaked or too flat. This choice would be close to the optimal solution if the data were uniformly distributed in the input space, leading to a uniform distribution of medoids.
      Type Parameters:
      T - the data type of samples.
      Parameters:
      x - the training dataset.
      distance - the distance functor.
      k - the number of RBF neurons to learn.
      Returns:
      a Gaussian RBF function with parameter learned from data.
    • fit

      public static <T> RBF<T>[] fit(T[] x, Metric<T> distance, int k, int p)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the medoids of CLARANS. The standard deviation (i.e. width) of Gaussian radial basis function is estimated by the p-nearest neighbors (among centers, not all samples) heuristic. A suggested value for p is 2.
      Type Parameters:
      T - the data type of samples.
      Parameters:
      x - the training dataset.
      distance - the distance functor.
      k - the number of RBF neurons to learn.
      p - the number of nearest neighbors of centers to estimate the width of Gaussian RBF functions.
      Returns:
      Gaussian RBF functions with parameter learned from data.
    • fit

      public static <T> RBF<T>[] fit(T[] x, Metric<T> distance, int k, double r)
      Fits Gaussian RBF function and centers on data. The centers are chosen as the medoids of CLARANS. The standard deviation (i.e. width) of Gaussian radial basis function is estimated as the width of each cluster multiplied with a given scaling parameter r.
      Type Parameters:
      T - the data type of samples.
      Parameters:
      x - the training dataset.
      distance - the distance functor.
      k - the number of RBF neurons to learn.
      r - the scaling parameter.
      Returns:
      Gaussian RBF functions with parameter learned from data.