How to use the imblearn.utils.check_target_type function in imblearn

To help you get started, we’ve selected a few imblearn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-learn-contrib / imbalanced-learn / imblearn / ensemble / _easy_ensemble.py View on Github external
"""Train the ensemble on the training set.

        Parameters
        ----------
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
            The training input samples.

        y : array-like of shape (n_samples,)
            The target values.

        Returns
        -------
        self : object
            Returns self.
        """
        check_target_type(y)
        # RandomUnderSampler is not supporting sample_weight. We need to pass
        # None.
        return self._fit(X, y, self.max_samples, sample_weight=None)
github scikit-learn-contrib / imbalanced-learn / imblearn / ensemble / _weight_boosting.py View on Github external
The training input samples. Sparse matrix can be CSC, CSR, COO,
            DOK, or LIL. DOK and LIL are converted to CSR.

        y : array-like of shape (n_samples,)
            The target values (class labels).

        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, the sample weights are initialized to
            ``1 / n_samples``.

        Returns
        -------
        self : object
            Returns self.
        """
        check_target_type(y)
        self.samplers_ = []
        self.pipelines_ = []
        super().fit(X, y, sample_weight)
        return self
github scikit-learn-contrib / imbalanced-learn / imblearn / under_sampling / _prototype_selection / _random_under_sampler.py View on Github external
# store information to build dataframe
            self._X_columns = X.columns
            self._X_dtypes = X.dtypes
        else:
            self._X_columns = None
            self._X_dtypes = None

        if hasattr(y, "loc"):
            # store information to build a series
            self._y_name = y.name
            self._y_dtype = y.dtype
        else:
            self._y_name = None
            self._y_dtype = None

        y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
        X = check_array(X, accept_sparse=["csr", "csc"], dtype=None,
                        force_all_finite=False)
        y = check_array(
            y, accept_sparse=["csr", "csc"], dtype=None, ensure_2d=False
        )
        check_consistent_length(X, y)
        return X, y, binarize_y
github scikit-learn-contrib / imbalanced-learn / imblearn / over_sampling / _smote.py View on Github external
# store information to build dataframe
            self._X_columns = X.columns
            self._X_dtypes = X.dtypes
        else:
            self._X_columns = None
            self._X_dtypes = None

        if hasattr(y, "loc"):
            # store information to build a series
            self._y_name = y.name
            self._y_dtype = y.dtype
        else:
            self._y_name = None
            self._y_dtype = None

        y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
        X, y = check_X_y(X, y, accept_sparse=["csr", "csc"], dtype=None)
        return X, y, binarize_y
github scikit-learn-contrib / imbalanced-learn / imblearn / base.py View on Github external
    @staticmethod
    def _check_X_y(X, y):
        y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
        X, y = check_X_y(X, y, accept_sparse=['csr', 'csc'])
        return X, y, binarize_y
github scikit-learn-contrib / imbalanced-learn / imblearn / combine / _smote_enn.py View on Github external
def _fit_resample(self, X, y):
        self._validate_estimator()
        y = check_target_type(y)
        X, y = check_X_y(X, y, accept_sparse=["csr", "csc"])
        self.sampling_strategy_ = self.sampling_strategy

        X_res, y_res = self.smote_.fit_resample(X, y)
        return self.enn_.fit_resample(X_res, y_res)
github scikit-learn-contrib / imbalanced-learn / imblearn / misc.py View on Github external
def _check_X_y(self, X, y):
        if self.accept_sparse:
            X, y = check_X_y(X, y, accept_sparse=['csr', 'csc'])
        else:
            X, y = check_X_y(X, y, accept_sparse=False)
        y = check_target_type(y)

        return X, y
github scikit-learn-contrib / imbalanced-learn / imblearn / over_sampling / _random_over_sampler.py View on Github external
# store information to build dataframe
            self._X_columns = X.columns
            self._X_dtypes = X.dtypes
        else:
            self._X_columns = None
            self._X_dtypes = None

        if hasattr(y, "loc"):
            # store information to build a series
            self._y_name = y.name
            self._y_dtype = y.dtype
        else:
            self._y_name = None
            self._y_dtype = None

        y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
        X = check_array(X, accept_sparse=["csr", "csc"], dtype=None,
                        force_all_finite=False)
        y = check_array(
            y, accept_sparse=["csr", "csc"], dtype=None, ensure_2d=False
        )
        return X, y, binarize_y