Search in sources :

Example 1 with GmmTrainBatchOp

use of com.alibaba.alink.operator.batch.clustering.GmmTrainBatchOp in project Alink by alibaba.

the class GaussianMixtureTest method testLazyPrintClusterSummaries.

@Test
public void testLazyPrintClusterSummaries() throws Exception {
    VectorAssemblerBatchOp op = new VectorAssemblerBatchOp().setSelectedCols(Iris.getFeatureColNames()).setOutputCol("x").linkFrom(Iris.getBatchData());
    GmmTrainBatchOp gmm = new GmmTrainBatchOp().setVectorCol("x").setK(2).setEpsilon(0.).linkFrom(op);
    GmmPredictBatchOp predict = new GmmPredictBatchOp().setVectorCol("x").setPredictionCol("pred").linkFrom(gmm, op);
    ClusterMetrics eval = new EvalClusterBatchOp().setVectorCol("x").setLabelCol(Iris.getLabelColName()).setPredictionCol("pred").linkFrom(predict).collectMetrics();
    Assert.assertEquals(eval.getDb(), 1.15, 0.01);
    Assert.assertEquals(eval.getAri(), 0.35, 0.01);
}
Also used : GmmPredictBatchOp(com.alibaba.alink.operator.batch.clustering.GmmPredictBatchOp) GmmTrainBatchOp(com.alibaba.alink.operator.batch.clustering.GmmTrainBatchOp) ClusterMetrics(com.alibaba.alink.operator.common.evaluation.ClusterMetrics) VectorAssemblerBatchOp(com.alibaba.alink.operator.batch.dataproc.vector.VectorAssemblerBatchOp) EvalClusterBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalClusterBatchOp) Test(org.junit.Test)

Aggregations

GmmPredictBatchOp (com.alibaba.alink.operator.batch.clustering.GmmPredictBatchOp)1 GmmTrainBatchOp (com.alibaba.alink.operator.batch.clustering.GmmTrainBatchOp)1 VectorAssemblerBatchOp (com.alibaba.alink.operator.batch.dataproc.vector.VectorAssemblerBatchOp)1 EvalClusterBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalClusterBatchOp)1 ClusterMetrics (com.alibaba.alink.operator.common.evaluation.ClusterMetrics)1 Test (org.junit.Test)1