简体   繁体   English

使用具有最佳C和Gamma的libsvm训练数据

[英]train data using libsvm with best C and Gamma

Hi I'm using libsvm (in VS2010) for training my data , I scaled the input and output data successfully using svm-scale.c and my data is ready to be trained ... 嗨,我正在使用libsvm(在VS2010中)来训练我的数据,我使用svm-scale.c成功地缩放了输入和输出数据,并且我的数据已准备好进行训练...

Now I have two problems: 现在我有两个问题:

1). 1)。

as I've read from LIBSVM documentation I realized that first I need to train my scaled data and obtain a model. 正如我从LIBSVM文档中读取的那样,我意识到首先需要训练缩放后的数据并获得模型。 then use this model for predicting the final result but the problem is when I want to train my system I don't know what is the best choose for my model parameters and specifically (C,g) for training my data !!!. 然后使用该模型预测最终结果,但是问题是当我想训练我的系统时,我不知道什么是我的模型参数的最佳选择,特别是(C,g)来训练我的数据! what I do is that first I load my scaled data, then by using a svm_problem I fill svm_nodes with my train data then call this function : 我要做的是首先加载缩放后的数据,然后使用svm_problem将火车数据填充到svm_nodes,然后调用此函数:

struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param ); struct svm_model * svm_train(const struct svm_problem * prob, const struct svm_parameter * param );

2). 2)。 Also I'm not sure about the correct function calling of libsvm functions -> I mean I first use svm_train and then svm_predict to see the result , and I don't know if I should call sth else or not ?! 另外我不确定libsvm函数的正确函数调用->我的意思是我先使用svm_train然后使用svm_predict查看结果,而且我不知道是否应该调用sth吗?

Model = svm_train(My_data,My_param); 型号= svm_train(My_data,My_param); //I don't know how to fill my_param //我不知道如何填写my_param

svm_node Test_Vector = svm_scale_data(x); svm_node Test_Vector = svm_scale_data(x); //using the same algorithm as scaled_training data //使用与scaled_training数据相同的算法

double result = svm_predict(Model,Test_Vector); 双重结果= svm_predict(Model,Test_Vector);

Thanks 谢谢

If you want to call LIBSVM via C++, you can optimize parameters by letting LIBSVM do cross-validation internally. 如果要通过C ++调用LIBSVM,则可以通过让LIBSVM在内部进行交叉验证来优化参数。 When doing so, you just need to loop over the parameter tuples (C, gamma) you want to test and let LIBSVM perform cross-validation instead of proper training. 这样做时,您只需要遍历要测试的参数元组(C,gamma),并让LIBSVM执行交叉验证而不是进行适当的训练。

You can get LIBSVM to perform cross-validation with the following API function: 您可以使用以下API函数使LIBSVM执行交叉验证:

void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);

To answer your other question: yes, it is perfectly fine to call svm_train() followed by svm_predict() . 为了回答您的其他问题:是的,这是完全正常的调用svm_train()然后svm_predict()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在libsvm中训练不平衡数据 - training unbalanced data in libsvm 在Visual Studio 2010上使用LIBSVM - Using LIBSVM on Visual studio 2010 使用C#Intellisense注释的最佳实践 - Best Practices on using C# Intellisense Comments 保存数据的最佳方法:: Visual C#2010 - Best Way To Save Data::Visual C# 2010 在Visual Studio 2010 C#测试项目中使用测试文件/目录的最佳实践 - Best practice for using test files/directory in Visual Studio 2010 C# test projects 在Visual Studio中使用C ++创建Windows窗体应用程序时的最佳线程化方法是什么? - What is the best way of threading while using c++ to create windows form application in visual studio? 使用Visual Studio 2010数据库项目填充静态数据的最佳实践? - Best practice to populate static data using a Visual Studio 2010 database project? 使用源控件时处理敏感数据的最佳方法是什么? - What's the best way to deal with sensitve data while using a source control? 使用SqlCommand的最佳实践 - Best practices for using SqlCommand 无法使用C ++中的Windows服务检索可移动设备上的数据 - Unable to retrieve data on a removable device using a Windows service in C++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM