DiSMEC++
dismec::io::prediction Namespace Reference

Functions

void save_sparse_predictions (const path &target, const PredictionMatrix &values, const IndexMatrix &indices)
 Saves sparse predictions as a text file. More...
 
void save_sparse_predictions (std::ostream &target, const PredictionMatrix &values, const IndexMatrix &indices)
 Saves sparse predictions as a text file. More...
 
std::pair< IndexMatrix, PredictionMatrixread_sparse_prediction (std::istream &source)
 Reads sparse predictions as saved by save_sparse_predictions(). More...
 
std::pair< IndexMatrix, PredictionMatrixread_sparse_prediction (const path &source)
 Reads sparse predictions as saved by save_sparse_predictions(). More...
 
void save_dense_predictions_as_txt (const path &target, const PredictionMatrix &values)
 Saves predictions as a dense txt matrix. More...
 
void save_dense_predictions_as_txt (std::ostream &target, const PredictionMatrix &values)
 Saves predictions as a dense txt matrix. More...
 
void save_dense_predictions_as_npy (const path &target, const PredictionMatrix &values)
 Saves predictions as a dense npy file. More...
 
void save_dense_predictions_as_npy (std::ostream &target, const PredictionMatrix &values)
 Saves predictions as a dense npy file. More...
 

Function Documentation

◆ read_sparse_prediction() [1/2]

std::pair<IndexMatrix, PredictionMatrix> dismec::io::prediction::read_sparse_prediction ( const path &  source)

Reads sparse predictions as saved by save_sparse_predictions().

Parameters
sourceThe stream from which the data is read. The first line is expected the header that contains the number of instances and predictions, followed by the prediction of one instance each line.
Todo:
document this format and provide a link.
Returns
A pair that contains the indices and the corresponding scores.

◆ read_sparse_prediction() [2/2]

std::pair<IndexMatrix, PredictionMatrix> dismec::io::prediction::read_sparse_prediction ( std::istream &  source)

Reads sparse predictions as saved by save_sparse_predictions().

Parameters
sourceThe stream from which the data is read. The first line is expected the header that contains the number of instances and predictions, followed by the prediction of one instance each line.
Todo:
document this format and provide a link.
Returns
A pair that contains the indices and the corresponding scores.

Referenced by PYBIND11_MODULE(), and TEST_CASE().

◆ save_dense_predictions_as_npy() [1/2]

void dismec::io::prediction::save_dense_predictions_as_npy ( const path &  target,
const PredictionMatrix values 
)

Saves predictions as a dense npy file.

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesMatrix with the results. Each row corresponds to an instance and each column to a label.

◆ save_dense_predictions_as_npy() [2/2]

void dismec::io::prediction::save_dense_predictions_as_npy ( std::ostream &  target,
const PredictionMatrix values 
)

Saves predictions as a dense npy file.

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesMatrix with the results. Each row corresponds to an instance and each column to a label.

◆ save_dense_predictions_as_txt() [1/2]

void dismec::io::prediction::save_dense_predictions_as_txt ( const path &  target,
const PredictionMatrix values 
)

Saves predictions as a dense txt matrix.

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesMatrix with the results. Each row corresponds to an instance and each column to a label.

Referenced by TEST_CASE().

◆ save_dense_predictions_as_txt() [2/2]

void dismec::io::prediction::save_dense_predictions_as_txt ( std::ostream &  target,
const PredictionMatrix values 
)

Saves predictions as a dense txt matrix.

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesMatrix with the results. Each row corresponds to an instance and each column to a label.

◆ save_sparse_predictions() [1/2]

void dismec::io::prediction::save_sparse_predictions ( const path &  target,
const PredictionMatrix values,
const IndexMatrix indices 
)

Saves sparse predictions as a text file.

The sparse predictions are expected to be available as two separate arrays indices and values. Each is an N x K array, where N is the number of prediction points and K denotes the number of entries for each instance. The values are then interpreted as follows: For instance i, the predictions are given for the labels indices[i, j], with corresponding scores values[i, k].

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesThe scores for the labels corresponding to indices.
indicesThe indices corresponding to the values.
Exceptions
std::invalid_argumentif the shape of values does not match indices.

Referenced by main(), and TEST_CASE().

◆ save_sparse_predictions() [2/2]

void dismec::io::prediction::save_sparse_predictions ( std::ostream &  target,
const PredictionMatrix values,
const IndexMatrix indices 
)

Saves sparse predictions as a text file.

The sparse predictions are expected to be available as two separate arrays indices and values. Each is an N x K array, where N is the number of prediction points and K denotes the number of entries for each instance. The values are then interpreted as follows: For instance i, the predictions are given for the labels indices[i, j], with corresponding scores values[i, k].

Parameters
targetPath to the file which will be created or overwritten, or output stream.
valuesThe scores for the labels corresponding to indices.
indicesThe indices corresponding to the values.
Exceptions
std::invalid_argumentif the shape of values does not match indices.