This file contains hidden or 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 numpy as np | |
from sklearn.utils.class_weight import compute_class_weight | |
from sklearn.preprocessing import MultiLabelBinarizer | |
def generate_class_weights(class_series, multi_class=True, one_hot_encoded=False): | |
""" | |
Method to generate class weights given a set of multi-class or multi-label labels, both one-hot-encoded or not. | |
Some examples of different formats of class_series and their outputs are: |