00001 /* 00002 * Main authors: 00003 * Tias Guns <tias.guns@cs.kuleuven.be> 00004 * 00005 * Copyright: 00006 * Tias Guns, 2008 00007 * 00008 * Revision information: 00009 * $Id: pattset_concept_accuracy.cpp 217 2009-04-07 13:37:27Z tias $ 00010 * 00011 * This file is part of Cimcp, Correlated Itemset Mining using 00012 * Constraint Programming, and uses Gecode. 00013 * 00014 * Permission is hereby granted, free of charge, to any person obtaining 00015 * a copy of this software and associated documentation files (the 00016 * "Software"), to deal in the Software without restriction, including 00017 * without limitation the rights to use, copy, modify, merge, publish, 00018 * distribute, sublicense, and/or sell copies of the Software, and to 00019 * permit persons to whom the Software is furnished to do so, subject to 00020 * the following conditions: 00021 * 00022 * The above copyright notice and this permission notice shall be 00023 * included in all copies or substantial portions of the Software. 00024 * 00025 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00026 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00027 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00028 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00029 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00030 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00031 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00032 * 00033 */ 00034 00035 /// relative accuracy measure 00036 inline int monotone_function(int posTot, int pos, int negTot, int neg, int precision) { 00037 float pn = pos + neg; 00038 float tot = posTot + negTot; 00039 return ( ((pos+neg)/tot) * ( pos/pn - posTot/tot ) )*precision; 00040 // equivalently: (pos/posTot)-(neg/negTot) 00041 } 00042 #include "cimcp_Fmonotone.cpp" // model using monotone function of boolean variables 00043 00044 int main(int argc, char* argv[]) { 00045 Options_fimcp opt(strpbrk(argv[0],"/\\")+1); 00046 opt.delta(0); 00047 opt.alpha(1); 00048 opt.description("This model finds discriminative patterns, using relative accuracy as measure"); 00049 opt.usage("-datafile example.txt\n\ 00050 -datafile example.txt\t itemset file where last item is the class: 0 or 1\n\ 00051 -alpha k\t (default 1) use branch-and-bound search for top-k itemsets\n\ 00052 -alpha 0\t to find all patternsets given tresholds:\n\ 00053 \t -delta 0.50\t minimal measure value"); 00054 opt.parse(argc, argv); 00055 00056 if (opt.alpha() == 0) { 00057 fprintf(stdout, "Running DF search for "); 00058 Script::run<Cimcp_Fmonotone,DFS,Options_fimcp>(opt); 00059 } else { 00060 fprintf(stdout, "Running BAB search for "); 00061 Script::run<Cimcp_Fmonotone,BAB,Options_fimcp>(opt); 00062 } 00063 return 0; 00064 } 00065 // avoid 'undefined reference' linking error 00066 void Fimcp_basic::run(const Options_fimcp&) {};
1.6.3