如何在libsvm中创建用于训练和测试文件的源数据文件? [英] How to create source data file for training and testing file in libsvm?
问题描述
我想使用数据集来训练模型.数据集具有三种不同类型的生理数据.类型1,类型2和类型3.libSVM的格式如下: 标签index1:value1 index2:value2 ....
I want to use a dataset to train a model. The dataset has three different types of physiological data. type 1, type 2 and type 3. The format of the libSVM is as below: label index1:value1 index2:value2....
现在,我将类型1的标签设为1,将类型2的标签设为2,将类型3的标签设为3.其中,所有值都另存为1:(value).因此,我的培训和测试文件如下.
Now, I have taken label as 1 for type 1, 2 for type 2 and 3 for type 3. Where as all the values are save as 1:(value). So, my training and testing file is as below.
1 1:值\ n 1 1:值\ n 1 1:值\ n 1 1:值\ n 1 1:值\ n . . . 1 1:值\ n 2 1:值\ n 2 1:值\ n 2 1:值\ n 2 1:值\ n 2 1:值\ n . . . 2 1:值\ n 3 1:值\ n 3 1:值\ n 3 1:值\ n 3 1:值\ n . . . 3 1:值\ n
1 1:value \n 1 1:value \n 1 1:value \n 1 1:value \n 1 1:value \n . . . 1 1:value \n 2 1:value \n 2 1:value \n 2 1:value \n 2 1:value \n 2 1:value \n . . . 2 1:value \n 3 1:value \n 3 1:value \n 3 1:value \n 3 1:value \n . . . 3 1:value \n
因此,我正在用这种源文件训练svm并使用类似类型的源文件进行测试.我想确定我是否正确使用了SVM数据格式.谢谢
So, I am traing the svm with this kind of source file and testing with similar kind of source file. I want to make sure if I am using the SVM data format correctly. Thank you
推荐答案
Thus, every feature (or value) needs is own unique identifier.
示例:
想象一下,您有三个不同的类标签1,2,3
和一个由a(id=1),b(id=2),c=(id=3)
组成的特征集,这些特征集是通过特征选择机制获得的.
Imagine you have three different class labels 1,2,3
and a feature set consisting of a(id=1),b(id=2),c=(id=3)
, which was obtained via feature selection mechanism.
因此,假设我们有三个数据点d1,d2,d3
,我们想要在数据集中进行描述,例如:
So let's say, that we have three datapoints d1,d2,d3
, we want to describe in our dataset, it would be for example:
2 1:0.5325 3:0.523
3 2:0.7853 3:0.6326
1 1:0.53265 2:0.5422
含义:
-
d1
包含功能a(id=1)
和c(id=3)
-
d2
包含功能b(id=2)
和c(id=3)
-
d3
包含功能a(id=1)
和b(id=2)
d1
contains featurea(id=1)
andc(id=3)
d2
contains featureb(id=2)
andc(id=3)
d3
contains featurea(id=1)
andb(id=2)
请注意,没有必要为未包含在给定数据点中的要素提供feature_id1:feature_value1
.
Note, that it is not necessary to provide feature_id1:feature_value1
for features, which are not contained in the given datapoint.
这篇关于如何在libsvm中创建用于训练和测试文件的源数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!