Example #1
0
    def _save_min_max_meta(self, name, namespace):
        if self.scale_param.area == consts.ALL:
            LOGGER.debug("save_min_max_meta with mode is all")
            feat_upper = "None" if self.scale_param.feat_upper is None else str(self.scale_param.feat_upper)
            feat_lower = "None" if self.scale_param.feat_lower is None else str(self.scale_param.feat_lower)
            out_upper = "None" if self.scale_param.out_upper is None else str(self.scale_param.out_upper)
            out_lower = "None" if self.scale_param.out_lower is None else str(self.scale_param.out_lower)

            min_max_scale_meta = feature_scale_meta_pb2.MinMaxScaleMeta(feat_upper=feat_upper,
                                                                        feat_lower=feat_lower,
                                                                        out_upper=out_upper,
                                                                        out_lower=out_lower)

            minmax_scale_meta = {"0": min_max_scale_meta}
            meta_protobuf_obj = feature_scale_meta_pb2.ScaleMeta(is_scale=True,
                                                                 strategy=self.scale_param.method,
                                                                 minmax_scale_meta=minmax_scale_meta)
        else:
            LOGGER.debug("save_min_max_meta with mode is {}".format(self.scale_param.mode))
            meta_protobuf_obj = feature_scale_meta_pb2.ScaleMeta(is_scale=True)

        buffer_type = "{}.meta".format(self.class_name)
        model_manager.save_model(buffer_type=buffer_type,
                                 proto_buffer=meta_protobuf_obj,
                                 name=name,
                                 namespace=namespace)
        return buffer_type
Example #2
0
    def _save_standard_scale_meta(self, name, namespace):
        with_mean = self.scale_param.with_mean
        with_std = self.scale_param.with_std

        standard_scale_meta = feature_scale_meta_pb2.StandardScaleMeta(with_mean=with_mean, with_std=with_std)

        meta_protobuf_obj = feature_scale_meta_pb2.ScaleMeta(is_scale=True,
                                                             strategy=self.scale_param.method,
                                                             standard_scale_meta=standard_scale_meta)

        buffer_type = "{}.meta".format(self.class_name)
        model_manager.save_model(buffer_type=buffer_type,
                                 proto_buffer=meta_protobuf_obj,
                                 name=name,
                                 namespace=namespace)
        return buffer_type