LIBIRWLS
IOStructures.h
Go to the documentation of this file.
1 /*
2  ============================================================================
3  Author : Roberto Diaz Morales
4  ============================================================================
5 
6  Copyright (c) 2016 Roberto Díaz Morales
7 
8  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
9  (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
10  publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
11  subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 
20  ============================================================================
21  */
22 
33 #ifndef IOSTRUCTURES_
34 #define IOSTRUCTURES_
35 
36 #include <stdio.h>
37 
44 typedef struct properties{
45  double Kgamma;
46  int kernelType;
47  double C;
48  int Threads;
49  int MaxSize;
50  int size;
51  int algorithm;
52  double Eta;
53  int file;
54  char *separator;
55  int verbose;
56 }properties;
57 
58 
65 typedef struct predictProperties{
66  int Labels;
67  int Threads;
68  int Soft;
69  int file;
70  char *separator;
71  int verbose;
73 
74 
81 typedef struct model{
82  double Kgamma;
83  int kernelType;
84  int sparse;
85  int nSVs;
86  int nElem;
87  double *weights;
88  struct svm_sample **x;
89  double *quadratic_value;
90  int maxdim;
91  double bias;
92  struct svm_sample* features;
93 }model;
94 
95 
102 typedef struct svm_sample{
103  int index;
104  double value;
105 }svm_sample;
106 
107 
114 typedef struct svm_dataset{
115  int l;
116  int sparse;
117  int maxdim;
118  double *y;
119  struct svm_sample **x;
120  double *quadratic_value;
122 }svm_dataset;
123 
131 void freeDataset (svm_dataset data);
132 
140 void freeModel (model modelo);
141 
155 svm_dataset readTrainFile(char filename[]);
156 
171 svm_dataset readTrainFileCSV(char filename[],char* separator);
172 
187 svm_dataset readUnlabeledFile(char filename[]);
188 
189 
205 svm_dataset readUnlabeledFileCSV(char filename[],char* separator);
206 
207 
216 void storeModel(model * mod, FILE *Output);
217 
226 void readModel(model * mod, FILE *Input);
227 
228 
238 void writeOutput (char fileoutput[], double *predictions, int size);
239 
240 #endif
241 
struct model model
It represents a trained model that has been obtained using PIRWLS or PSIRWLS.
double * quadratic_value
Definition: IOStructures.h:120
double * quadratic_value
Definition: IOStructures.h:89
double Eta
Definition: IOStructures.h:52
int kernelType
Definition: IOStructures.h:83
A dataset.
Definition: IOStructures.h:114
int nElem
Definition: IOStructures.h:86
int kernelType
Definition: IOStructures.h:46
int index
Definition: IOStructures.h:103
void freeModel(model modelo)
Free model memory.
double * weights
Definition: IOStructures.h:87
int l
Definition: IOStructures.h:115
double bias
Definition: IOStructures.h:91
char * separator
Definition: IOStructures.h:54
struct properties properties
Training parameters of the IRWLS procedures.
It represents a trained model that has been obtained using PIRWLS or PSIRWLS.
Definition: IOStructures.h:81
int Soft
Definition: IOStructures.h:68
int nSVs
Definition: IOStructures.h:85
int algorithm
Definition: IOStructures.h:51
void writeOutput(char fileoutput[], double *predictions, int size)
It writes the content of a double array into a file.
double * y
Definition: IOStructures.h:118
struct svm_dataset svm_dataset
A dataset.
struct svm_sample ** x
Definition: IOStructures.h:119
double Kgamma
Definition: IOStructures.h:45
struct svm_sample * features
Definition: IOStructures.h:92
struct predictProperties predictProperties
Testing parameters of the IRWLS procedures.
int verbose
Definition: IOStructures.h:55
double value
Definition: IOStructures.h:104
int maxdim
Definition: IOStructures.h:117
Training parameters of the IRWLS procedures.
Definition: IOStructures.h:44
int maxdim
Definition: IOStructures.h:90
int sparse
Definition: IOStructures.h:116
struct svm_sample svm_sample
A single feature of a data.
void freeDataset(svm_dataset data)
Free dataset memory.
double C
Definition: IOStructures.h:47
struct svm_sample ** x
Definition: IOStructures.h:88
int Labels
Definition: IOStructures.h:66
int sparse
Definition: IOStructures.h:84
int file
Definition: IOStructures.h:69
int Threads
Definition: IOStructures.h:67
svm_dataset readTrainFile(char filename[])
It reads a file that contains a labeled dataset in libsvm format.
struct svm_sample * features
Definition: IOStructures.h:121
Testing parameters of the IRWLS procedures.
Definition: IOStructures.h:65
void storeModel(model *mod, FILE *Output)
It stores a trained model into a file.
char * separator
Definition: IOStructures.h:70
A single feature of a data.
Definition: IOStructures.h:102
int size
Definition: IOStructures.h:50
double Kgamma
Definition: IOStructures.h:82
svm_dataset readUnlabeledFileCSV(char filename[], char *separator)
It reads a file that contains an unlabeled dataset in CSV format.
void readModel(model *mod, FILE *Input)
It loads a trained model from a file.
int Threads
Definition: IOStructures.h:48
int MaxSize
Definition: IOStructures.h:49
int file
Definition: IOStructures.h:53
svm_dataset readTrainFileCSV(char filename[], char *separator)
It reads a file that contains a labeled dataset in CSV format.
int verbose
Definition: IOStructures.h:71
svm_dataset readUnlabeledFile(char filename[])
It reads a file that contains an unlabeled dataset in libsvm format.