public class LocalNonnegativeMatrixFactorization extends Object
Modifier and Type | Field and Description |
---|---|
protected DoubleMatrix2D |
A
Input matrix
|
protected double[] |
aggregates
Sorting aggregates
|
protected double |
approximationError
Current approximation error
|
protected double[] |
approximationErrors
Approximation errors during subsequent iterations
|
protected static int |
DEFAULT_K |
protected static int |
DEFAULT_MAX_ITERATIONS |
protected static boolean |
DEFAULT_ORDERED |
protected static ISeedingStrategy |
DEFAULT_SEEDING_STRATEGY |
protected static double |
DEFAULT_STOP_THRESHOLD |
protected int |
iterationsCompleted
Iteration counter
|
protected int |
k
The desired number of base vectors
|
protected int |
maxIterations
The maximum number of iterations the algorithm is allowed to run
|
protected boolean |
ordered
Order base vectors according to their 'activity'?
|
protected ISeedingStrategy |
seedingStrategy
Seeding strategy
|
protected double |
stopThreshold
If the percentage decrease in approximation error becomes smaller than
stopThreshold , the algorithm will stop. |
protected DoubleMatrix2D |
U
Base vector result matrix
|
protected DoubleMatrix2D |
V
Coefficient result matrix
|
Constructor and Description |
---|
LocalNonnegativeMatrixFactorization(DoubleMatrix2D A)
Creates the LocalNonnegativeMatrixFactorization object for matrix A.
|
Modifier and Type | Method and Description |
---|---|
void |
compute()
Computes the factorization.
|
double[] |
getAggregates()
Returns column aggregates for a sorted factorization, and
null for an
unsorted factorization. |
double |
getApproximationError()
Returns approximation error achieved after the last iteration of the
algorithm or -1 if the approximation error is not available.
|
double[] |
getApproximationErrors() |
int |
getIterationsCompleted()
Returns the number of iterations the algorithm has completed.
|
int |
getK()
Returns the number of base vectors k .
|
int |
getMaxIterations()
Returns the maximum number of iterations the algorithm is allowed to run.
|
ISeedingStrategy |
getSeedingStrategy()
Returns current
ISeedingStrategy . |
double |
getStopThreshold()
Returns the algorithms
stopThreshold . |
DoubleMatrix2D |
getU()
Returns the U matrix (base vectors matrix).
|
DoubleMatrix2D |
getV()
Returns the V matrix (coefficient matrix)
|
boolean |
isOrdered()
Returns
true when the factorization is set to generate an ordered
basis. |
protected void |
order()
Orders U and V matrices according to the 'activity' of base vectors.
|
void |
setK(int k)
Sets the number of base vectors k .
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations the algorithm is allowed to run.
|
void |
setOrdered(boolean ordered)
Set to
true to generate an ordered basis. |
void |
setSeedingStrategy(ISeedingStrategy seedingStrategy)
Sets new
ISeedingStrategy . |
void |
setStopThreshold(double stopThreshold)
Sets the algorithms
stopThreshold . |
String |
toString() |
protected boolean |
updateApproximationError() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getU, getV
protected int k
protected static int DEFAULT_K
protected int maxIterations
protected static final int DEFAULT_MAX_ITERATIONS
protected double stopThreshold
stopThreshold
, the algorithm will stop. Note: calculation of
approximation error is quite costly. Setting the threshold to -1 turns off
approximation error calculation and hence makes the algorithm do the maximum number
of iterations.protected static double DEFAULT_STOP_THRESHOLD
protected ISeedingStrategy seedingStrategy
protected static final ISeedingStrategy DEFAULT_SEEDING_STRATEGY
protected boolean ordered
protected static final boolean DEFAULT_ORDERED
protected double approximationError
protected double[] approximationErrors
protected int iterationsCompleted
protected double[] aggregates
protected DoubleMatrix2D A
protected DoubleMatrix2D U
protected DoubleMatrix2D V
public LocalNonnegativeMatrixFactorization(DoubleMatrix2D A)
compute()
method.A
- matrix to be factorizedpublic void compute()
public void setK(int k)
k
- the number of base vectorspublic int getK()
protected boolean updateApproximationError()
stopThreshold
protected void order()
public ISeedingStrategy getSeedingStrategy()
ISeedingStrategy
.public void setSeedingStrategy(ISeedingStrategy seedingStrategy)
ISeedingStrategy
.public int getMaxIterations()
public void setMaxIterations(int maxIterations)
public double getStopThreshold()
stopThreshold
. If the percentage decrease in
approximation error becomes smaller than stopThreshold
, the algorithm
will stop.public void setStopThreshold(double stopThreshold)
stopThreshold
. If the percentage decrease in
approximation error becomes smaller than stopThreshold
, the algorithm
will stop.
Note: calculation of approximation error is quite costly. Setting the threshold to -1 turns off calculation of the approximation error and hence makes the algorithm do the maximum allowed number of iterations.
public double getApproximationError()
IIterativeMatrixFactorization
getApproximationError
in interface IIterativeMatrixFactorization
public double[] getApproximationErrors()
public int getIterationsCompleted()
IIterativeMatrixFactorization
getIterationsCompleted
in interface IIterativeMatrixFactorization
public boolean isOrdered()
true
when the factorization is set to generate an ordered
basis.public void setOrdered(boolean ordered)
true
to generate an ordered basis.public double[] getAggregates()
null
for an
unsorted factorization.public DoubleMatrix2D getU()
IMatrixFactorization
getU
in interface IMatrixFactorization
public DoubleMatrix2D getV()
IMatrixFactorization
getV
in interface IMatrixFactorization