Build the estimator class.

        Returns
        -------
        :return : string
            The built class as string.
191498
def create_class(self, method):
        
        temp_type = self.temp('type')
        temp_arr = self.temp('arr')
        temp_arr_ = self.temp('arr[]')
        temp_arr__ = self.temp('arr[][]')

        # Samples:
        temps = []
        for atts in enumerate(self.estimator._fit_X):  # pylint: disable=W0212
            tmp = [temp_type.format(self.repr(a)) for a in atts[1]]
            tmp = temp_arr.format(', '.join(tmp))
            temps.append(tmp)
        temps = ', '.join(temps)
        temps = temp_arr__.format(type='double', name='X', values=temps,
                                  n=self.n_templates, m=self.n_features)

        # Classes:
        classes = self.estimator._y  # pylint: disable=W0212
        classes = [temp_type.format(int(c)) for c in classes]
        classes = ', '.join(classes)
        classes = temp_arr_.format(type='int', name='y', values=classes,
                                   n=self.n_templates)

        temp_class = self.temp('separated.class')
        return temp_class.format(class_name=self.class_name,
                                 method_name=self.method_name, method=method,
                                 n_features=self.n_features, X=temps, y=classes,
                                 n_neighbors=self.n_neighbors,
                                 n_templates=self.n_templates,
                                 n_classes=self.n_classes,
                                 power=self.power_param)
24705
def make_name(estimator):
  
  if estimator is not None:
    if isinstance(estimator, six.string_types):
      estimator_name = estimator
    else:
      estimator_name = estimator.__class__.__name__
  else:
    estimator_name = None
  return estimator_name
898371
def build(self) -> type:
        
        def _get_property_mappings(encoder: MappingJSONEncoder) -> List[JsonPropertyMapping]:
            return _get_all_property_mappings(encoder, self.mappings, self.superclasses)

        def get_deserializable_cls(decoder: MappingJSONDecoder) -> type:
            return self.target_cls

        return type(
            "%sDynamicMappingJSONDecoder" % self.target_cls.__name__,
            self.superclasses,
            {
                "_get_property_mappings": _get_property_mappings,
                "_get_deserializable_cls": get_deserializable_cls
            }
        )
386211
def create_tree(self):
        
        feature_indices = []
        for i in self.estimator.tree_.feature:
            n_features = self.n_features
            if self.n_features > 1 or (self.n_features == 1 and i >= 0):
                feature_indices.append([str(j) for j in range(n_features)][i])
        indentation = 1 if self.target_language in ['java', 'js',
                                                    'php', 'ruby'] else 0
        return self.create_branches(
            self.estimator.tree_.children_left,
            self.estimator.tree_.children_right,
            self.estimator.tree_.threshold,
            self.estimator.tree_.value,
            feature_indices, 0, indentation)
643381
def update(self):
        '''
        
        '''
        observed_arr = self.noise_sampler.generate()
        inferenced_arr = self.inference(observed_arr)

        error_arr = self.__encoder_decoder_controller.computable_loss.compute_loss(
            observed_arr,
            inferenced_arr
        )
        delta_arr = self.__encoder_decoder_controller.computable_loss.compute_delta(
            observed_arr,
            inferenced_arr
        )
        decoder_grads_list, encoder_delta_arr, encoder_grads_list = self.__encoder_decoder_controller.back_propagation(
            delta_arr
        )
        self.__encoder_decoder_controller.optimize(
            decoder_grads_list,
            encoder_grads_list,
            self.__learning_rate, 
            1
        )

        return error_arr
46318
def as_dict(self):
        
        d = self.final_structure.as_dict()
        d["@module"] = self.__class__.__module__
        d["@class"] = self.__class__.__name__
        d["history"] = jsanitize(self.history)
        d["version"] = __version__
        d["last_modified"] = str(datetime.datetime.utcnow())
        d["other_parameters"] = jsanitize(self.other_parameters)
        return d
1282095
def str_def(self):
        
        return "classname={!r}; min_api_version={!r}; api_version={!r}; " \
            "message={!r};". \
            format(self.__class__.__name__, self.min_api_version,
                   self.api_version, self.args[0])
523998
def buildCliString(self):
        
        config = self.navbar.getActiveConfig()
        group = self.buildSpec['widgets'][self.navbar.getSelectedGroup()]
        positional = config.getPositionalArgs()
        optional = config.getOptionalArgs()
        print(cli.buildCliString(
            self.buildSpec['target'],
            group['command'],
            positional,
            optional
        ))
        return cli.buildCliString(
            self.buildSpec['target'],
            group['command'],
            positional,
            optional
        )
912097
def _create_model_class(self, model):
        
        cls_name = model.replace('.', '_')
        # Hack for Python 2 (no need to do this for Python 3)
        if sys.version_info[0] < 3:
            if isinstance(cls_name, unicode):
                cls_name = cls_name.encode('utf-8')
        # Retrieve server fields info and generate corresponding local fields
        attrs = {
            '_env': self,
            '_odoo': self._odoo,
            '_name': model,
            '_columns': {},
        }
        fields_get = self._odoo.execute(model, 'fields_get')
        for field_name, field_data in fields_get.items():
            if field_name not in FIELDS_RESERVED:
                Field = fields.generate_field(field_name, field_data)
                attrs['_columns'][field_name] = Field
                attrs[field_name] = Field
        # Case where no field 'name' exists, we generate one (which will be
        # in readonly mode) in purpose to be filled with the 'name_get' method
        if 'name' not in attrs['_columns']:
            field_data = {'type': 'text', 'string': 'Name', 'readonly': True}
            Field = fields.generate_field('name', field_data)
            attrs['_columns']['name'] = Field
            attrs['name'] = Field
        return type(cls_name, (Model,), attrs)
1091866
def _parallel_build_estimators(n_estimators, ensemble, X, y, cost_mat,
                               seeds, verbose):
    """"""
    # Retrieve settings
    n_samples, n_features = X.shape
    max_samples = ensemble.max_samples
    max_features = ensemble.max_features

    if (not isinstance(max_samples, (numbers.Integral, np.integer)) and
            (0.0 < max_samples <= 1.0)):
        max_samples = int(max_samples * n_samples)

    if (not isinstance(max_features, (numbers.Integral, np.integer)) and
            (0.0 < max_features <= 1.0)):
        max_features = int(max_features * n_features)

    bootstrap = ensemble.bootstrap
    bootstrap_features = ensemble.bootstrap_features

    # Build estimators
    estimators = []
    estimators_samples = []
    estimators_features = []

    for i in range(n_estimators):
        if verbose > 1:
            print(("building estimator %d of %d" % (i + 1, n_estimators)))

        random_state = check_random_state(seeds[i])
        seed = check_random_state(random_state.randint(MAX_INT))
        estimator = ensemble._make_estimator(append=False)

        try:  # Not all estimator accept a random_state
            estimator.set_params(random_state=seed)
        except ValueError:
            pass

        # Draw features
        if bootstrap_features:
            features = random_state.randint(0, n_features, max_features)
        else:
            features = sample_without_replacement(n_features,
                                                  max_features,
                                                  random_state=random_state)

        # Draw samples, using a mask, and then fit
        if bootstrap:
            indices = random_state.randint(0, n_samples, max_samples)
        else:
            indices = sample_without_replacement(n_samples,
                                                 max_samples,
                                                 random_state=random_state)

        sample_counts = np.bincount(indices, minlength=n_samples)

        estimator.fit((X[indices])[:, features], y[indices], cost_mat[indices, :])
        samples = sample_counts > 0.

        estimators.append(estimator)
        estimators_samples.append(samples)
        estimators_features.append(features)

    return estimators, estimators_samples, estimators_features
1225746
def _get_help_for_estimator(prefix, estimator, defaults=None):
    """"""
    from numpydoc.docscrape import ClassDoc

    defaults = defaults or {}
    estimator = _extract_estimator_cls(estimator)
    yield "<{}> options:".format(estimator.__name__)

    doc = ClassDoc(estimator)
    yield from _get_help_for_params(
        doc['Parameters'],
        prefix=prefix,
        defaults=defaults,
    )
    yield ''
831081
def get_model(PARAMS):
    ''''''
    model_dict = {
        'LinearRegression': LinearRegression(),
        'SVR': SVR(),
        'KNeighborsRegressor': KNeighborsRegressor(),
        'DecisionTreeRegressor': DecisionTreeRegressor()
    }
    if not model_dict.get(PARAMS['model_name']):
        LOG.exception('Not supported model!')
        exit(1)
    
    model = model_dict[PARAMS['model_name']]
    
    try:
        if PARAMS['model_name'] == 'SVR':
            model.kernel = PARAMS['svr_kernel']
        elif PARAMS['model_name'] == 'KNeighborsRegressor':
            model.weights = PARAMS['knr_weights']
    except Exception as exception:
        LOG.exception(exception)
        raise
    return model
667469
def build_model(self):
        ''''''
        if self.model_config['model-type']:
            return self.build_red()
        elif self.model_config['model-type']:
            return self.buidl_hred()
        else:
            raise Error("Unrecognized model type '{}'".format(self.model_config['model-type']))
1103937
def create_class(self, method):
        
        self.__dict__.update(dict(method=method))
        temp_class = self.temp('separated.class')
        return temp_class.format(**self.__dict__)
853274
def to_dict(self):
        

        input_dict = super(EP, self)._save_to_input_dict()
        input_dict["class"] = "GPy.inference.latent_function_inference.expectation_propagation.EP"
        if self.ga_approx_old is not  None:
            input_dict["ga_approx_old"] = self.ga_approx_old.to_dict()
        if self._ep_approximation is not  None:
            input_dict["_ep_approximation"] = {}
            input_dict["_ep_approximation"]["post_params"] = self._ep_approximation[0].to_dict()
            input_dict["_ep_approximation"]["ga_approx"] = self._ep_approximation[1].to_dict()
            input_dict["_ep_approximation"]["cav_params"] = self._ep_approximation[2].to_dict()
            input_dict["_ep_approximation"]["log_Z_tilde"] = self._ep_approximation[3].tolist()

        return input_dict
490416
def as_dict(self):
        
        return {"@module": self.__class__.__module__,
                "@class": self.__class__.__name__,
                "additional_condition": self._additional_condition,
                "symmetry_measure_type": self.symmetry_measure_type,
                "nb_set_weights": [nb_set_weight.as_dict() for nb_set_weight in self.nb_set_weights],
                "ce_estimator": self.ce_estimator,
                }
692846
def describe_constructor(self, s):
        
        method = self.signatures.get(b"__constructor__")
        if not method:
            # constructor not available
            m = AbiMethod({"type": "constructor", "name": "", "inputs": [], "outputs": []})
            return m

        types_def = method["inputs"]
        types = [t["type"] for t in types_def]
        names = [t["name"] for t in types_def]

        if not len(s):
            values = len(types) * ["<nA>"]
        else:
            values = decode_abi(types, s)

        # (type, name, data)
        method.inputs = [{"type": t, "name": n, "data": v} for t, n, v in list(
            zip(types, names, values))]
        return method