ClassPriors
✖
ClassPriors
is an option for Classify and related functions that specifies explicit prior probabilities to assume for output classes, independent of anything deduced from the training set.
Details

- ClassPriors<class1p1,class2p2,… > specifies that the prior probability to classify a particular input as being in class classi should be pi.
- By default, the class priors are computed from the class frequencies of the training set.
- In ClassPriors<class1p1,class2p2,… >, unspecified class priors will be set to their rescaled default value to ensure normalization of the distribution.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Train a classifier on an unbalanced training set:

https://wolfram.com/xid/0btnc8ay4rdg-vvjkap

https://wolfram.com/xid/0btnc8ay4rdg-jgw9q2

Obtain class probabilities for a new example:

https://wolfram.com/xid/0btnc8ay4rdg-pzmtax

Set a uniform prior distribution for the classes:

https://wolfram.com/xid/0btnc8ay4rdg-3t4cal

Set the prior distribution of classes inside the classifier:

https://wolfram.com/xid/0btnc8ay4rdg-252zkb


https://wolfram.com/xid/0btnc8ay4rdg-no60bq

Priors of unspecified classes are functions of the remaining probability mass:

https://wolfram.com/xid/0btnc8ay4rdg-i5vc31


https://wolfram.com/xid/0btnc8ay4rdg-svuflv

Applications (3)Sample problems that can be solved with this function
Restrict the built-in language classifier to only two languages:

https://wolfram.com/xid/0btnc8ay4rdg-1v24g1

Train a classifier to recognize if an organism is diseased on a balanced training set:

https://wolfram.com/xid/0btnc8ay4rdg-3ot9yq

Find the probability that a new organism is diseased:

https://wolfram.com/xid/0btnc8ay4rdg-xfsyy0

Find the probability that the same organism is diseased, incorporating prior knowledge that diseased organisms represent only 1% of the population:

https://wolfram.com/xid/0btnc8ay4rdg-e93hbc

Train a classifier able to predict if a website user will buy a given item based on his behavior:

https://wolfram.com/xid/0btnc8ay4rdg-w7fes8

Define and visualize a model for the probability of buying the item as a function of the outside temperature:

https://wolfram.com/xid/0btnc8ay4rdg-lrelis

https://wolfram.com/xid/0btnc8ay4rdg-bvhlwv

Use this model and WeatherData to increase the prediction performance for a Parisian user, without additional training:

https://wolfram.com/xid/0btnc8ay4rdg-tb94fq

Wolfram Research (2014), ClassPriors, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassPriors.html.
Text
Wolfram Research (2014), ClassPriors, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassPriors.html.
Wolfram Research (2014), ClassPriors, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassPriors.html.
CMS
Wolfram Language. 2014. "ClassPriors." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ClassPriors.html.
Wolfram Language. 2014. "ClassPriors." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ClassPriors.html.
APA
Wolfram Language. (2014). ClassPriors. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClassPriors.html
Wolfram Language. (2014). ClassPriors. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClassPriors.html
BibTeX
@misc{reference.wolfram_2025_classpriors, author="Wolfram Research", title="{ClassPriors}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/ClassPriors.html}", note=[Accessed: 09-July-2025
]}
BibLaTeX
@online{reference.wolfram_2025_classpriors, organization={Wolfram Research}, title={ClassPriors}, year={2014}, url={https://reference.wolfram.com/language/ref/ClassPriors.html}, note=[Accessed: 09-July-2025
]}