def __init__(self, config): super().__init__(config) self._class_encoder = SKLabelEncoder() self._feat_vectorizer = DictVectorizer() self._feat_selector = self._get_feature_selector() self._feat_scaler = self._get_feature_scaler() self._meta_type = None self._meta_feat_vectorizer = DictVectorizer(sparse=False) self._base_clfs = {} self.cv_loss_ = None self.train_acc_ = None
def setup_model(self, config): if config.model_settings is None: selector_type = None scale_type = None else: selector_type = config.model_settings.get('feature_selector') scale_type = config.model_settings.get('feature_scaler') self.class_encoder = SKLabelEncoder() self.feat_vectorizer = DictVectorizer() self._feat_selector = self._get_feature_selector(selector_type) self._feat_scaler = self._get_feature_scaler(scale_type)
def __init__(self, config): if not _is_module_available('torch'): raise ImportError( "Install the extra 'torch' library by runnning " "'pip install mindmeld[torch]' to use pytorch based neural models" ) super().__init__(config) self._label_encoder = get_label_encoder(self.config) self._class_encoder = SKLabelEncoder() self._query_text_type = None self._clf = None
def deserialise_encoder( encoder: acton_pb.Database.LabelEncoder ) -> sklearn.preprocessing.LabelEncoder: """Deserialises a LabelEncoder protobuf. Parameters ---------- encoder LabelEncoder protobuf. Returns ------- sklearn.preprocessing.LabelEncoder LabelEncoder (or None if no encodings were specified). """ encodings = [] for encoding in encoder.encoding: encodings.append((encoding.class_int, encoding.class_label)) encodings.sort() encodings = numpy.array([c[1] for c in encodings]) encoder = SKLabelEncoder() encoder.classes_ = encodings return encoder