"FacebookTopic" (Built-in Classifier)
Classes
Details
- 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.
Examples
open all close allBasic 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["FacebookTopic", {"I bought a new computer", "happy birthday!", "this skirt looks nice"}]Unrecognized topics or languages will return 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 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"}]Scope (1)
Load the ClassifierFunction corresponding to the built-in classifier:
c = Classify["FacebookTopic"]Obtain the possible classes using Information:
Information[c, "Classes"]Options (3)
ClassPriors (1)
Use a custom ClassPriors to restrict the possible outputs:
Classify["FacebookTopic", "Let's celeberate your new job", ClassPriors -> <|"SpecialOccasions" -> 0.5, "Leisure" -> 0.5|>]IndeterminateThreshold (1)
Use a custom IndeterminateThreshold:
Classify["FacebookTopic", "what have you been doing with your life lately", IndeterminateThreshold -> .5]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?"]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 WordCloud:
WordCloud[topics]Related Guides
History
Introduced in 2018 (11.3)