📜  python 函数检查列表元素与总数据的比率 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:17.070000             🧑  作者: Mango

代码示例1
def compensate_imbalance(data):
    total_data = len(data)
    clean_data = [item for n, item in enumerate(data) if item not in data[:n]]
    weight_list = [data.count(item)/total_data for item in clean_data]
    return weight_list