Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
examples
Benchmark
shark
kernel_csvm.cpp
Go to the documentation of this file.
1
#include <
shark/Data/SparseData.h
>
2
#include <
shark/ObjectiveFunctions/Loss/ZeroOneLoss.h
>
3
#include <
shark/Algorithms/Trainers/CSvmTrainer.h
>
4
#include <
shark/Models/Kernels/GaussianRbfKernel.h
>
5
6
#include <
shark/Core/Timer.h
>
7
#include <iostream>
8
using namespace
shark
;
9
using namespace
std;
10
11
int
main
(
int
argc,
char
**argv) {
12
LabeledData<RealVector,unsigned int>
data;
13
importSparseData
(data,
"cod-rna"
,0,8192);
14
15
GaussianRbfKernel<>
kernel(1.0);
16
for
(
double
C = 0.01; C <= 1; C*=10){
17
KernelClassifier<RealVector>
model;
18
CSvmTrainer<RealVector>
trainer(&kernel,C,
true
);
19
20
Timer
time;
21
trainer.
train
(model, data);
22
double
time_taken = time.
stop
();
23
24
ZeroOneLoss<>
loss;
25
cout << C <<
" "
<< time_taken <<
" "
<< loss(data.
labels
(),model(data.
inputs
()))<<std::endl;
26
}
27
}