Ejemplo n.º 1
0
 def save(self) -> dict:
     model_desc = super().save()
     model_desc['internal_model'] = self.impl.__class__.__module__ + "." + self.impl.__class__.__name__
     model_desc['desc'] = encode(self.impl)
     model_desc['sklearn_version'] = sklearn_version
     model_desc['trained_time'] = self.trained_time
     model_desc['weight'] = self.impl.coef_.tolist()
     return model_desc
Ejemplo n.º 2
0
def encode_formula(formula):
    str_repr = encode(formula)
    return {
        'desc': str_repr,
        'formula_type':
        formula.__class__.__module__ + "." + formula.__class__.__name__,
        'dependency': formula.fields,
        'window': formula.window
    }
Ejemplo n.º 3
0
    def save(self) -> dict:

        if self.__class__.__module__ == '__main__':
            alpha_logger.warning(
                "model is defined in a main module. The model_name may not be correct."
            )

        model_desc = dict(model_name=self.__class__.__module__ + "." +
                          self.__class__.__name__,
                          language='python',
                          saved_time=arrow.now().format("YYYY-MM-DD HH:mm:ss"),
                          features=list(self.features),
                          trained_time=self.trained_time,
                          desc=self.model_encode(),
                          formulas=encode(self.formulas),
                          fit_target=encode(self.fit_target),
                          internal_model=self.impl.__class__.__module__ + "." +
                          self.impl.__class__.__name__)
        return model_desc
Ejemplo n.º 4
0
 def save(self):
     return dict(name=self.name,
                 base_universe=self.base_universe,
                 exclude_universe=self.exclude_universe,
                 special_codes=self.special_codes,
                 filter_cond=encode(self.filter_cond))
Ejemplo n.º 5
0
 def __eq__(self, rhs):
     return self.model_encode() == rhs.model_encode() \
            and self.trained_time == rhs.trained_time \
            and list_eq(self.features, rhs.features) \
            and encode(self.formulas) == encode(rhs.formulas) \
            and encode(self.fit_target) == encode(rhs.fit_target)
Ejemplo n.º 6
0
 def model_encode(self):
     return encode(self.impl)