How to use the mleap.sklearn.pipeline.SimpleSerializer function in mleap

To help you get started, we’ve selected a few mleap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github combust / mleap / python / mleap / sklearn / feature_extraction / text.py View on Github external
# define node inputs and outputs
        inputs = [{
                  "name": transformer.input_features,
                  "port": "input"
                  }]

        outputs = [{
                  "name": transformer.prediction_column,
                  "port": "output"
                   }]

        self.serialize(transformer, path, model_name, attributes, inputs, outputs)


class TfidfVectorizerSerializer(MLeapSerializer):
    pipeline_serializer = PipelineSerializer()

    def __init__(self):
        super(TfidfVectorizerSerializer, self).__init__()

    @staticmethod
    def set_prediction_column(transformer, prediction_column):
        transformer.prediction_column = prediction_column

    @staticmethod
    def set_input_features(transformer, input_features):
        transformer.input_features = input_features

    def serialize_to_bundle(self, transformer, path, model_name):
        num_features = transformer.idf_.shape[0]
        vocabulary = [None] * num_features