Search in sources :

Example 36 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class PipelineCandidatesRandom method get.

@Override
public Tuple2<Pipeline, List<Tuple3<Integer, ParamInfo, Object>>> get(int index, List<Double> experienceScores) throws CloneNotSupportedException {
    ArrayList<Tuple3<Integer, ParamInfo, Object>> paramList = new ArrayList<>();
    rand.setSeed(this.seed + index * 100000);
    for (Tuple3<Integer, ParamInfo, ValueDist> t3 : this.items) {
        paramList.add(new Tuple3<>(t3.f0, t3.f1, t3.f2.get(rand.nextDouble())));
    }
    Pipeline pipelineClone = this.pipeline.clone();
    updatePipelineParams(pipelineClone, paramList);
    return Tuple2.of(pipelineClone, paramList);
}
Also used : Tuple3(org.apache.flink.api.java.tuple.Tuple3) ArrayList(java.util.ArrayList) ParamInfo(org.apache.flink.ml.api.misc.param.ParamInfo) Pipeline(com.alibaba.alink.pipeline.Pipeline)

Example 37 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class ItemCfTrainBatchOpTest method testPearson.

@Test
public void testPearson() {
    BatchOperator<?> emptyRate = BatchOperator.fromTable(MLEnvironmentFactory.getDefault().createBatchTable(rows, new String[] { "user", "item", "rate" }));
    BatchOperator<?> spliter = new LeaveTopKObjectOutBatchOp().setK(2).setObjectCol("item").setRateCol("rate").setOutputCol("label").setGroupCol("user");
    BatchOperator<?> test = spliter.linkFrom(emptyRate);
    BatchOperator<?> train = spliter.getSideOutput(0);
    ItemCfTrainBatchOp trainBatchOp = new ItemCfTrainBatchOp().setSimilarityType("PEARSON").setUserCol("user").setItemCol("item").setRateCol("rate").linkFrom(train);
    ItemCfItemsPerUserRecommender recommender = new ItemCfItemsPerUserRecommender().setUserCol("user").setRecommCol("recomm").setModelData(trainBatchOp);
    PipelineModel model = new Pipeline().add(recommender).fit(trainBatchOp);
    model.transform(test).collect();
}
Also used : ItemCfItemsPerUserRecommender(com.alibaba.alink.pipeline.recommendation.ItemCfItemsPerUserRecommender) PipelineModel(com.alibaba.alink.pipeline.PipelineModel) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Example 38 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class RandomForestTrainBatchOpTest method testC45Pipeline.

@Test
public void testC45Pipeline() throws Exception {
    C45 c45 = new C45().setFeatureCols(featureColNames).setCategoricalCols(categoricalColNames).setLabelCol(labelColName).setPredictionCol("c45_test_result").setPredictionDetailCol("c45_test_detail");
    Pipeline pipeline = new Pipeline().add(c45);
    BatchOperator<?> output = pipeline.fit(input).transform(input);
    output.lazyPrint(-1);
    BatchOperator<?> output1 = BatchOperator.fromTable(output.getOutputTable());
    output1.lazyPrint(-1);
    AlgoOperator<?> outputStream = pipeline.fit(input).transform(inputStream);
    outputStream.print();
    MLEnvironmentFactory.getDefault().getStreamExecutionEnvironment().execute();
}
Also used : C45(com.alibaba.alink.pipeline.classification.C45) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Example 39 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest3.

@Test
public void batchMixVecTest3() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec").setWithIntercept(true).setStandardization(false).setLabelCol("labels").setPredictionCol("pred"));
    PipelineModel model = pipeline.fit(trainData);
    model.transform(trainData).collect();
}
Also used : LogisticRegression(com.alibaba.alink.pipeline.classification.LogisticRegression) BatchOperator(com.alibaba.alink.operator.batch.BatchOperator) Pipeline(com.alibaba.alink.pipeline.Pipeline) PipelineModel(com.alibaba.alink.pipeline.PipelineModel) Test(org.junit.Test)

Example 40 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest17.

@Test
public void batchMixVecTest17() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec2").setWithIntercept(false).setStandardization(true).setLabelCol("labels").setPredictionCol("pred"));
    PipelineModel model = pipeline.fit(trainData);
    model.transform(trainData).collect();
}
Also used : LogisticRegression(com.alibaba.alink.pipeline.classification.LogisticRegression) BatchOperator(com.alibaba.alink.operator.batch.BatchOperator) Pipeline(com.alibaba.alink.pipeline.Pipeline) PipelineModel(com.alibaba.alink.pipeline.PipelineModel) Test(org.junit.Test)

Aggregations

Pipeline (com.alibaba.alink.pipeline.Pipeline)63 Test (org.junit.Test)38 PipelineModel (com.alibaba.alink.pipeline.PipelineModel)34 LogisticRegression (com.alibaba.alink.pipeline.classification.LogisticRegression)20 Row (org.apache.flink.types.Row)18 BatchOperator (com.alibaba.alink.operator.batch.BatchOperator)16 MemSourceBatchOp (com.alibaba.alink.operator.batch.source.MemSourceBatchOp)16 VectorAssembler (com.alibaba.alink.pipeline.dataproc.vector.VectorAssembler)11 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)10 CollectSinkStreamOp (com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp)9 EvalBinaryClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalBinaryClassBatchOp)8 MemSourceStreamOp (com.alibaba.alink.operator.stream.source.MemSourceStreamOp)7 File (java.io.File)5 ArrayList (java.util.ArrayList)5 EvalMultiClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalMultiClassBatchOp)4 StandardScaler (com.alibaba.alink.pipeline.dataproc.StandardScaler)4 Stopwatch (com.alibaba.alink.common.utils.Stopwatch)3 CsvSourceBatchOp (com.alibaba.alink.operator.batch.source.CsvSourceBatchOp)3 KMeans (com.alibaba.alink.pipeline.clustering.KMeans)3 VectorToTensor (com.alibaba.alink.pipeline.dataproc.VectorToTensor)3