python(针对文本分类问题的sciket学习)

2024-09-30 18:16:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到以下错误:

 File "<ipython-input-2-c2b8a0449401>", line 3
    news_train = skd.load_files('C:\Users\ahmir\Downloads\Compressed\SkdLearnDataSet\20news-bydate-train',
                               ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

运行此代码时:

import sklearn.datasets as skd
categories = ['alt.atheism', 'soc.religion.christian','comp.graphics', 'sci.med']
news_train = skd.load_files('C:\Users\ahmir\Downloads\Compressed\SkdLearnDataSet\20news-bydate-train', 
                            categories= categories, encoding= 'UTF-8')
news_test = skd.load_files('C:\Users\ahmir\Downloads\Compressed\SkdLearnDataSet\20news-bydate-test',categories= categories, encoding= 'ISO-8859-1')

Tags: testdownloads错误loadtrainfilescompressedusers