Skip to content跳到正文
All work全部作品

2026 · Data Science数据科学

Fake News Detector — A Model That Reads Style, Not Truth假新闻检测器:一个看文风、不辨真假的模型

A text classifier trained on 44,898 news articles from 2016 and 2017. A bag-of-words logistic regression reached 92% on headlines alone and 99.6% with the full text, but the words it leaned on show what it really learned. It recognises how an article is written and where it came from, and it never checks whether a claim is true.一个文本分类器,用 2016 和 2017 年的 44,898 篇新闻文章训练而成。基于词袋的逻辑回归只看标题就达到 92% 的准确率,加上全文后达到 99.6%,但它最依赖的那些词暴露了它真正学到的东西。它认的是文章的写法和来源,从来不核实一个说法是不是真的。

Fake News Detector — A Model That Reads Style, Not Truth
Articles, fake and real文章数,包括假新闻和真新闻
44,89844,898
Test accuracy from headlines alone只看标题时的测试准确率
92.2%92.2%
With the full text, mostly from spotting the source加上全文后,主要靠认出来源
99.6%99.6%

The data

The Fake and Real News dataset (Bisaillon, 2020) has 23,481 fake and 21,417 real articles, mostly political news from 2016 and 2017, each with a headline, the full text, a subject and a date. The classes are close to balanced, so always guessing “fake” scores 52%, and any model has to beat that clearly.

The first thing the data gave away was a shortcut. The subject column splits the two classes perfectly. Every real article is filed under one of two subjects, and every fake one under the other six. A one-line rule on that column would score 100%, because the labels came from which site published the article, not from checking each story. I kept the subject out of every model.

One word is not enough

Fake headlines are longer and looser, about 94 characters on average against 65, and they lean on words like BREAKING, VIDEO and WATCH. BREAKING appears in 864 fake headlines and in no real ones, so when it shows up the article is almost certainly fake. It just doesn’t show up often. Used as a rule, it scores 49.6%, worse than guessing.

数据

Fake and Real News 数据集(Bisaillon, 2020)包含 23,481 篇假新闻和 21,417 篇真新闻,大多是 2016 和 2017 年的政治新闻,每篇都有标题、全文、主题和日期。两类的数量接近平衡,所以一律猜“假”能得到 52%,任何模型都必须明显超过这个水平。

数据最先暴露出来的是一条捷径。主题(subject)这一列能把两类完全分开:每篇真新闻都归在其中两个主题下,每篇假新闻都归在另外六个主题下。只凭这一列写一条规则就能得 100%,因为标签是按文章出自哪个网站来定的,而不是逐篇核实。所以我在所有模型里都没有用主题这一列。

只靠一个词不够

假新闻的标题更长、更随意,平均约 94 个字符,真新闻约 65 个,而且爱用 BREAKING(突发)、VIDEO(视频)和 WATCH(快看)这类词。BREAKING 出现在 864 条假新闻标题里,真新闻标题里一次也没有,所以只要它出现,这篇文章几乎肯定是假的。只是它出现得并不多。把它当成规则来用,准确率只有 49.6%,比瞎猜还差。

Bar chart of test accuracy: always guessing fake 52.3%, a BREAKING rule 49.6%, a VIDEO rule 59.8%, logistic regression on headline words 92.2%, and headline plus article text 99.6%

Letting the model weigh every word

Each headline was lowercased, stripped of stop words and lemmatised with spaCy, then turned into counts over the 1,000 most common words. A logistic regression on those counts reached 92.2% on held-out articles, with training accuracy only a point higher, so it isn’t simply memorising.

Its weights show what it learned. The words pushing toward fake are clickbait and partisan shorthand. The words pushing toward real are the house style of one news wire, like “factbox”, “Reuters”, “urges” and “spokesman”, plus the foreign stories that wire covered in those years.

让模型给每个词打分

每条标题都先转成小写,去掉停用词,再用 spaCy 做词形还原,然后统计最常见的 1,000 个词各出现了几次。在这些词频上训练的逻辑回归,对没见过的文章达到 92.2% 的准确率,而训练集准确率只高一个百分点,说明它不只是在死记硬背。

它的权重显示了它学到了什么。把结果推向“假”的词,是标题党用语和带党派色彩的简称。把结果推向“真”的词,是某一家通讯社的固定写法,比如 “factbox”(要点摘要)、“Reuters”、“urges”(敦促)和 “spokesman”(发言人),再加上这家通讯社那几年报道的国际新闻。

Diverging bar chart of word weights. Toward real: factbox, reuter, urge, myanmar, kremlin, spokesman. Toward fake: breaking, video, gop, dem, watch, wow.

Why 99.6% isn’t the headline

Adding the article text lifted accuracy to 99.6%. The strongest single weight in that model is the word “Reuters”, about five times larger than any other, because almost every real article opens with a Reuters dateline. The model is mostly recognising the source.

That has a cost outside this dataset. A real story from any other outlet would look suspicious, a fake one written in wire style would pass, and the 2016 vocabulary is already out of date. The cover shows both failures with headlines I wrote and ran through the model. Ordinary market news written as clickbait comes out as certainly fake, and a made-up policy claim written as a wire factbox comes out as certainly real. It checks style, not truth, so it can help a person decide what to look at first, and it shouldn’t be trusted to remove anything on its own.

为什么 99.6% 不是重点

加入正文之后,准确率升到 99.6%。这个模型里权重最大的单个词是 “Reuters”,比其他任何词大约大五倍,因为几乎每篇真新闻的开头都有路透社(Reuters)的电头。模型主要是在认来源。

一旦离开这个数据集,这就要付出代价。来自其他任何媒体的真实报道会显得可疑,用通讯社文风写的假新闻却能过关,而且 2016 年的用词已经过时了。封面图展示了这两种失败,用的是我自己写的标题,拿给模型去判断。用标题党方式写的普通市场新闻,被判定为肯定是假的;用通讯社要点摘要格式写的编造政策说法,被判定为肯定是真的。它检查的是文风,不是真假,所以可以帮人决定先看哪些内容,但不应该放手让它自己删除任何东西。