Search in sources :

Example 1 with KerasSequentialRegressor

use of com.alibaba.alink.pipeline.regression.KerasSequentialRegressor in project Alink by alibaba.

the class Chap25 method dnnReg.

public static void dnnReg(BatchOperator<?> train_set, BatchOperator<?> test_set) throws Exception {
    BatchOperator.setParallelism(1);
    new Pipeline().add(new StandardScaler().setSelectedCols(Chap16.FEATURE_COL_NAMES)).add(new VectorAssembler().setSelectedCols(Chap16.FEATURE_COL_NAMES).setOutputCol("vec")).add(new VectorToTensor().setSelectedCol("vec").setOutputCol("tensor").setReservedCols("quality")).add(new KerasSequentialRegressor().setTensorCol("tensor").setLabelCol("quality").setPredictionCol("pred").setLayers("Dense(64, activation='relu')", "Dense(64, activation='relu')", "Dense(64, activation='relu')", "Dense(64, activation='relu')", "Dense(64, activation='relu')").setNumEpochs(20)).fit(train_set).transform(test_set).lazyPrintStatistics().link(new EvalRegressionBatchOp().setLabelCol("quality").setPredictionCol("pred").lazyPrintMetrics());
    BatchOperator.execute();
}
Also used : StandardScaler(com.alibaba.alink.pipeline.dataproc.StandardScaler) VectorAssembler(com.alibaba.alink.pipeline.dataproc.vector.VectorAssembler) EvalRegressionBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp) KerasSequentialRegressor(com.alibaba.alink.pipeline.regression.KerasSequentialRegressor) VectorToTensor(com.alibaba.alink.pipeline.dataproc.VectorToTensor) Pipeline(com.alibaba.alink.pipeline.Pipeline)

Aggregations

EvalRegressionBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp)1 Pipeline (com.alibaba.alink.pipeline.Pipeline)1 StandardScaler (com.alibaba.alink.pipeline.dataproc.StandardScaler)1 VectorToTensor (com.alibaba.alink.pipeline.dataproc.VectorToTensor)1 VectorAssembler (com.alibaba.alink.pipeline.dataproc.vector.VectorAssembler)1 KerasSequentialRegressor (com.alibaba.alink.pipeline.regression.KerasSequentialRegressor)1