Shark machine learning library
About Shark
News!
Contribute
Credits and copyright
Downloads
Getting Started
Installation
Using the docs
Documentation
Tutorials
Quick references
Class list
Global functions
FAQ
Showroom
include
shark
Data
Libsvm.h
Go to the documentation of this file.
1
//===========================================================================
2
/*!
3
*
4
*
5
* \brief Deprecated import_libsvm and export_libsvm functions.
6
*
7
*
8
* \deprecated This file is provided for backwards compatibility. Its is deprecated, use SparseData.h for new projects.
9
*
10
*
11
*
12
*
13
* \author T. Glasmachers
14
* \date 2014
15
*
16
*
17
* \par Copyright 1995-2017 Shark Development Team
18
*
19
* <BR><HR>
20
* This file is part of Shark.
21
* <http://shark-ml.org/>
22
*
23
* Shark is free software: you can redistribute it and/or modify
24
* it under the terms of the GNU Lesser General Public License as published
25
* by the Free Software Foundation, either version 3 of the License, or
26
* (at your option) any later version.
27
*
28
* Shark is distributed in the hope that it will be useful,
29
* but WITHOUT ANY WARRANTY; without even the implied warranty of
30
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
* GNU Lesser General Public License for more details.
32
*
33
* You should have received a copy of the GNU Lesser General Public License
34
* along with Shark. If not, see <http://www.gnu.org/licenses/>.
35
*
36
*/
37
//===========================================================================
38
39
#ifndef SHARK_DATA_LIBSVM_H
40
#define SHARK_DATA_LIBSVM_H
41
#include <
shark/Data/SparseData.h
>
42
43
namespace
shark
{
44
45
/**
46
* \ingroup shark_globals
47
*
48
* @{
49
*/
50
51
/// \brief Import data from a LIBSVM file.
52
///
53
/// \deprecated use importSparseData instead
54
///
55
/// \param dataset container storing the loaded data
56
/// \param stream stream to be read from
57
/// \param highestIndex highest feature index, or 0 for auto-detection
58
/// \param batchSize size of batch
59
inline
void
import_libsvm
(
60
LabeledData<RealVector, unsigned int>
& dataset,
61
std::istream& stream,
62
unsigned
int
highestIndex = 0,
63
std::size_t
batchSize
=
LabeledData<RealVector, unsigned int>::DefaultBatchSize
64
)
65
{
importSparseData
(dataset, stream, highestIndex,
batchSize
); }
66
67
/// \brief Import data from a LIBSVM file.
68
///
69
/// \deprecated use importSparseData instead
70
///
71
/// \param dataset container storing the loaded data
72
/// \param stream stream to be read from
73
/// \param highestIndex highest feature index, or 0 for auto-detection
74
/// \param batchSize size of batch
75
inline
void
import_libsvm
(
76
LabeledData<CompressedRealVector, unsigned int>
& dataset,
77
std::istream& stream,
78
unsigned
int
highestIndex = 0,
79
std::size_t
batchSize
=
LabeledData<RealVector, unsigned int>::DefaultBatchSize
80
)
81
{
importSparseData
(dataset, stream, highestIndex,
batchSize
); }
82
83
/// \brief Import data from a LIBSVM file.
84
///
85
/// \deprecated use importSparseData instead
86
///
87
/// \param dataset container storing the loaded data
88
/// \param fn the file to be read from
89
/// \param highestIndex highest feature index, or 0 for auto-detection
90
/// \param batchSize size of batch
91
inline
void
import_libsvm
(
92
LabeledData<RealVector, unsigned int>
& dataset,
93
std::string fn,
94
unsigned
int
highestIndex = 0,
95
std::size_t
batchSize
=
LabeledData<RealVector, unsigned int>::DefaultBatchSize
96
)
97
{
importSparseData
(dataset, fn, highestIndex,
batchSize
); }
98
99
/// \brief Import data from a LIBSVM file.
100
///
101
/// \deprecated use importSparseData instead
102
///
103
/// \param dataset container storing the loaded data
104
/// \param fn the file to be read from
105
/// \param highestIndex highest feature index, or 0 for auto-detection
106
/// \param batchSize size of batch
107
inline
void
import_libsvm
(
108
LabeledData<CompressedRealVector, unsigned int>
& dataset,
109
std::string fn,
110
unsigned
int
highestIndex = 0,
111
std::size_t
batchSize
=
LabeledData<RealVector, unsigned int>::DefaultBatchSize
112
)
113
{
importSparseData
(dataset, fn, highestIndex,
batchSize
); }
114
115
116
/// \brief Export data to LIBSVM format.
117
///
118
/// \deprecated use exportSparseData instead
119
///
120
/// \param dataset Container storing the data
121
/// \param fn Output file
122
/// \param dense Flag for using dense output format
123
/// \param oneMinusOne Flag for applying the transformation y<-2y-1 to binary labels
124
/// \param sortLabels Flag for sorting data points according to labels
125
/// \param append Flag for appending to the output file instead of overwriting it
126
template
<
typename
InputType>
127
inline
void
export_libsvm
(
LabeledData<InputType, unsigned int>
& dataset,
const
std::string &fn,
bool
dense=
false
,
bool
oneMinusOne =
true
,
bool
sortLabels =
false
,
bool
append =
false
) {
128
exportSparseData
(dataset, fn, dense, oneMinusOne, sortLabels, append);
129
}
130
131
/** @}*/
132
133
}
134
#endif