# 导入库import numpy as np# 共 100 个样本每个样本 x 都包括 5 个特征nprandomseed0x = nprandomrandint02100 5# 共 100 个样本每个样本 x 都属于 01 类别中的一个nprandomseed0y = nprandomrandint02100# 给定 xx = 01011xx = nparray01011# setx_0 表示
for i in range(5): if xx[i] == 0: p_0 *= (setx_0[:,i]==0).sum() / setx_0.shape[0] else: p_0 *= (setx_0[:,i]==1).sum() / setx_0.shape[0] p_0 *= setx_0.shape[0] / 100
原文地址: http://www.cveoy.top/t/topic/enuK 著作权归作者所有。请勿转载和采集!