Search in sources :

Example 1 with OneHotEncoderModel

use of com.alibaba.alink.pipeline.feature.OneHotEncoderModel in project Alink by alibaba.

the class SplitBatchOpTest method testSplitAfterOneHot.

@Test
public void testSplitAfterOneHot() throws Exception {
    BatchOperator data = Iris.getBatchData();
    OneHotEncoderModel model = new OneHotEncoder().setSelectedCols(Iris.getFeatureColNames()).setReservedCols(Iris.getLabelColName()).setOutputCols("features").fit(data);
    data = model.transform(data);
    SplitBatchOp split = new SplitBatchOp().setFraction(0.4);
    BatchOperator data1 = split.linkFrom(data);
    BatchOperator data2 = split.getSideOutput(0);
    Assert.assertEquals(data1.count(), 60);
    Assert.assertEquals(data2.count(), 90);
}
Also used : OneHotEncoder(com.alibaba.alink.pipeline.feature.OneHotEncoder) BatchOperator(com.alibaba.alink.operator.batch.BatchOperator) OneHotEncoderModel(com.alibaba.alink.pipeline.feature.OneHotEncoderModel) Test(org.junit.Test)

Aggregations

BatchOperator (com.alibaba.alink.operator.batch.BatchOperator)1 OneHotEncoder (com.alibaba.alink.pipeline.feature.OneHotEncoder)1 OneHotEncoderModel (com.alibaba.alink.pipeline.feature.OneHotEncoderModel)1 Test (org.junit.Test)1