GenSVM
|
Header file for gensvm_io.c. More...
Go to the source code of this file.
Functions | |
void | gensvm_read_data (struct GenData *dataset, char *data_file) |
Read data from file. More... | |
void | gensvm_read_data_libsvm (struct GenData *dataset, char *data_file) |
Read data from a file in LibSVM/SVMlight format. More... | |
void | gensvm_read_model (struct GenModel *model, char *model_filename) |
Read model from file. More... | |
void | gensvm_write_model (struct GenModel *model, char *output_filename) |
Write model to file. More... | |
void | gensvm_write_predictions (struct GenData *data, long *predy, char *output_filename) |
Write predictions to file. More... | |
void | gensvm_time_string (char *buffer) |
Get time string with UTC offset. More... | |
Header file for gensvm_io.c.
Function declarations for input/output functions.
This file is part of GenSVM.
GenSVM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GenSVM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GenSVM. If not, see http://www.gnu.org/licenses/.
Definition in file gensvm_io.h.
void gensvm_read_data | ( | struct GenData * | dataset, |
char * | data_file | ||
) |
Read data from file.
Read the data from the data_file. The data matrix X is augmented with a column of ones, to get the matrix Z. The data is expected to follow a specific format, which is specified in the Default Data File Specification. The class labels are assumed to be in the interval [1 .. K], which can be checked using the function gensvm_check_outcome_contiguous().
[in,out] | dataset | initialized GenData struct |
[in] | data_file | filename of the data file. |
Definition at line 47 of file gensvm_io.c.
void gensvm_read_data_libsvm | ( | struct GenData * | data, |
char * | data_file | ||
) |
Read data from a file in LibSVM/SVMlight format.
This function reads data from a file where the data is stored in LibSVM/SVMlight format. The file format is described in LibSVM/SVMlight Data File Specification. This is a sparse data format, which can be beneficial for certain applications. The advantage of having this function here is twofold: 1) existing datasets where data is stored in LibSVM/SVMlight format can be easily used in GenSVM, and 2) sparse datasets which are too large for memory when kept in dense format can be loaded efficiently into GenSVM.
[in] | data | GenData structure |
[in] | data_file | filename of the datafile |
Definition at line 178 of file gensvm_io.c.
void gensvm_read_model | ( | struct GenModel * | model, |
char * | model_filename | ||
) |
Read model from file.
Read a GenModel from a model file. The GenModel struct must have been initalized elswhere. The model file is expected to follow the Model File Specification. The easiest way to generate a model file is through gensvm_write_model(), which can for instance be used in trainGenSVM.c.
[in,out] | model | initialized GenModel |
[in] | model_filename | filename of the model file |
Definition at line 410 of file gensvm_io.c.
void gensvm_time_string | ( | char * | buffer | ) |
Get time string with UTC offset.
Create a string for the current system time. Include an offset of UTC for consistency. The format of the generated string is "DDD MMM D HH:MM:SS YYYY (UTC +HH:MM)", e.g. "Fri Aug 9, 12:34:56 2013 (UTC +02:00)".
[in,out] | buffer | allocated string buffer, on exit contains formatted string |
Definition at line 596 of file gensvm_io.c.
void gensvm_write_model | ( | struct GenModel * | model, |
char * | output_filename | ||
) |
Write model to file.
Write a GenModel to a file. The current time is specified in the file in UTC + offset. The model file further corresponds to the Model File Specification.
[in] | model | GenModel which contains an estimate for GenModel::V |
[in] | output_filename | the output file to write the model to |
Definition at line 494 of file gensvm_io.c.
void gensvm_write_predictions | ( | struct GenData * | data, |
long * | predy, | ||
char * | output_filename | ||
) |
Write predictions to file.
Write the given predictions to an output file, such that the resulting file corresponds to the Default Data File Specification.
[in] | data | GenData with the original instances |
[in] | predy | predictions of the class labels of the instances in the given GenData. Note that the order of the instances is assumed to be the same. |
[in] | output_filename | the file to which the predictions are written |
Definition at line 556 of file gensvm_io.c.