/** * Gets the i-th orthogonal term vector that makes up the basis for * the transform. * * @param i * An index. Must be between 0 (inclusive) and rank (exclusive). * @return * The i-th orthogonal term vector. */ public Vector getTermVector( final int i) { return this.termBasis.getColumn(i); }
/** * Gets the i-th orthogonal term vector that makes up the basis for * the transform. * * @param i * An index. Must be between 0 (inclusive) and rank (exclusive). * @return * The i-th orthogonal term vector. */ public Vector getTermVector( final int i) { return this.termBasis.getColumn(i); }
/** * Gets the i-th orthogonal term vector that makes up the basis for * the transform. * * @param i * An index. Must be between 0 (inclusive) and rank (exclusive). * @return * The i-th orthogonal term vector. */ public Vector getTermVector( final int i) { return this.termBasis.getColumn(i); }
/** * {@inheritDoc} * @param data {@inheritDoc} * @param cogxels {@inheritDoc} */ public void toCogxels( Matrix data, CogxelState cogxels) { for( int j = 0; j < this.getColumnConverters().size(); j++ ) { Vector column = data.getColumn(j); this.getColumnConverters().get(j).toCogxels( column, cogxels ); } }
/** * {@inheritDoc} * @param data {@inheritDoc} * @param cogxels {@inheritDoc} */ public void toCogxels( Matrix data, CogxelState cogxels) { for( int j = 0; j < this.getColumnConverters().size(); j++ ) { Vector column = data.getColumn(j); this.getColumnConverters().get(j).toCogxels( column, cogxels ); } }
/** * Compute the proportion of completely zero columns to columns with * non-zero values * * @param mat * the matrix * @return the column sparsity */ public static double colSparcity(Matrix mat) { final double ncols = mat.getNumColumns(); double nsparse = 0; for (int c = 0; c < ncols; c++) { if (mat.getColumn(c).sum() == 0) { nsparse++; } } return nsparse / ncols; }
private Map<String, Pair<Double>> minMaxUsers() { Map<String, Pair<Double>> ret = new HashMap<String, Pair<Double>>(); if(this.learner == null) return ret; BiMap<String, Integer> depvals = this.learner.getDependantValues(); BilinearSparseOnlineLearner bilearner = this.learner.getBilinearLearner(); for (String task : depvals.keySet()) { Integer taskCol = this.learner.getDependantValues().get(task); ret.put( task, new Pair<Double>( CFMatrixUtils.min(bilearner.getU().getColumn(taskCol)), CFMatrixUtils.max(bilearner.getU().getColumn(taskCol)) ) ); } return ret; }
private Map<String, Pair<Double>> minMaxWords() { Map<String, Pair<Double>> ret = new HashMap<String, Pair<Double>>(); if(this.learner == null) return ret; BiMap<String, Integer> depvals = this.learner.getDependantValues(); BilinearSparseOnlineLearner bilearner = this.learner.getBilinearLearner(); for (String task : depvals.keySet()) { Integer taskCol = this.learner.getDependantValues().get(task); ret.put( task, new Pair<Double>( CFMatrixUtils.min(bilearner.getW().getColumn(taskCol)), CFMatrixUtils.max(bilearner.getW().getColumn(taskCol)) ) ); } return ret; }
private Map<String, Pair<Double>> minMaxWords() { Map<String, Pair<Double>> ret = new HashMap<String, Pair<Double>>(); if(this.learner == null) return ret; BiMap<String, Integer> depvals = this.learner.getDependantValues(); BilinearSparseOnlineLearner bilearner = this.learner.getBilinearLearner(); for (String task : depvals.keySet()) { Integer taskCol = this.learner.getDependantValues().get(task); ret.put( task, new Pair<Double>( CFMatrixUtils.min(bilearner.getW().getColumn(taskCol)), CFMatrixUtils.max(bilearner.getW().getColumn(taskCol)) ) ); } return ret; }
private Map<String, Pair<Double>> minMaxUsers() { Map<String, Pair<Double>> ret = new HashMap<String, Pair<Double>>(); if(this.learner == null) return ret; BiMap<String, Integer> depvals = this.learner.getDependantValues(); BilinearSparseOnlineLearner bilearner = this.learner.getBilinearLearner(); for (String task : depvals.keySet()) { Integer taskCol = this.learner.getDependantValues().get(task); ret.put( task, new Pair<Double>( CFMatrixUtils.min(bilearner.getU().getColumn(taskCol)), CFMatrixUtils.max(bilearner.getU().getColumn(taskCol)) ) ); } return ret; }
public void setValue( Matrix value) { final int dim = this.conditionalDistribution.getInputDimensionality(); if( (value.getNumRows() != dim) || (value.getNumColumns() != (dim+1) ) ) { throw new IllegalArgumentException( "Expected (dim x dim+1) Matrix" ); } Vector mean = value.getColumn(0); Matrix covariance = value.getSubMatrix(0, dim-1, 1,dim); this.conditionalDistribution.setMean(mean); this.conditionalDistribution.setCovariance(covariance); }
public void setValue( Matrix value) { final int dim = this.conditionalDistribution.getInputDimensionality(); if( (value.getNumRows() != dim) || (value.getNumColumns() != (dim+1) ) ) { throw new IllegalArgumentException( "Expected (dim x dim+1) Matrix" ); } Vector mean = value.getColumn(0); Matrix covariance = value.getSubMatrix(0, dim-1, 1,dim); this.conditionalDistribution.setMean(mean); this.conditionalDistribution.setCovariance(covariance); }
public void setValue( Matrix value) { final int dim = this.conditionalDistribution.getInputDimensionality(); if( (value.getNumRows() != dim) || (value.getNumColumns() != (dim+1) ) ) { throw new IllegalArgumentException( "Expected (dim x dim+1) Matrix" ); } Vector mean = value.getColumn(0); Matrix covariance = value.getSubMatrix(0, dim-1, 1,dim); this.conditionalDistribution.setMean(mean); this.conditionalDistribution.setCovariance(covariance); }
public double logEvaluate( Matrix input) { final int d = input.getNumRows(); Vector mean = input.getColumn(0); Matrix C = input.getSubMatrix(0,d-1,1,d); C.scaleEquals(1.0/this.covarianceDivisor); double lpg = this.gaussian.getProbabilityFunction().logEvaluate(mean); double lpiw = this.inverseWishart.getProbabilityFunction().logEvaluate(C); return lpg + lpiw; }
public double logEvaluate( Matrix input) { final int d = input.getNumRows(); Vector mean = input.getColumn(0); Matrix C = input.getSubMatrix(0,d-1,1,d); C.scaleEquals(1.0/this.covarianceDivisor); double lpg = this.gaussian.getProbabilityFunction().logEvaluate(mean); double lpiw = this.inverseWishart.getProbabilityFunction().logEvaluate(C); return lpg + lpiw; }
public double logEvaluate( Matrix input) { final int d = input.getNumRows(); Vector mean = input.getColumn(0); Matrix C = input.getSubMatrix(0,d-1,1,d); C.scaleEquals(1.0/this.covarianceDivisor); double lpg = this.gaussian.getProbabilityFunction().logEvaluate(mean); double lpiw = this.inverseWishart.getProbabilityFunction().logEvaluate(C); return lpg + lpiw; }
/** * Extract the diagonal elements as a vector * * @param mat * the matrix to extract from * @return the diagonal */ public static Vector diag(Matrix mat) { Vector ret; if (mat.getNumColumns() > mat.getNumRows()) { ret = mat.getRow(0); } else { ret = mat.getColumn(0); } final int rowcol = ret.getDimensionality(); for (int rc = 0; rc < rowcol; rc++) { ret.setElement(rc, mat.getElement(rc, rc)); } return ret; }
public Matrix predict(double[] x) { final Matrix X = prepareMatrix(x); final Matrix hiddenTimes = weightsL1.transpose().times(X); final Matrix hiddenVal = prepareMatrix(gMat.apply(hiddenTimes).getColumn(0)); final Matrix finalTimes = weightsL2.transpose().times(hiddenVal); final Matrix finalVal = gMat.apply(finalTimes); return finalVal; }
public Matrix predict(double[] x) { final Matrix X = prepareMatrix(x); final Matrix hiddenTimes = weightsL1.transpose().times(X); final Matrix hiddenVal = prepareMatrix(gMat.apply(hiddenTimes).getColumn(0)); final Matrix finalTimes = weightsL2.transpose().times(hiddenVal); final Matrix finalVal = gMat.apply(finalTimes); return finalVal; }