Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ipd_extended/correlation_measures/binning.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (13 sloc)
698 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
class Binning: | |
def __init__(self, data): | |
self.rank_data = data.rank(method='first') | |
# todo (small reminder) in the original ipd it is NOT equal binning | |
# Series of binned points (with dropDuplicates produces not equally frequent bins) | |
def equal_frequency_binning(self, dim, bins_count): | |
return pd.qcut(self.rank_data.sort_values(by=dim)[dim], bins_count) | |
def equal_frequency_binning2(self, dim, bins_count): | |
qcut = pd.qcut(self.rank_data.sort_values(by=dim)[dim], bins_count) | |
return qcut.cat.rename_categories([i for i in range(bins_count)]).reindex(qcut.index) | |
def get_rank_data(self): | |
return self.rank_data |