资源简介
在windows下通过编译并运行成功
代码片段和文件信息
/******************************************************************************
* ONLINE SUPPORT VECTOR REGRESSION *
* Copyright 2006 - Francesco Parrella *
* *
*This program is distributed under the terms of the GNU General Public License*
******************************************************************************/
#ifndef CROSS_VALIDATION_CPP
#define CROSS_VALIDATION_CPP
#include “OnlineSVR.h“
#include
#include
#include
namespace onlinesvr
{
void OnlineSVR::CrossValidation (Matrix* TrainingSetX Vector* TrainingSetY Vector* EpsilonList Vector* CList Vector* KernelParamList int SetNumber char* ResultsFileName)
{
int i j k;
// Partition of the training set
int SamplesPerSet = static_cast(TrainingSetX->GetLengthRows()/SetNumber);
// Build the Sets
Vector*>* SetX = new Vector*>();
Vector*>* SetY = new Vector*>();
for (i=0; i SetX->Add(new Matrix());
SetY->Add(new Vector());
for (j=0; j SetX->GetValue(i)->AddRowCopy(TrainingSetX->GetRowRef(j*SetNumber+i));
SetY->GetValue(i)->Add(TrainingSetY->GetValue(j*SetNumber+i));
}
}
// Open the file
ofstream File (ResultsFileName ios::out);
if (!File) {
cerr << “Error. It‘s impossible to create the file.“ << endl;
return;
}
File << “Epsilon \t C \t KernelParam \t Error“ << endl;
// Cross Validation
int IterationsNumber = EpsilonList->GetLength() * CList->GetLength() * KernelParamList->GetLength();
int CurrentIteration = 0;
double MinError = 10000;
double MinEpsilon = 0;
double MinC = 0;
double MinKernelParam = 0;
for (i=0; iGetLength(); i++) {
for (j=0; jGetLength(); j++) {
for (k=0; kGetLength(); k++) {
if(1==0)//if (CurrentIteration==33 || CurrentIteration==34 || CurrentIteration==42)
{CurrentIteration++; printf(“%d\n“CurrentIteration);}
else {
double Error = CrossValidation (SetX SetY EpsilonList->GetValue(i) CList->GetValue(j) KernelParamList->GetValue(k));
File << EpsilonList->GetValue(i) << “\t“ << CList->GetValue(j) << “\t“ << KernelParamList->GetValue(k) << “ \t“ << Error << endl;
cout << “Test “ << ++CurrentIteration << “/“ << IterationsNumber << “\t“ << “Epsilon=“ << EpsilonList->GetValue(i) << “\t“ << “C=“ << CList->GetValue(j) << “\t“ << “KernelParam=“ << KernelParamList->GetValue(k) << “ \t“ << “Error=“ << Error << endl;
if (Error MinError = Error;
MinEpsilon = EpsilonList->GetValue(i);
MinC = CList->GetValue(j);
MinKernelParam = KernelParamList->GetValue(k);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7542 2006-12-01 16:29 OnlineSVR C++ Code\CrossValidation.cpp
文件 1979 2006-12-01 23:06 OnlineSVR C++ Code\Example.cpp
文件 10659 2007-06-11 19:40 OnlineSVR C++ Code\File.cpp
文件 5537 2007-06-11 19:37 OnlineSVR C++ Code\Forget.cpp
文件 18326 2006-12-01 15:47 OnlineSVR C++ Code\GPL.txt
文件 2202 2006-12-01 16:29 OnlineSVR C++ Code\Kernel.cpp
文件 13079 2007-06-01 15:24 OnlineSVR C++ Code\Main.cpp
文件 785 2006-12-01 11:21 OnlineSVR C++ Code\makefile
文件 18796 2007-06-11 01:26 OnlineSVR C++ Code\Matrix.h
文件 16119 2007-06-11 01:42 OnlineSVR C++ Code\OnlineSVR.cpp
文件 9454 2007-06-09 15:47 OnlineSVR C++ Code\OnlineSVR.h
文件 10944 2007-06-11 01:35 OnlineSVR C++ Code\Show.cpp
文件 6546 2007-06-11 19:36 OnlineSVR C++ Code\Stabilize.cpp
文件 9357 2007-06-11 19:37 OnlineSVR C++ Code\Train.cpp
文件 21018 2007-06-13 11:44 OnlineSVR C++ Code\Variations.cpp
文件 17440 2007-06-11 19:20 OnlineSVR C++ Code\Vector.h
- 上一篇:c语言课程设计 工资管理系统
- 下一篇:C语言编写的前方交会代码
评论
共有 条评论