fft_kde_main.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00039 #include <fastlib/fastlib.h>
00040 #include "dataset_scaler.h"
00041 #include "fft_kde.h"
00042 #include "naive_kde.h"
00043
00097 int main(int argc, char *argv[]) {
00098
00099
00100 fx_init(argc, argv, NULL);
00101
00103
00104
00105
00106
00107
00108 struct datanode *fft_kde_module =
00109 fx_submodule(NULL, "kde");
00110
00111
00112 const char* references_file_name = fx_param_str_req(NULL, "data");
00113
00114
00115 const char* queries_file_name =
00116 fx_param_str(NULL, "query", references_file_name);
00117
00118
00119 Matrix references;
00120 Matrix queries;
00121
00122
00123 bool queries_equal_references =
00124 !strcmp(queries_file_name, references_file_name);
00125
00126
00127 data::Load(references_file_name, &references);
00128 if(queries_equal_references) {
00129 queries.Alias(references);
00130 }
00131 else {
00132 data::Load(queries_file_name, &queries);
00133 }
00134
00135
00136 if(!strcmp(fx_param_str(fft_kde_module, "scaling", "none"), "range")) {
00137 DatasetScaler::ScaleDataByMinMax(queries, references,
00138 queries_equal_references);
00139 }
00140
00141
00142
00143 FFTKde fft_kde;
00144 Vector fft_kde_results;
00145
00146
00147 fft_kde.Init(queries, references, fft_kde_module);
00148 fft_kde.Compute();
00149 fft_kde.get_density_estimates(&fft_kde_results);
00150
00151
00152 if(fx_param_exists(fft_kde_module, "fft_kde_output")) {
00153 fft_kde.PrintDebug();
00154 }
00155
00156
00157
00158 if(fx_param_exists(fft_kde_module, "do_naive")) {
00159 NaiveKde<GaussianKernel> naive_kde;
00160 naive_kde.Init(queries, references, fft_kde_module);
00161 naive_kde.Compute();
00162
00163 if(fx_param_exists(fft_kde_module, "naive_kde_output")) {
00164 naive_kde.PrintDebug();
00165 }
00166 naive_kde.ComputeMaximumRelativeError(fft_kde_results);
00167 }
00168
00169 fx_done(NULL);
00170 return 0;
00171 }