Search in sources :

Example 1 with ComboMapper

use of com.alibaba.alink.common.mapper.ComboMapper in project Alink by alibaba.

the class ModelExporterUtils method createMapperFromStage.

// not open and load.
public static Mapper createMapperFromStage(PipelineStageBase<?> stage, TableSchema modelSchema, TableSchema inputSchema, List<Row> data) {
    Mapper mapper = null;
    if (stage instanceof MapModel) {
        MapModel<?> mapModel = (MapModel<?>) stage;
        mapper = mapModel.mapperBuilder.apply(modelSchema, inputSchema, mapModel.getParams());
        if (data != null) {
            ((ModelMapper) mapper).loadModel(data);
        }
    } else if (stage instanceof BaseRecommender) {
        mapper = RecommenderUtil.createRecommMapper((BaseRecommender<?>) stage, modelSchema, inputSchema, data);
    } else if (stage instanceof MapTransformer) {
        MapTransformer<?> mapTransformer = (MapTransformer<?>) stage;
        mapper = mapTransformer.mapperBuilder.apply(inputSchema, mapTransformer.getParams());
    } else {
        throw new RuntimeException("not support yet.");
    }
    if (mapper instanceof ComboModelMapper) {
        ((ComboModelMapper) mapper).newMapperList();
    }
    if (mapper instanceof ComboMapper) {
        ((ComboMapper) mapper).newMapperList();
    }
    return mapper;
}
Also used : ModelMapper(com.alibaba.alink.common.mapper.ModelMapper) ComboModelMapper(com.alibaba.alink.common.mapper.ComboModelMapper) ComboMapper(com.alibaba.alink.common.mapper.ComboMapper) PipelineModelMapper(com.alibaba.alink.common.mapper.PipelineModelMapper) Mapper(com.alibaba.alink.common.mapper.Mapper) ComboMapper(com.alibaba.alink.common.mapper.ComboMapper) BaseRecommender(com.alibaba.alink.pipeline.recommendation.BaseRecommender) ModelMapper(com.alibaba.alink.common.mapper.ModelMapper) ComboModelMapper(com.alibaba.alink.common.mapper.ComboModelMapper) PipelineModelMapper(com.alibaba.alink.common.mapper.PipelineModelMapper) ComboModelMapper(com.alibaba.alink.common.mapper.ComboModelMapper)

Aggregations

ComboMapper (com.alibaba.alink.common.mapper.ComboMapper)1 ComboModelMapper (com.alibaba.alink.common.mapper.ComboModelMapper)1 Mapper (com.alibaba.alink.common.mapper.Mapper)1 ModelMapper (com.alibaba.alink.common.mapper.ModelMapper)1 PipelineModelMapper (com.alibaba.alink.common.mapper.PipelineModelMapper)1 BaseRecommender (com.alibaba.alink.pipeline.recommendation.BaseRecommender)1