使用scikit-learn load_files加载文件

时间:2017-12-19 20:56:34

标签: python scikit-learn

我下载了20 newsgroup tar file并将其解压缩。我将load_files函数指向列车文件,但我一直收到错误:

Traceback (most recent call last):
  File "D:\Python\DataScience\t.py", line 14, in <module>
    data=load_files("\dataSet\20news-bydate\20news-bydate-train")
  File "C:\Users\Khoa\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\datasets\base.py", line 166, in load_files
    folders = [f for f in sorted(listdir(container_path))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\dataSet\x10news-bydate\x10news-bydate-train'

这是我的代码:

data=load_files("\dataSet\20news-bydate\20news-bydate-train")

你能告诉我正确的代码吗?

1 个答案:

答案 0 :(得分:0)

在我看来,你需要删除前面的“\”。

data = load_files('dataSet\2020news-bydate\20news-bydate-train')