使用词云可视化文本数据

这个示例展示了如何使用单词云可视化文本数据。

文本分析工具箱扩展了wordcloud(MATLAB)功能。它还支持直接从字万博1manbetx符串数组创建单词云,以及从单词包模型和LDA主题创建单词云。

加载示例数据。该文件factoryReports.csv包含工厂报告,包括每个事件的文本描述和分类标签。

文件名=“factoryReports.csv”;台= readtable(文件名,“TextType”,“字符串”);

属性中提取文本数据描述列。

textData = tbl.Description;textData (1:10)
ans =10 x1字符串“物品偶尔会卡在扫描仪的卷轴里。”"Loud rattling and banging sounds are coming from assembler pistons." "There are cuts to the power when starting the plant." "Fried capacitors in the assembler." "Mixer tripped the fuses." "Burst pipe in the constructing agent is spraying coolant." "A fuse is blown in the mixer." "Things continue to tumble off of the belt." "Falling items from the conveyor belt." "The scanner reel is split, it will soon begin to curve."

从报告中创建一个单词云。

图wordcloud (textData);标题(“工厂报告”)

将报告中的单词与标签进行比较“泄漏”“机械故障”。为每个标签创建报表的单词云。为每个单词云分别指定单词颜色为蓝色和洋红色。

figure labels = tbl.Category;subplot(1,2,1) idx =标签==“泄漏”;wordcloud (textData (idx),“颜色”,“蓝”);标题(“泄漏”) subplot(1,2,2) idx =标签==“机械故障”;wordcloud (textData (idx),“颜色”,“红色”);标题(“机械故障”)

将报告中的词语与紧急情况“Low”、“Medium”和“High”进行比较。

figure urgent = tbl. urgent;subplot(1,3,1) idx = urgent ==“低”;wordcloud (textData (idx));标题(“紧迫性:低”) (1,3,2) idx = emergency ==“媒介”;wordcloud (textData (idx));标题(“紧迫性:媒介”) (1,3,3) idx = emergency ==“高”;wordcloud (textData (idx));标题(“紧迫性:高”)

将报告中以数百美元报告的成本与以数千美元报告的成本进行比较。分别用突出显示的蓝色和红色为这些数字创建报表的单词云。

成本= tbl.Cost;idx =成本> 100;图wordcloud (textData (idx),“HighlightColor”,“蓝”);标题(“成本> 100美元”)

idx =成本> 1000;图wordcloud (textData (idx),“HighlightColor”,“红色”);标题(“成本> 1000美元”)

另请参阅

||

相关的话题