计算每一类数据的占比

def compute_ratio(x):
        """
        计算每一类数据的占比
        """
        sum_ = sum(x)
        ratios = []
        for i in x:
            ratio = i / sum_
            ratios.append(ratio)
        return ratios