Dav*_*vid 16 scikits scikit-learn
在大多数Scikit-learn算法中,数据必须作为Bunch对象加载.对于教程中的许多示例,load_files()或其他函数用于填充Bunch对象.像load_files()这样的函数希望数据以某种格式存在,但我有以不同格式存储的数据,即每个字段都包含字符串的CSV文件.
如何解析此并以Bunch对象格式加载数据?
Hug*_*ins 22
你可以这样做:
import numpy as np
import sklearn.datasets
examples = []
examples.append('some text')
examples.append('another example text')
examples.append('example 3')
target = np.zeros((3,), dtype=np.int64)
target[0] = 0
target[1] = 1
target[2] = 0
dataset = sklearn.datasets.base.Bunch(data=examples, target=target)
Run Code Online (Sandbox Code Playgroud)
ogr*_*sel 16
您不必创建Bunch对象.它们仅用于加载scikit-learn的内部样本数据集.
您可以直接将Python字符串列表提供给vectorizer对象.
| 归档时间: |
|
| 查看次数: |
13532 次 |
| 最近记录: |