Analyzes the result of a classification algorithm's fitting. See also
    :func:`fit` for explanation of arguments.
976920
def classify_fit(fqdn, result, *argl, **argd):
    
    if len(argl) > 2:
        #Usually fit is called with fit(machine, Xtrain, ytrain).
        yP = argl[2]
    out = _generic_fit(fqdn, result, classify_predict, yP, *argl, **argd)
    return out
819863
def _return_result(self, result, comparison_vectors=None):
        
        return_type = cf.get_option('classification.return_type')

        if type(result) != np.ndarray:
            raise ValueError("numpy.ndarray expected.")

        # return the pandas.MultiIndex
        if return_type == 'index':
            return comparison_vectors.index[result.astype(bool)]

        # return a pandas.Series
        elif return_type == 'series':
            return pandas.Series(
                result,
                index=comparison_vectors.index,
                name='classification')

        # return a numpy.ndarray
        elif return_type == 'array':
            return result

        # return_type not known
        else:
            raise ValueError(
                "return_type {} unknown. Choose 'index', 'series' or "
                "'array'".format(return_type))
644462
def fit(self, weighted, show_progress=True):
        
        self.similarity = all_pairs_knn(weighted, self.K,
                                        show_progress=show_progress,
                                        num_threads=self.num_threads).tocsr()
        self.scorer = NearestNeighboursScorer(self.similarity)
175818
def fit(self, data):
        
        jmodel = callMLlibFunc("fitPCA", self.k, data)
        return PCAModel(jmodel)
203317
def fit(self, X):
        

        training_signal = X

        self.window_design(self.window_length, self.beta)

        if self.method == 'std_dev':
            self.fit_freq_std_dev(training_signal)
        elif self.method == 'min_max':
            self.fit_freq_min_max(training_signal)
        else:
            raise ValueError('Unknown method: {}'.format(self.method))
411558
def _fit(
    indexed_params,
    penalization,
    lam,
    lam_perturb,
    lam_scale_,
    estimator,
    penalty_name,
    subsample,
    bootstrap,
    prng,
    X=None,
):
    
    index = indexed_params

    if isinstance(X, np.ndarray):
        local_X = X
    else:
        local_X = X.value

    n_samples, n_features = local_X.shape

    prec_is_real = False
    while not prec_is_real:
        boot_lam = None
        if penalization == "subsampling":
            pass
        elif penalization == "random":
            boot_lam = _fix_weights(_random_weights, n_features, lam, lam_perturb, prng)
        elif penalization == "fully-random":
            boot_lam = _fix_weights(_fully_random_weights, n_features, lam_scale_, prng)
        else:
            raise NotImplementedError(
                (
                    "Only penalization = 'subsampling', "
                    "'random', and 'fully-random' have "
                    "been implemented. Found {}.".format(penalization)
                )
            )

        # new instance of estimator
        new_estimator = clone(estimator)
        if boot_lam is not None:
            new_estimator.set_params(**{penalty_name: boot_lam})

        # fit estimator
        num_subsamples = int(subsample * n_samples)
        rp = bootstrap(n_samples, num_subsamples, prng)
        new_estimator.fit(local_X[rp, :])

        # check that new_estimator.precision_ is real
        # if not, skip this boot_lam and try again
        if isinstance(new_estimator.precision_, list):
            prec_real_bools = []
            for prec in new_estimator.precision_:
                prec_real_bools.append(np.all(np.isreal(prec)))

            prec_is_real = np.all(np.array(prec_real_bools) is True)

        elif isinstance(new_estimator.precision_, np.ndarray):
            prec_is_real = np.all(np.isreal(new_estimator.precision_))

        else:
            raise ValueError("Estimator returned invalid precision_.")

    return index, (boot_lam, rp, new_estimator)
839244
def fit(*args)
    range, items = parse_fit_args(args)
    r = range.map{|x| "#{x} "}.join
    c = items.cmd_str
    puts send_cmd("fit #{r}#{c}")
    nil
  end
155462
def fit(self, X, y=None):
        
        # default to QuicGraphicalLassoCV
        estimator = self.estimator or QuicGraphicalLassoCV()

        self.lam_ = None
        self.estimator_ = None

        X = check_array(X, ensure_min_features=2, estimator=self)
        X = as_float_array(X, copy=False, force_all_finite=False)

        n_samples_, n_features_ = X.shape

        # perform first estimate
        estimator.fit(X)

        if self.method == "binary":
            # generate weights
            self.lam_ = self._binary_weights(estimator)

            # perform second step adaptive estimate
            self.estimator_ = QuicGraphicalLasso(
                lam=self.lam_ * estimator.lam_,
                mode="default",
                init_method="cov",
                auto_scale=False,
            )
            self.estimator_.fit(X)

        elif self.method == "inverse_squared":
            self.lam_ = self._inverse_squared_weights(estimator)

            # perform second step adaptive estimate
            self.estimator_ = QuicGraphicalLassoCV(
                lam=self.lam_ * self.estimator.lam_, auto_scale=False
            )
            self.estimator_.fit(X)

        elif self.method == "inverse":
            self.lam_ = self._inverse_weights(estimator)

            # perform second step adaptive estimate
            self.estimator_ = QuicGraphicalLassoCV(
                lam=self.lam_ * estimator.lam_, auto_scale=False
            )
            self.estimator_.fit(X)

        else:
            raise NotImplementedError(
                (
                    "Only method='binary', 'inverse_squared', or",
                    "'inverse' have been implemented.",
                )
            )

        self.is_fitted_ = True
        return self
873535
def fit(self, labels, samples, pstates):
        
        assert len(labels) == len(samples) == len(pstates)

        for label in set(labels):
            label_samples = [s for l,s in zip(labels, samples) if l == label]
            label_pstates = [p for l,p in zip(labels, pstates) if l == label]

            pohmm = self.pohmm_factory()
            pohmm.fit(label_samples, label_pstates)
            self.pohmms[label] = pohmm

        return self
492323
def fit_predict(self, X, y=None, **kwargs):
        
        return self.fit(X, **kwargs).predict(X, **kwargs)
1060802
def _fit_newton(self, fitcache=None, ebin=None, **kwargs):
        """"""

        tol = kwargs.get('tol', self.config['optimizer']['tol'])
        max_iter = kwargs.get('max_iter',
                              self.config['optimizer']['max_iter'])
        init_lambda = kwargs.get('init_lambda',
                                 self.config['optimizer']['init_lambda'])
        use_reduced = kwargs.get('use_reduced', True)

        free_params = self.get_params(True)
        free_norm_params = [p for p in free_params if p['is_norm'] is True]

        if len(free_params) != len(free_norm_params):
            msg = 'Executing Newton fitter with one ' + \
                'or more free shape parameters.'
            self.logger.error(msg)
            raise Exception(msg)

        verbosity = kwargs.get('verbosity', 0)
        if fitcache is None:
            fitcache = self._create_fitcache(**kwargs)

        fitcache.update(self.get_params(),
                        tol, max_iter, init_lambda, use_reduced)

        logemin = self.loge_bounds[0]
        logemax = self.loge_bounds[1]
        imin = int(utils.val_to_edge(self.log_energies, logemin)[0])
        imax = int(utils.val_to_edge(self.log_energies, logemax)[0])

        if ebin is not None:
            fitcache.fitcache.setEnergyBin(ebin)
        elif imin == 0 and imax == self.enumbins:
            fitcache.fitcache.setEnergyBin(-1)
        else:
            fitcache.fitcache.setEnergyBins(imin, imax)

        num_free = len(free_norm_params)

        o = {'fit_status': 0,
             'fit_quality': 3,
             'fit_success': True,
             'edm': 0,
             'loglike': None,
             'values': np.ones(num_free) * np.nan,
             'errors': np.ones(num_free) * np.nan,
             'indices': np.zeros(num_free, dtype=int),
             'is_norm': np.empty(num_free, dtype=bool),
             'src_names': num_free * [None],
             'par_names': num_free * [None],
             }

        if num_free == 0:
            return o

        ref_vals = np.array(fitcache.fitcache.refValues())
        free = np.array(fitcache.fitcache.currentFree())
        norm_vals = ref_vals[free]

        norm_idxs = []
        for i, p in enumerate(free_norm_params):

            norm_idxs += [p['idx']]
            o['indices'][i] = p['idx']
            o['src_names'][i] = p['src_name']
            o['par_names'][i] = p['par_name']
            o['is_norm'][i] = p['is_norm']

        o['fit_status'] = fitcache.fit(verbose=verbosity)
        o['edm'] = fitcache.fitcache.currentEDM()

        pars, errs, cov = fitcache.get_pars()
        pars *= norm_vals
        errs *= norm_vals
        cov = cov * np.outer(norm_vals, norm_vals)

        o['values'] = pars
        o['errors'] = errs
        o['covariance'] = cov
        errinv = np.zeros_like(o['errors'])
        m = o['errors'] > 0
        errinv[m] = 1. / o['errors'][m]
        o['correlation'] = o['covariance'] * np.outer(errinv, errinv)

        if o['fit_status'] in [-2, 0]:
            for idx, val, err in zip(norm_idxs, pars, errs):
                self._set_value_bounded(idx, val)
                self.like[idx].setError(err)
            self.like.syncSrcParams()
            o['fit_success'] = True
        else:
            o['fit_success'] = False

        if o['fit_status']:
            self.logger.error('Error in NEWTON fit. Fit Status: %i',
                              o['fit_status'])

        # FIXME: Figure out why currentLogLike gets out of sync
        #loglike = fitcache.fitcache.currentLogLike()
        #prior_vals, prior_errs, has_prior = gtutils.get_priors(self.like)
        #loglike -= np.sum(has_prior) * np.log(np.sqrt(2 * np.pi))
        loglike = -self.like()
        o['loglike'] = loglike

        return o
299859
def mark_fit_bad(self, fit):
        
        if fit not in self.bad_fits:
            self.bad_fits.append(fit)
            return True
        else:
            return False
692035
def fit(self, X, y=None):
        
        # The target determines what kind of estimator is fit
        ttype = type_of_target(y)
        if ttype.startswith(MULTICLASS):
            self.target_type_ = MULTICLASS
            self.estimator = OneVsRestClassifier(self.estimator)

            # Use label_binarize to create multi-label ouptut for OneVsRestClassifier
            self._target_labels = np.unique(y)
            Y = label_binarize(y, classes=self._target_labels)
        elif ttype.startswith(BINARY):
            self.target_type_ = BINARY

            # Different variable is used here to prevent transformation
            Y = y
        else:
            raise YellowbrickValueError((
                "{} does not support target type '{}', "
                "please provide a binary or multiclass single-output target"
            ).format(
                self.__class__.__name__, ttype
            ))

        # Fit the model and return self
        return super(PrecisionRecallCurve, self).fit(X, Y)
1019134
def fit(self, X, y=None, **kwargs):
        
        X = pandas_to_numpy(X)

        random_state = check_random_state(self.random_state)
        self._enc_cluster_centroids, self._enc_map, self.labels_,\
            self.cost_, self.n_iter_ = k_modes(X,
                                               self.n_clusters,
                                               self.max_iter,
                                               self.cat_dissim,
                                               self.init,
                                               self.n_init,
                                               self.verbose,
                                               random_state,
                                               self.n_jobs)
        return self
952800
def plot_fit(self):
        
        self.plt.plot(*self.fit.fit, **self.options['fit'])
545342
def _run_arguement_object_fits(self):
        
        # run fits
        # fit catalog object
        Y_dict = self._catalog_object.get_transformed_Y()
        # fit designmatrix object
        X = self._designmatrix_object.get_matrix()
        Xcol_names = self._designmatrix_object.get_columnnames()
        row_names = self._designmatrix_object.get_rownames()
        # make sure waveforms are matched
        # loop through Xrow_names, use as key for Y_dict, populate Y_matrix
        Y = np.empty((len(row_names),len(Y_dict[Y_dict.keys()[0]])))

        # check if waveforms are complex valued.  if so, instantiate Y as complex type
        if sum(np.iscomplex(Y_dict[Y_dict.keys()[0]])):
            # then it is complex
            Y = np.empty((len(row_names),len(Y_dict[Y_dict.keys()[0]]))).astype(np.complex)

        for i in np.arange(0,len(row_names)):
            Y[i,:] = Y_dict[row_names[i]]
        # fit basis object
        A = self._basis_object.fit_transform(Y)
        return Y, X, A, Xcol_names, row_names
1353402
def do_bestfit(self):
        
        self.check_important_variables()
        logx = np.log(self.args["x"])
        logy = np.log(self.args["y"])
        self.fit_args_log = np.polyfit(logx, logy, 1)
        self.fit_args = self.fit_args_log[:]
        self.fit_args[1] = np.exp(self.fit_args[1])
        self.done_bestfit = True
        return self.fit_args