# Path: xam/preprocessing/binning/equal_frequency.py
# class EqualFrequencyBinner(BaseUnsupervisedBinner):
# 
#     def __init__(self, n_bins=5):
# 
#         super().__init__()
# 
#         # Properties
#         self.n_bins = n_bins
# 
#     def fit(self, X, y=None, **fit_params):
#         """Choose equally spaces cut points."""
# 
#         # scikit-learn checks
#         X = check_array(X)
# 
#         step = 100 / self.n_bins
# 
#         self.cut_points_ = np.stack([
#             np.percentile(X, q, axis=0)
#             for q in np.arange(start=step, stop=100, step=step)
#         ], axis=-1).tolist()
# 
#         return self
# 
#     @property
#     def cut_points(self):
#         return self.cut_points_


import numpy as np
import pandas as pd
from .binning.equal_frequency import EqualFrequencyBinner
        else:
            self.binner.fit(X[:, self.column].values.reshape(-1, 1))

    def transform(self, X, y=None):

        if isinstance(X, pd.DataFrame):
            bins = self.binner.transform(X[[self.column]])[:, 0]
        else:
            bins = self.binner.transform(X[:, self.column].values.reshape(-1, 1))[:, 0]

        # Match each observation in the training set to a bin
        bin_counts = np.bincount(bins)

        # Count the number of values in each training set bin
        weights = 1 / np.array([bin_counts[x] for x in bins])

        # Weight each observation in the training set based on which bin it is in
        weights_norm = weights / np.sum(weights)

        if isinstance(X, pd.DataFrame):
            return X.sample(
                frac=self.sample_frac,
                weights=weights_norm,
                replace=False,
                random_state=self.seed
            )
        else:
            weights_norm = weights / np.sum(weights)
            return pd.DataFrame(X).sample(
                frac=self.sample_frac,

# Path: xam/preprocessing/binning/equal_frequency.py
# class EqualFrequencyBinner(BaseUnsupervisedBinner):
# 
#     def __init__(self, n_bins=5):
# 
#         super().__init__()
# 
#         # Properties
#         self.n_bins = n_bins
# 
#     def fit(self, X, y=None, **fit_params):
#         """Choose equally spaces cut points."""
# 
#         # scikit-learn checks
#         X = check_array(X)
# 
#         step = 100 / self.n_bins
# 
#         self.cut_points_ = np.stack([
#             np.percentile(X, q, axis=0)
#             for q in np.arange(start=step, stop=100, step=step)
#         ], axis=-1).tolist()
# 
#         return self
# 
#     @property
#     def cut_points(self):
#         return self.cut_points_


# Path: xam/preprocessing/resampling.py
import numpy as np
import pandas as pd
from .binning.equal_frequency import EqualFrequencyBinner

        else:
            self.binner.fit(X[:, self.column].values.reshape(-1, 1))

    def transform(self, X, y=None):

        if isinstance(X, pd.DataFrame):
            bins = self.binner.transform(X[[self.column]])[:, 0]
        else:
            bins = self.binner.transform(X[:, self.column].values.reshape(-1, 1))[:, 0]

        # Match each observation in the training set to a bin
        bin_counts = np.bincount(bins)

        # Count the number of values in each training set bin
        weights = 1 / np.array([bin_counts[x] for x in bins])

        # Weight each observation in the training set based on which bin it is in
        weights_norm = weights / np.sum(weights)

        if isinstance(X, pd.DataFrame):
            return X.sample(
                frac=self.sample_frac,
                weights=weights_norm,
                replace=False,
                random_state=self.seed
            )
        else:
            weights_norm = weights / np.sum(weights)
            return pd.DataFrame(X).sample(
                frac=self.sample_frac,

                weights=weights_norm,