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
00032
00033
00034
00035 #include <math.h>
00036
00037
00038 inline int convex_function(int posTot, int pos, int negTot, int neg, int precision) {
00039 float tot = posTot + negTot;
00040 float base = 1 - ((posTot/tot)*(posTot/tot)) - ((negTot/tot)*(negTot/tot));
00041
00042 float covered = pos + neg;
00043 float notCovered = tot - covered;
00044 float calc = covered * ( 1 - ((pos/covered)*(pos/covered)) - ((neg/covered)*(neg/covered)) ) +
00045 notCovered * ( 1 - (((posTot-pos)/notCovered)*((posTot-pos)/notCovered))
00046 - (((negTot-neg)/notCovered)*((negTot-neg)/notCovered)) );
00047 if (isnan(calc)) return 0;
00048 return (int) (precision*(base - calc/tot));
00049 }
00050 #include "cimcp_Fconvex.cpp"
00051
00052 int main(int argc, char* argv[]) {
00053 Options_fimcp opt(strpbrk(argv[0],"/\\")+1);
00054 opt.delta(0);
00055 opt.alpha(1);
00056 opt.description("This model finds discriminative patterns, using gini index as measure");
00057 opt.usage("-datafile example.txt\n\
00058 -datafile example.txt\t itemset file where last item is the class: 0 or 1\n\
00059 -alpha k\t (default 1) use branch-and-bound search for top-k itemsets\n\
00060 -alpha 0\t to find all patternsets given tresholds:\n\
00061 \t -delta 0.50\t minimal measure value");
00062 opt.parse(argc, argv);
00063
00064 if (opt.alpha() == 0) {
00065 fprintf(stdout, "Running DF search for ");
00066 Script::run<Cimcp_Fconvex,DFS,Options_fimcp>(opt);
00067 } else {
00068 fprintf(stdout, "Running BAB search for ");
00069 Script::run<Cimcp_Fconvex,BAB,Options_fimcp>(opt);
00070 }
00071 return 0;
00072 }
00073
00074 void Fimcp_basic::run(const Options_fimcp&) {};