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);
}
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();
}
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();
}
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();
}
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();
}
Aggregations