【机器学习】libsvm使用的数据格式
2008-11-06 22:29
477 查看
该软件使用的训练数据和检验数据文件格式如下:
<label> <index1>:<value1> <index2>:<value2> ...
其中<label> 是训练数据集的目标值,对于分类,它是标识某类的整数(支持多个类);对于回归,是任意实数。<index> 是以1开始的整数,可以是不连续的;<value>为实数,也就是我们常说的自变量。检验数据文件中的label只用于计算准确度或误差,如果它是未知的,只需用一个数填写这一栏,也可以空着不填。在程序包中,还包括有一个训练数据实例:heart_scale,方便参考数据文件格式以及练习使用软件。
在NET.SVM中,Node和Problem类提供此项功能。如果说我要定义如下数据集:
+1 1:0.708333 2:1 3:1 4:-0.320755
-1 1:0.583333 2:-1 3:0.333333 4:-0.603774
+1 1:0.166667 2:1 3:-0.333333 4:-0.433962
-1 1:0.458333 2:1 3:1 4:-0.358491
可以先定义X的矩阵:private Node[][] _X;一组Y的数组private double[] _Y;然后再分别给_X和_Y赋值;
当然,也可以用Problem类提供的方法来Read(Stream)和Read(String)来将数据直接读取到Problem中去。
Class Node
Class Problem
<label> <index1>:<value1> <index2>:<value2> ...
其中<label> 是训练数据集的目标值,对于分类,它是标识某类的整数(支持多个类);对于回归,是任意实数。<index> 是以1开始的整数,可以是不连续的;<value>为实数,也就是我们常说的自变量。检验数据文件中的label只用于计算准确度或误差,如果它是未知的,只需用一个数填写这一栏,也可以空着不填。在程序包中,还包括有一个训练数据实例:heart_scale,方便参考数据文件格式以及练习使用软件。
在NET.SVM中,Node和Problem类提供此项功能。如果说我要定义如下数据集:
+1 1:0.708333 2:1 3:1 4:-0.320755
-1 1:0.583333 2:-1 3:0.333333 4:-0.603774
+1 1:0.166667 2:1 3:-0.333333 4:-0.433962
-1 1:0.458333 2:1 3:1 4:-0.358491
可以先定义X的矩阵:private Node[][] _X;一组Y的数组private double[] _Y;然后再分别给_X和_Y赋值;
当然,也可以用Problem类提供的方法来Read(Stream)和Read(String)来将数据直接读取到Problem中去。
Class Node
Member | Description |
Node()()() | Default Constructor. |
Node(Int32, Double) | Constructor. |
CompareTo(Node) | Compares this node with another. |
Equals(Object) | (Inherited from Object.) |
Finalize()()() | (Inherited from Object.) |
GetHashCode()()() | (Inherited from Object.) |
GetType()()() | (Inherited from Object.) |
Index | Index of this Node. |
MemberwiseClone()()() | (Inherited from Object.) |
ToString()()() | String representation of this Node as {index}:{value}. (Overrides Object.ToString()()().) |
Value | Value at Index. |
Member | Description |
Problem(Int32, array<Double>[]()[], array<array<Node>[]()[]>[]()[], Int32) | Constructor. |
Problem()()() | Empty Constructor. Nothing is initialized. |
Count | Number of vectors. |
Equals(Object) | (Inherited from Object.) |
Finalize()()() | (Inherited from Object.) |
GetHashCode()()() | (Inherited from Object.) |
GetType()()() | (Inherited from Object.) |
MaxIndex | Maximum index for a vector. |
MemberwiseClone()()() | (Inherited from Object.) |
Read(Stream) | Reads a problem from a stream. |
Read(String) | Reads a Problem from a file. |
ToString()()() | (Inherited from Object.) |
Write(Stream, Problem) | Writes a problem to a stream. |
Write(String, Problem) | Writes a problem to a file. This will overwrite any previous data in the file. |
X | Vector data. |
Y | Class labels. |
相关文章推荐
- 生成libSVM的数据格式及使用方法总结
- 生成libSVM的数据格式及使用方法
- LIBSVM数据格式及其使用
- libsvm——数据格式的转换及使用
- 生成libSVM的数据格式及使用方法
- 生成libSVM的数据格式及使用方法总结
- 将UCI数据、Matlab数据转变为LIBSVM使用数据格式的程序
- C++生成libsvm训练使用数据文件格式
- 生成libSVM的数据格式及使用方法总结
- 使用python生成libSVM的数据格式
- Ajax使用JSON数据格式
- ASP.NET设置数据格式与String.Format使用总结
- 使用TextView在固定的格式中插入数据
- 在.NET使用JSON作为数据交换格式(转载)
- 在.NET使用JSON作为数据交换格式
- 使用Struts2写的接口实现接收json格式的数据
- 使用JDBC获取数据库数据,并生成json格式文件(省市区三级联动)
- sl3中的DataGrid中的数据导出到Excel中 使用csv格式 解决中文是乱码的问题
- [转]Angular2 使用管道Pipe以及自定义管道格式数据
- mybatis 处理数组类型及使用Json格式保存数据 JsonTypeHandler and ArrayTypeHandler