@Override public Vector convertToVector() { return VectorFactory.getDefault().createVector(0); }
/** * Creates a new instance of MovingAverageFilter * @param coefficients * Coefficients of the moving-average filter. Element 0 is applied to the * most-recent input, Element 1 is applied to the second-most-recent, * and so forth. */ public MovingAverageFilter( double ... coefficients ) { this( VectorFactory.getDefault().copyArray( coefficients ) ); }
private Vector convert(FeatureVector feature) { return VectorFactory.getDenseDefault().copyArray(feature.asDoubleVector()); } }
@Override public Vector convertToVector() { return VectorFactory.getDefault().copyValues( this.shape, this.scale ); }
x[k] = VectorFactory.getDefault().createUniformRandom( dim, -1.0, 1.0, this.getRandom() ); x[k].plusEquals( CollectionUtil.getElement(this.data,index) );
final VectorFactory<?> vectorFactory = VectorFactory.getDenseDefault(); this.update = vectorFactory.createVector(this.dimensionality); 1.0 / (this.dimensionality * sqrtLambda); final Vector initialWeights = vectorFactory.createUniformRandom(this.dimensionality, -initializationRange, initializationRange, this.random); if (initialWeights.norm2() < (1.0 / sqrtLambda)) this.update = vectorFactory.createVector(this.dimensionality);
/** * Creates a new, empty {@link FactorizationMachine} of the given * input dimensionality (d) and factor count (k). It initializes the * internal d-dimensional weight vector and k-by-d factor matrix based on * these sizes. All values are initialized to 0. * * @param dimensionality * The input dimensionality (d). Cannot be negative. * @param factorCount * The number of factors for pairwise interactions (k). Cannot be * negative. */ public FactorizationMachine( final int dimensionality, final int factorCount) { this(0.0, VectorFactory.getDenseDefault().createVector(dimensionality), MatrixFactory.getDenseDefault().createMatrix( factorCount, dimensionality)); }
@Override public T predict(Double data) { return model.evaluate(VectorFactory.getDefault().createVector1D(data)); }
@Override public Vector convertToVector() { return VectorFactory.getDenseDefault().copyValues( this.getMinSupport(), this.getMaxSupport()); }
public Vector computeLocalWeights( final Vector counts) { // Since the counts are positive, the 1-norm of them is their sum. final Vector result = this.vectorFactory.copyVector(counts); final double countSum = counts.norm1(); if (countSum != 0.0) { result.scaleEquals(1.0 / countSum); } return result; }
/** * Copies the values from the given doubles into a Vector * @param values Values to copy * @return Vector with same dimension and values as "values" */ public VectorType copyValues( double... values ) { return this.copyArray( values ); }
/** * Creates a new {@code OnlinePerceptron}. */ public OnlinePerceptron() { this(VectorFactory.getDenseDefault()); }
/** * Creates a one-dimensional zero vector: (0.0). * * @return * A one-dimensional zero vector. */ public Vector1D createVector1D() { return this.createVector1D(0.0); }
this.documentCount, this.termCount); latent.pTermGivenLatent = this.getVectorFactory().createUniformRandom( this.termCount, 0.0, 1.0, this.getRandom()); VectorUtil.divideByNorm1Equals(latent.pTermGivenLatent); latent.pDocumentGivenLatent = this.getVectorFactory().createUniformRandom( this.documentCount, 0.0, 1.0, this.getRandom()); VectorUtil.divideByNorm1Equals(latent.pDocumentGivenLatent);
/** * Returns the parameter of the chi-square PDF * @return * 1-dimensional Vector containing the degrees of freedom */ @Override public Vector convertToVector() { return VectorFactory.getDefault().copyValues( this.getDegreesOfFreedom() ); }
x[k] = VectorFactory.getDefault().createUniformRandom( dim, -1.0, 1.0, this.getRandom() ); x[k].plusEquals( CollectionUtil.getElement(this.data,index) );
final VectorFactory<?> vectorFactory = VectorFactory.getDenseDefault(); this.update = vectorFactory.createVector(this.dimensionality); 1.0 / (this.dimensionality * sqrtLambda); final Vector initialWeights = vectorFactory.createUniformRandom(this.dimensionality, -initializationRange, initializationRange, this.random); if (initialWeights.norm2() < (1.0 / sqrtLambda)) this.update = vectorFactory.createVector(this.dimensionality);
/** * Creates a new, empty {@link FactorizationMachine} of the given * input dimensionality (d) and factor count (k). It initializes the * internal d-dimensional weight vector and k-by-d factor matrix based on * these sizes. All values are initialized to 0. * * @param dimensionality * The input dimensionality (d). Cannot be negative. * @param factorCount * The number of factors for pairwise interactions (k). Cannot be * negative. */ public FactorizationMachine( final int dimensionality, final int factorCount) { this(0.0, VectorFactory.getDenseDefault().createVector(dimensionality), MatrixFactory.getDenseDefault().createMatrix( factorCount, dimensionality)); }
@Override public boolean estimate(List<? extends IndependentPair<Double, T>> data) { final VectorNaiveBayesCategorizer.BatchGaussianLearner<T> learner = new VectorNaiveBayesCategorizer.BatchGaussianLearner<T>(); final List<InputOutputPair<Vector, T>> cfdata = new ArrayList<InputOutputPair<Vector, T>>(); for (final IndependentPair<Double, T> d : data) { final InputOutputPair<Vector, T> iop = new DefaultInputOutputPair<Vector, T>(VectorFactory.getDefault() .createVector1D(d.firstObject()), d.secondObject()); cfdata.add(iop); } model = learner.learn(cfdata); return true; }
@Override public Vector convertToVector() { return VectorFactory.getDenseDefault().copyValues( this.getMinSupport(), this.getMaxSupport()); }