Short text classification with machine learning in the social sciences: The case of climate change on Twitter
pmc-PMC10540966.pdf · Phiên bản 1 · 26 trang
In our analysis, we use KNN with uniform weights. Because of the majority voting proce- dure, we set the hyperparameter k to an odd number. We sweep k and another hyperpara- meter, leaf size, to optimize the KNN performance. Naïve Bayes. Naïve Bayes (NB) is a probabilistic classifier whose basic idea is to use the joint probabilities of words and categories to estimate the conditional category probabilities given a data point [45]. It has been successfully used for text classification [46, 47]. It is called “naïve” because it makes an assumption that features are conditionally independent given the label. This assumption simplifies the computations carried out by the NB classifier, when com- pared to a non-naïve Bayes classifier, because the NB classifier does not use word combina- tions as predictors. Given an observation x, such as a short text, the NB classifier assigns the most probable cat- egory ^y according to ^y ¼ argmaxc2C fpðcjxÞg ¼ argmaxc2C fpðxjcÞpðcÞg; ð3Þ due to Bayes’ theorem. The term p(x) is not dependent on class c and hence skipped. Since it is difficult to estimate p(x|c), the naïve Bayes assumption is made. Namely, we factorize this con- ditional distribution as p(x|c) = p(x1|c)p(x2|c) � � � p(xM|c), which simplifies the computations. Moreover, p(c) is estimated as the fraction of the tweets in class y in the training set. Mean- while, p(xj|c) is estimated as the relative count of feature xj in class c to all features, with applied Laplace smoothing. The advantages of the NB classifier are its simplicity, good scalability, quick training and
insensitivity to irrelevant data. The disadvantages of the method are the assumption of inde- pendent predictor features and zero-probability problem for features present in the test set, but not occurring in the training set. Fig 4. Illustration of a k nearest neighbors classifier. For an unseen data point, the distances towards its k nearest neighbors are computed, and the majority class gets assigned. https://doi.org/10.1371/journal.pone.0290762.g004 PLOS ONE Short text classification with machine learning in the social sciences PLOS ONE | https://doi.org/10.1371/journal.pone.0290762 September 29, 2023 10 / 26