# Path: DSTK/utils/sampling_helpers.py
# def get_minority_majority_keys(sample_size_dict):
# def upsample_minority_class(data, labels, random_seed=None):
# def downsample_majority_class(data, labels, random_seed=None):
# def random_sample(data, label, sample_fraction, random_seed=None):
# def create_bags(data, label, sample_fraction, num_bags, bagging_fraction, random_seed=None):
# def permute_column_of_numpy_array(array, col_idx, random_seed=None):


import pandas as pd
import numpy as np
import sys
import time
import abc
from DSTK.utils import sampling_helpers as sh
from sklearn.metrics import precision_score, accuracy_score, recall_score, roc_auc_score
                labels = labels.values

        start = time.time()
        for m in range(epochs):

            boot_data, oob_data, boot_labels, oob_labels = sh.random_sample(data,
                                                                            labels,
                                                                            sample_fraction=int(self.bootstrap_fraction * len(labels)),
                                                                            random_seed=self.random_seed)

            self.clf.fit(boot_data, boot_labels)
            boselector_metrics_dct = {attr: coef for attr, coef in zip(self.attributes, self._get_feature_coeff())}

            if self.feature_importance_metric:
                boselector_metrics_dct = self._calculate_feature_importance(oob_data, oob_labels)

            self.coeff_df = self.coeff_df.append(pd.Series(boselector_metrics_dct), ignore_index=True)
            self.num_bootstraps += 1

            if verbose == 1:
                sys.stdout.write("\r>> Iteration: {0:0d}/{1:0d}, elapsed time:{2:4.1f} s".format(m+1, epochs, time.time()-start))
                sys.stdout.flush()
        if verbose == 1:
            sys.stdout.write('\n')
            sys.stdout.flush()

    def _calculate_feature_importance(self, oob_data, oob_labels):

        dct = dict()
        for col_idx in np.where(np.asarray(self._get_feature_coeff()) != 0)[0]:

# Path: DSTK/utils/sampling_helpers.py
# def get_minority_majority_keys(sample_size_dict):
# def upsample_minority_class(data, labels, random_seed=None):
# def downsample_majority_class(data, labels, random_seed=None):
# def random_sample(data, label, sample_fraction, random_seed=None):
# def create_bags(data, label, sample_fraction, num_bags, bagging_fraction, random_seed=None):
# def permute_column_of_numpy_array(array, col_idx, random_seed=None):


# Path: DSTK/BoostedFeatureSelectors/base_selector.py
import pandas as pd
import numpy as np
import sys
import time
import abc
from DSTK.utils import sampling_helpers as sh
from sklearn.metrics import precision_score, accuracy_score, recall_score, roc_auc_score

                labels = labels.values

        start = time.time()
        for m in range(epochs):

            boot_data, oob_data, boot_labels, oob_labels = sh.random_sample(data,
                                                                            labels,
                                                                            sample_fraction=int(self.bootstrap_fraction * len(labels)),
                                                                            random_seed=self.random_seed)

            self.clf.fit(boot_data, boot_labels)
            boselector_metrics_dct = {attr: coef for attr, coef in zip(self.attributes, self._get_feature_coeff())}

            if self.feature_importance_metric:
                boselector_metrics_dct = self._calculate_feature_importance(oob_data, oob_labels)

            self.coeff_df = self.coeff_df.append(pd.Series(boselector_metrics_dct), ignore_index=True)
            self.num_bootstraps += 1

            if verbose == 1:
                sys.stdout.write("\r>> Iteration: {0:0d}/{1:0d}, elapsed time:{2:4.1f} s".format(m+1, epochs, time.time()-start))
                sys.stdout.flush()
        if verbose == 1:
            sys.stdout.write('\n')
            sys.stdout.flush()

    def _calculate_feature_importance(self, oob_data, oob_labels):

        dct = dict()
        for col_idx in np.where(np.asarray(self._get_feature_coeff()) != 0)[0]:

            mean_oob_perm = np.mean(np.asarray([self._get_metrics(sh.permute_column_of_numpy_array(oob_data, col_idx), oob_labels) for i in range(10)]), axis=0)