diff options
| author | Gertjan van den Burg <burg@ese.eur.nl> | 2016-12-07 15:45:54 +0100 |
|---|---|---|
| committer | Gertjan van den Burg <burg@ese.eur.nl> | 2016-12-07 15:45:54 +0100 |
| commit | db54d84bc0fa031da3caa1a7eaf916c673eb4f56 (patch) | |
| tree | 3d7fedeb0b2f0c1ddf5bec92994ad7602eba8149 | |
| parent | make test for sparsity the same everywhere (diff) | |
| download | gensvm-db54d84bc0fa031da3caa1a7eaf916c673eb4f56.tar.gz gensvm-db54d84bc0fa031da3caa1a7eaf916c673eb4f56.zip | |
throw warning when using sparse matrices with kernels
| -rw-r--r-- | src/GenSVMgrid.c | 11 | ||||
| -rw-r--r-- | src/GenSVMtraintest.c | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/GenSVMgrid.c b/src/GenSVMgrid.c index bbbd0cf..1fd7463 100644 --- a/src/GenSVMgrid.c +++ b/src/GenSVMgrid.c @@ -113,6 +113,17 @@ int main(int argc, char **argv) note("Reading data from %s\n", grid->train_data_file); gensvm_read_data(train_data, grid->train_data_file); + + // check if we are sparse and want nonlinearity + if (train_data->Z == NULL && grid->kerneltype != K_LINEAR) { + err("[GenSVM Warning]: Sparse matrices with nonlinear kernels " + "are not yet supported. Dense matrices will " + "be used.\n"); + train_data->RAW = gensvm_sparse_to_dense(train_data->spZ); + train_data->Z = train_data->RAW; + gensvm_free_sparse(train_data->spZ); + } + if (grid->traintype == TT) { err("[GenSVM Warning]: Using test datasets in a grid search " "is not yet supported in GenSVM.\n" diff --git a/src/GenSVMtraintest.c b/src/GenSVMtraintest.c index 40c4321..ecf455b 100644 --- a/src/GenSVMtraintest.c +++ b/src/GenSVMtraintest.c @@ -135,6 +135,16 @@ int main(int argc, char **argv) model->data_file = Calloc(char, GENSVM_MAX_LINE_LENGTH); strcpy(model->data_file, training_inputfile); + // check if we are sparse and want nonlinearity + if (traindata->Z == NULL && model->kerneltype != K_LINEAR) { + err("[GenSVM Warning]: Sparse matrices with nonlinear kernels " + "are not yet supported. Dense matrices will " + "be used.\n"); + traindata->RAW = gensvm_sparse_to_dense(traindata->spZ); + traindata->Z = traindata->RAW; + gensvm_free_sparse(traindata->spZ); + } + // seed the random number generator srand(time(NULL)); @@ -151,6 +161,16 @@ int main(int argc, char **argv) // to an output file if specified if (testing_inputfile != NULL) { gensvm_read_data(testdata, testing_inputfile); + + // check if we are sparse and want nonlinearity + if (testdata->Z == NULL && model->kerneltype != K_LINEAR) { + err("[GenSVM Warning]: Sparse matrices with nonlinear " + "kernels are not yet supported. Dense " + "matrices will be used.\n"); + testdata->Z = gensvm_sparse_to_dense(testdata->spZ); + gensvm_free_sparse(testdata->spZ); + } + gensvm_kernel_postprocess(model, traindata, testdata); // predict labels |
