ClassPriors
是 Classify 及相关函数的一个选项,指定输出类别假定的显式先验概率,独立于从训练集推导出的结果.
范例
打开所有单元 关闭所有单元基本范例 (1)
trainingset = {1 -> "a", 2 -> "b", 3 -> "a", 4 -> "b", 5 -> "b", 6 -> "b", 7 -> "b"};c = Classify[trainingset]c[2.5, "Probabilities"]c[2.5, "Probabilities", ClassPriors -> <|"a" -> 0.5, "b" -> 0.5|>]c = Classify[trainingset, ClassPriors -> <|"a" -> 0.5, "b" -> 0.5|>]c[2.5, "Probabilities"]c[2.5, "Probabilities", ClassPriors -> <|"a" -> 0.8|>]c[2.5, "Probabilities", ClassPriors -> <|"a" -> 1|>]应用 (3)
Classify["Language", {"What is this language?", "¿Qué idioma es ese?", "Quelle est cette langue?"}, ClassPriors -> <|Entity["Language", "English"] -> 0.5, Entity["Language", "Spanish"] -> 0.5|>]c = Classify[{{1., 3.2, "Y"} -> "Diseased", {2.4, -3.1, "N"} -> "Healthy", {-2.1, 4.2, "N"} -> "Diseased", {2.7, -10, "N"} -> "Healthy", {-4., 6.2, "Y"} -> "Diseased", {2.5, 7., "Y"} -> "Healthy"}]c[{0.8, 2.2, "Y"}, "Probabilities"]求同一有机体患病的概率,结合患病有机体仅代表总体的1%这一先验知识:
c[{0.8, 2.2, "Y"}, "Probabilities", ClassPriors -> <|"Diseased" -> 0.01|>]训练一个分类器,使其能够根据网站用户的行为预测他是否会购买已给定物品:
c = Classify[{
{1.7, False, 1.3, True} -> "will buy", {-4, False, 1.1, True} -> "won't buy", {5.7, True, 1.2, True} -> "will buy", {7.3, False, 1.3, False} -> "won't buy", {-2.3, False, 1.8, True} -> "won't buy", {3.2, True, 1.4, True} -> "won't buy"
}]prior[temp_] := 0.15 + ArcTan[-0.1 * temp] / 10;Plot[prior[temp], {temp, -20, 40}, PlotRange -> {0, 1}]使用该模型和 WeatherData 提升对巴黎用户的预测效果,而无需额外的训练:
c[{7.2, False, 1.5, True}, "Probabilities", ClassPriors -> <|"will buy" -> prior[QuantityMagnitude[WeatherData["Paris", "Temperature"]]]|>]文本
Wolfram Research (2014),ClassPriors,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ClassPriors.html.
CMS
Wolfram 语言. 2014. "ClassPriors." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/ClassPriors.html.
APA
Wolfram 语言. (2014). ClassPriors. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ClassPriors.html 年
BibTeX
@misc{reference.wolfram_2026_classpriors, author="Wolfram Research", title="{ClassPriors}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/ClassPriors.html}", note=[Accessed: 05-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_classpriors, organization={Wolfram Research}, title={ClassPriors}, year={2014}, url={https://reference.wolfram.com/language/ref/ClassPriors.html}, note=[Accessed: 05-September-2026]}