fgt_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 "fgt_kde.h"
00042 #include "naive_kde.h"
00043
00095 int main(int argc, char *argv[]) {
00096
00097
00098 fx_init(argc, argv, NULL);
00099
00101
00102
00103
00104
00105
00106 struct datanode *fgt_kde_module =
00107 fx_submodule(fx_root, "kde");
00108
00109
00110 const char* references_file_name = fx_param_str_req(NULL, "data");
00111 printf("%s\n",references_file_name);
00112
00113
00114 const char* queries_file_name =
00115 fx_param_str(NULL, "query", references_file_name);
00116
00117
00118 Matrix references;
00119 Matrix queries;
00120
00121
00122 bool queries_equal_references =
00123 !strcmp(queries_file_name, references_file_name);
00124
00125
00126 data::Load(references_file_name, &references);
00127 if(queries_equal_references) {
00128 queries.Alias(references);
00129 }
00130 else {
00131 data::Load(queries_file_name, &queries);
00132 }
00133
00134
00135 if(!strcmp(fx_param_str(fgt_kde_module, "scaling", "none"), "range")) {
00136 DatasetScaler::ScaleDataByMinMax(queries, references,
00137 queries_equal_references);
00138 }
00139
00140
00141
00142 FGTKde fgt_kde;
00143 Vector fgt_kde_results;
00144
00145 fgt_kde.Init(queries, references, fgt_kde_module);
00146 fgt_kde.Compute();
00147 fgt_kde.get_density_estimates(&fgt_kde_results);
00148
00149
00150 if(fx_param_exists(fgt_kde_module, "fgt_kde_output")) {
00151 fgt_kde.PrintDebug();
00152 }
00153
00154
00155
00156 if(fx_param_exists(fgt_kde_module, "do_naive")) {
00157 NaiveKde<GaussianKernel> naive_kde;
00158 naive_kde.Init(queries, references, fgt_kde_module);
00159 naive_kde.Compute();
00160
00161 if(fx_param_exists(fgt_kde_module, "naive_kde_output")) {
00162 naive_kde.PrintDebug();
00163 }
00164 naive_kde.ComputeMaximumRelativeError(fgt_kde_results);
00165 }
00166
00167 fx_done(fx_root);
00168 return 0;
00169 }