测试环境:
anaconda3+python3.8
texthero==1.1.0
测试代码来自官方:https://github.com/jbesomi/texthero
代码:
import texthero as hero
import pandas as pd
df = pd.read_csv(
"https://gitee.com/FIRC/texthero/raw/master/dataset/bbcsport.csv"
)
df['pca'] = (
df['text']
.pipe(hero.clean)
.pipe(hero.tfidf)
.pipe(hero.pca)
)
hero.scatterplot(df, 'pca', color='topic', title="PCA BBC Sport news")
显示结果: