This classifier attempts to infer the topic of a text.

This classifier has been trained on Facebook posts, but can be used for other texts as well.

The input text should typically be one or a few sentences.

This classifier assumes the topic of the text is unique. The probabilities reflect the belief in these topics, not the proportion of topics.

The current version only works for the English language.

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Use the "FacebookTopic" built-in classifier to detect the topic of a Facebook post:

Classify["FacebookTopic", "I love eating carrots in the morning"]

Classify multiple examples:

Classify["FacebookTopic", {"I bought a new computer", "happy birthday!", "this skirt looks nice"}]

Unrecognized topics or languages will return (RefLink[Indeterminate, paclet:ref/Indeterminate]):

Classify["FacebookTopic", {"what is this topic?","qwe niowqe mwoei!"}]

Obtain the probabilities for the 3 most likely classes:

Classify["FacebookTopic", "Let's celeberate your new job", "TopProbabilities"->3]

Obtain a (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) for this classifier:

c=Classify["FacebookTopic"]

Apply the classifier to a list of texts:

c[{"what have you been doing with your life lately", "Let's celeberate your new job"}]

OpenersExampleSection1(Spacer1)Scope  (1)

Load the (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) corresponding to the built-in classifier:

c=Classify["FacebookTopic"]

Obtain the possible classes using (RefLink[ClassifierInformation, paclet:ref/ClassifierInformation]):

Information[c,"Classes"]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)ClassPriors  (1)

Use a custom (RefLink[ClassPriors, paclet:ref/ClassPriors]) to restrict the possible outputs:

Classify["FacebookTopic", "Let's celeberate your new job", ClassPriors-><|"SpecialOccasions" -> 0.5, "Leisure" -> 0.5|>]

OpenersExampleSubsection1(Spacer1)IndeterminateThreshold  (1)

Use a custom (RefLink[IndeterminateThreshold, paclet:ref/IndeterminateThreshold]):

Classify["FacebookTopic","what have you been doing with your life lately",IndeterminateThreshold->.5]

OpenersExampleSubsection2(Spacer1)UtilityFunction  (1)

Obtain the utility function of the classifier:

utility=Information[Classify["FacebookTopic"],"UtilityFunction"];

Modify this utility function to penalize "Weather" being misclassified as "FoodAndDrink":

utility["Weather", "FoodAndDrink"]=-10.;

Classify the post using this new utility:

Classify["FacebookTopic","What does it mean when deserts freeze?",UtilityFunction->utility]

Compare to the result with the default utility:

Classify["FacebookTopic", "What does it mean when deserts freeze?"]

OpenersExampleSection3(Spacer1)Neat Examples  (1)

Obtain different possible topics with their corresponding probabilities:

topics=Classify["FacebookTopic","what have you been doing with your life lately","Probabilities"];

Visualize the result using (RefLink[WordCloud, paclet:ref/WordCloud]):

WordCloud[topics]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Classify, paclet:ref/Classify])  ▪  (RefLink[TextCases, paclet:ref/TextCases])  ▪  (RefLink[TextSentences, paclet:ref/TextSentences])  ▪  (RefLink[WolframLanguageData, paclet:ref/WolframLanguageData])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])(WebLink[: Machine Learning, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NeuralNetRepository.png(Spacer1)Wolfram Neural Net Repository, https://resources.wolframcloud.com/NeuralNetRepository/])}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Machine Learning, paclet:guide/MachineLearning])}})}})