Search in sources :

Example 1 with StreamingKMeansStreamOp

use of com.alibaba.alink.operator.stream.clustering.StreamingKMeansStreamOp in project Alink by alibaba.

the class Chap18 method c_3.

static void c_3() throws Exception {
    AkSourceStreamOp stream_source = new AkSourceStreamOp().setFilePath(DATA_DIR + SPARSE_TRAIN_FILE);
    AkSourceBatchOp init_model = new AkSourceBatchOp().setFilePath(DATA_DIR + INIT_MODEL_FILE);
    StreamOperator<?> stream_pred = stream_source.link(new StreamingKMeansStreamOp(init_model).setTimeInterval(1L).setHalfLife(1).setPredictionCol(PREDICTION_COL_NAME)).select(PREDICTION_COL_NAME + ", " + LABEL_COL_NAME + ", " + VECTOR_COL_NAME);
    stream_pred.sample(0.001).print();
    stream_pred.link(new AkSinkStreamOp().setFilePath(DATA_DIR + TEMP_STREAM_FILE).setOverwriteSink(true));
    StreamOperator.execute();
    new AkSourceBatchOp().setFilePath(DATA_DIR + TEMP_STREAM_FILE).link(new EvalClusterBatchOp().setVectorCol(VECTOR_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).setLabelCol(LABEL_COL_NAME).lazyPrintMetrics("StreamingKMeans"));
    BatchOperator.execute();
}
Also used : AkSinkStreamOp(com.alibaba.alink.operator.stream.sink.AkSinkStreamOp) AkSourceBatchOp(com.alibaba.alink.operator.batch.source.AkSourceBatchOp) AkSourceStreamOp(com.alibaba.alink.operator.stream.source.AkSourceStreamOp) StreamingKMeansStreamOp(com.alibaba.alink.operator.stream.clustering.StreamingKMeansStreamOp) EvalClusterBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalClusterBatchOp)

Aggregations

EvalClusterBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalClusterBatchOp)1 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)1 StreamingKMeansStreamOp (com.alibaba.alink.operator.stream.clustering.StreamingKMeansStreamOp)1 AkSinkStreamOp (com.alibaba.alink.operator.stream.sink.AkSinkStreamOp)1 AkSourceStreamOp (com.alibaba.alink.operator.stream.source.AkSourceStreamOp)1