/** * Gets the number of components in the analysis result. * * @return * The number of components in the analysis result. */ public int getComponentCount() { return this.components.getNumRows(); }
/** * Determines if this Factorization Machine has pairwise factor terms. * Without pairwise factor terms, this becomes a linear model. * * @return * True if this has pairwise factor terms; otherwise, false. */ public boolean hasFactors() { return this.factors != null && this.factors.getNumRows() > 0; }
/** * Gets the number of factors in the model. * * @return * The number of factors. Cannot be negative. */ public int getFactorCount() { return this.factors == null ? 0 : this.factors.getNumRows(); }
/** * Gets the number of components in the analysis result. * * @return * The number of components in the analysis result. */ public int getComponentCount() { return this.components.getNumRows(); }
/** * Gets the number of factors in the model. * * @return * The number of factors. Cannot be negative. */ public int getFactorCount() { return this.factors == null ? 0 : this.factors.getNumRows(); }
/** * Gets the number of components in the analysis result. * * @return * The number of components in the analysis result. */ public int getComponentCount() { return this.components.getNumRows(); }
/** * Gets the dimensionality of the inverse scale Matrix. * @return * Dimensionality of the inverse scale Matrix */ public int getInputDimensionality() { return this.getInverseScale().getNumRows(); }
@Override public boolean checkMultiplicationDimensions( final Matrix postMultiplicationMatrix) { return this.getNumColumns() == postMultiplicationMatrix.getNumRows(); }
/** * Gets the dimensionality of the inverse scale Matrix. * @return * Dimensionality of the inverse scale Matrix */ public int getInputDimensionality() { return this.getInverseScale().getNumRows(); }
@Override public int getOutputDimensionality() { return this.getDiscriminant().getNumRows(); }
/** * Returns the expected dimension of output Vectors * @return * Expected dimension of output Vectors */ public int getOutputDimensionality() { return this.getDimensionReducer().getDiscriminant().getNumRows(); }
/** * Creates a new instance of MultivariateDiscriminantWithBias. * * @param discriminant internal matrix to premultiply input vectors by. */ public MultivariateDiscriminantWithBias( final Matrix discriminant ) { this( discriminant, VectorFactory.getDefault().createVector(discriminant.getNumRows()) ); }
@Override public Matrix init(int rows, int cols) { Matrix currentValues = getCurrentValues(); Vector mean = currentValues.sumOfRows().scale(1f/currentValues.getNumRows()); Matrix m = DenseMatrixFactoryMTJ.INSTANCE.createMatrix(rows, cols); for (int r = 0; r < m.getNumRows(); r++) { m.setRow(r, mean); } return m; }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
private static double[][] fromMatrix(Matrix a) { final double[][] ret = new double[a.getNumRows()][a.getNumColumns()]; for (final MatrixEntry ds : a) { ret[ds.getRowIndex()][ds.getColumnIndex()] = ds.getValue(); } return ret; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, gPrime.apply(in.getElement(i, j))); } } return out; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, g.apply(in.getElement(i, j))); } } return out; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, gPrime.apply(in.getElement(i, j))); } } return out; }
@Override public void assertSameDimensions( Matrix other ) { if (!this.checkSameDimensions(other)) { throw new DimensionalityMismatchException( "Matrices must have same dimensions: " + "(" + this.getNumRows() + "x" + this.getNumColumns() + ") !=" + "(" + other.getNumRows() + "x" + other.getNumColumns() + ")" ); } }
/** * @param laplacian * @return copy and convert */ public static Jama.Matrix asJama(Matrix laplacian) { final Jama.Matrix ret = new Jama.Matrix(laplacian.getNumRows(), laplacian.getNumColumns()); for (final MatrixEntry matrixEntry : laplacian) { ret.set(matrixEntry.getRowIndex(), matrixEntry.getColumnIndex(), matrixEntry.getValue()); } return ret; }