Search in sources :

Example 1 with LogisticRegression

use of com.alibaba.alink.pipeline.classification.LogisticRegression in project Alink by alibaba.

the class Chap13 method c_3.

static void c_3() throws Exception {
    AkSourceBatchOp train_data = new AkSourceBatchOp().setFilePath(DATA_DIR + SPARSE_TRAIN_FILE);
    AkSourceBatchOp test_data = new AkSourceBatchOp().setFilePath(DATA_DIR + SPARSE_TEST_FILE);
    BatchOperator.setParallelism(1);
    new OneVsRest().setClassifier(new LogisticRegression().setVectorCol(VECTOR_COL_NAME).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME)).setNumClass(10).fit(train_data).transform(test_data).link(new EvalMultiClassBatchOp().setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).lazyPrintMetrics("OneVsRest - LogisticRegression"));
    new OneVsRest().setClassifier(new LinearSvm().setVectorCol(VECTOR_COL_NAME).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME)).setNumClass(10).fit(train_data).transform(test_data).link(new EvalMultiClassBatchOp().setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).lazyPrintMetrics("OneVsRest - LinearSvm"));
    BatchOperator.execute();
}
Also used : EvalMultiClassBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalMultiClassBatchOp) AkSourceBatchOp(com.alibaba.alink.operator.batch.source.AkSourceBatchOp) OneVsRest(com.alibaba.alink.pipeline.classification.OneVsRest) LinearSvm(com.alibaba.alink.pipeline.classification.LinearSvm) LogisticRegression(com.alibaba.alink.pipeline.classification.LogisticRegression)

Example 2 with LogisticRegression

use of com.alibaba.alink.pipeline.classification.LogisticRegression in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest5.

@Test
public void batchMixVecTest5() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec").setWithIntercept(false).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 3 with LogisticRegression

use of com.alibaba.alink.pipeline.classification.LogisticRegression in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest15.

@Test
public void batchMixVecTest15() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec2").setWithIntercept(false).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 4 with LogisticRegression

use of com.alibaba.alink.pipeline.classification.LogisticRegression in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest8.

@Test
public void batchMixVecTest8() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("vec").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)

Example 5 with LogisticRegression

use of com.alibaba.alink.pipeline.classification.LogisticRegression in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest6.

@Test
public void batchMixVecTest6() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("vec").setWithIntercept(false).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)

Aggregations

LogisticRegression (com.alibaba.alink.pipeline.classification.LogisticRegression)24 Pipeline (com.alibaba.alink.pipeline.Pipeline)20 PipelineModel (com.alibaba.alink.pipeline.PipelineModel)14 BatchOperator (com.alibaba.alink.operator.batch.BatchOperator)13 Test (org.junit.Test)13 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)10 EvalBinaryClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalBinaryClassBatchOp)9 VectorAssembler (com.alibaba.alink.pipeline.dataproc.vector.VectorAssembler)8 AkSinkBatchOp (com.alibaba.alink.operator.batch.sink.AkSinkBatchOp)3 LinearSvm (com.alibaba.alink.pipeline.classification.LinearSvm)3 OneVsRest (com.alibaba.alink.pipeline.classification.OneVsRest)3 DocCountVectorizer (com.alibaba.alink.pipeline.nlp.DocCountVectorizer)3 RegexTokenizer (com.alibaba.alink.pipeline.nlp.RegexTokenizer)3 File (java.io.File)3 EvalMultiClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalMultiClassBatchOp)2 NGram (com.alibaba.alink.pipeline.nlp.NGram)2 BinaryClassificationTuningEvaluator (com.alibaba.alink.pipeline.tuning.BinaryClassificationTuningEvaluator)2 GridSearchCV (com.alibaba.alink.pipeline.tuning.GridSearchCV)2 GridSearchCVModel (com.alibaba.alink.pipeline.tuning.GridSearchCVModel)2 ParamGrid (com.alibaba.alink.pipeline.tuning.ParamGrid)2