Shark machine learning library
Installation
Tutorials
Benchmarks
Documentation
Quick references
Class list
Global functions
examples
Benchmark
shark
linear_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
5
#include <
shark/Core/Timer.h
>
6
#include <iostream>
7
using namespace
shark
;
8
using namespace
std;
9
10
int
main
(
int
argc,
char
**argv) {
11
LabeledData<CompressedRealVector,unsigned int>
data_sparse;
12
importSparseData
(data_sparse,
"rcv1_train.binary"
,0,8192);
13
14
for
(
double
C = 1; C <= 100000; C*=10){
15
LinearClassifier<CompressedRealVector>
model;
16
LinearCSvmTrainer<CompressedRealVector>
trainer(C,
true
);
17
18
Timer
time;
19
trainer.
train
(model, data_sparse);
20
double
time_taken = time.
stop
();
21
22
ZeroOneLoss<>
loss;
23
cout << C <<
" "
<< time_taken <<
" "
<< loss(data_sparse.
labels
(),model(data_sparse.
inputs
()))<<std::endl;
24
}
25
}