Java library of 2-dimensional matrix algorithms.
Unsupervised:
- Principal Component Analysis (PCA)
- Generalized Least Squares Weighting (GLSW)
- External Parameter Orthogonalization (EPO)
- Independent Component Analysis (FastICA)
Supervised:
- Partial Least Squares (PLS1)
- Simple PLS (SIMPLS)
- Kernel PLS (KernelPLS)
- Orthogonal Signal Correction (OPLS)
- Nonlinear Iterative PLS (NIPALS)
- Sparse PLS (SparsePLS)
- Y Gradient based Generalized Least Squares Weighting (YGradientGLSW)
- Y Gradient based External Parameter Orthogonalization (YGradientEPO)
- Canonical Correlation Analysis (CCA)
- Domain Invariant PLS (DIPLS)
- Variance Constrained PLS
Planned:
Add the following dependency to your pom.xml
:
<dependency>
<groupId>nz.ac.waikato.cms.adams</groupId>
<artifactId>matrix-algorithms</artifactId>
<version>0.0.16</version>
</dependency>
import com.github.waikatodatamining.matrix.core.matrix.Matrix;
import com.github.waikatodatamining.matrix.algorithms.PCA;
import com.github.waikatodatamining.matrix.core.matrix.MatrixHelper;
public class Main {
public static void main(String[] args) {
Matrix data = MatrixHelper.read("bolts.csv", true, ',');
// remove the class column, if present
//data = MatrixHelper.deleteCol(data, data.getColumnDimension() - 1);
System.out.println("\nInput");
System.out.println(MatrixHelper.toString(data));
PCA pca = new PCA();
Matrix transformed = pca.transform(data);
System.out.println("\nTransformed");
System.out.println(MatrixHelper.toString(transformed));
}
}
import com.github.waikatodatamining.matrix.core.matrix.Matrix;
import com.github.waikatodatamining.matrix.algorithms.pls.SIMPLS;
import com.github.waikatodatamining.matrix.core.matrix.MatrixHelper;
public class Main {
public static void main(String[] args) {
Matrix predictors = MatrixHelper.read("bolts.csv", true, ',');
Matrix response = MatrixHelper.read("bolts_response.csv", true, ',');
System.out.println("\nPredictors");
System.out.println(MatrixHelper.toString(predictors));
System.out.println("\nResponse");
System.out.println(MatrixHelper.toString(response));
SIMPLS pls = new SIMPLS();
pls.setNumComponents(3);
try {
pls.configure(predictors, response);
} catch (Exception e) {
System.out.println("\nInitialization failed:\n" + e);
return;
}
System.out.println("\nTransformed");
System.out.println(MatrixHelper.toString(pls.transform(predictors)));
System.out.println("\nPredictions");
System.out.println(MatrixHelper.toString(pls.predict(predictors)));
System.out.println("\nLoadings");
System.out.println(MatrixHelper.toString(pls.getLoadings()));
}
}