Fungsi Python untuk memeriksa rasio elemen daftar dengan total data

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
hacknasawithmatlab