1/*
    2The task is to decide whether a machine should be fixed, sent back or is ok.
    3Machines dataset from The ACE Data Mining System User's Manual
    4https://dtai.cs.kuleuven.be/ACE/doc/ACEuser-1.2.16.pdf
    5
    6Downloaded from
    7https://dtai.cs.kuleuven.be/static/ACE/doc/
    8*/

?- induce_par([train],P),test(P,[test],LL,AUCROC,ROC,AUCPR,PR). ?- induce_par([rand_train],P),test(P,[rand_test],LL,AUCROC,ROC,AUCPR,PR). */

   14:-use_module(library(slipcover)).   15
   16:- if(current_predicate(use_rendering/1)).   17:- use_rendering(c3).   18:- use_rendering(lpad).   19:- endif.   20
   21:-sc.   22
   23:- set_sc(depth_bound,false).   24:- set_sc(neg_ex,given).   25:- set_sc(megaex_bottom,15).   26:- set_sc(max_iter,10).   27:- set_sc(max_iter_structure,50).   28:- set_sc(verbosity,1).   29
   30
   31:- begin_in.   32class(sendback):0.5 :-
   33  worn(A),
   34  not_replaceable(A).
   35
   36class(fix):0.6 :-
   37  worn(A),
   38  replaceable(A).
   39
   40class(ok):0.5 :-
   41  not_worn(_A).
   42:- end_in.   43
   44:- begin_bg.   45component(C):-
   46  replaceable(C).
   47component(C):-
   48  not_replaceable(C).
   49replaceable(gear).
   50replaceable(wheel).
   51replaceable(chain).
   52not_replaceable(engine).
   53not_replaceable(control_unit).
   54not_worn(C):-
   55  component(C),
   56  \+ worn(C).
   57one_worn:-
   58  worn(_).
   59none_worn:-
   60  \+ one_worn.
   61:- end_bg.   62
   63fold(train,[1,2,3,4,5,6,7,8,9,10]).
   64
   65fold(test,[11,12,13,14,15]).
   66
   67fold(all,F):-
   68  fold(train,FTr),
   69  fold(test,FTe),
   70  append(FTr,FTe,F).
   71
   72:- fold(all,F),
   73   sample(10,F,FTr,FTe),
   74   assert(fold(rand_train,FTr)),
   75   assert(fold(rand_test,FTe)).   76
   77output(class/1).
   78
   79input_cw(replaceable/1).
   80input_cw(not_replaceable/1).
   81input_cw(worn/1).
   82input_cw(not_worn/1).
   83input_cw(none_worn/0).
   84%input(one_worn/0).
   85
   86determination(class/1,replaceable/1).
   87determination(class/1,not_replaceable/1).
   88determination(class/1,worn/1).
   89determination(class/1,not_worn/1).
   90determination(class/1,none_worn/0).
   91
   92modeh(*,class(fix)).
   93modeh(*,class(ok)).
   94modeh(*,class(sendback)).
   95
   96
   97/*modeh(*,[class(fix),class(ok),class(sendback)],
   98  [class(fix),class(ok),class(sendback)],
   99  [replaceable/1,not_replaceable/1,worn/1]).
  100*/
  101
  102modeb(*,not_replaceable(-comp)).
  103modeb(*,replaceable(-comp)).
  104modeb(*,worn(-comp)).
  105modeb(*,not_worn(-comp)).
  106modeb(*,none_worn).
  107
  108begin(model(1)).
  109testnr(1).
  110class(sendback).
  111neg(class(fix)).
  112neg(class(ok)).
  113worn(gear).
  114worn(engine).
  115end(model(1)).
  116
  117begin(model(2)).
  118testnr(2).
  119class(ok).
  120neg(class(sendback)).
  121neg(class(fix)).
  122end(model(2)).
  123
  124begin(model(3)).
  125testnr(3).
  126class(fix).
  127neg(class(sendback)).
  128neg(class(ok)).
  129worn(gear).
  130end(model(3)).
  131
  132begin(model(4)).
  133testnr(4).
  134class(sendback).
  135neg(class(fix)).
  136neg(class(ok)).
  137worn(engine).
  138end(model(4)).
  139
  140begin(model(5)).
  141testnr(5).
  142class(fix).
  143neg(class(sendback)).
  144neg(class(ok)).
  145worn(gear).
  146worn(chain).
  147end(model(5)).
  148
  149begin(model(6)).
  150testnr(6).
  151class(fix).
  152neg(class(sendback)).
  153neg(class(ok)).
  154worn(wheel).
  155end(model(6)).
  156
  157begin(model(7)).
  158testnr(7).
  159class(sendback).
  160neg(class(fix)).
  161neg(class(ok)).
  162worn(wheel).
  163worn(control_unit).
  164end(model(7)).
  165
  166begin(model(8)).
  167testnr(8).
  168class(ok).
  169neg(class(sendback)).
  170neg(class(fix)).
  171end(model(8)).
  172
  173begin(model(9)).
  174testnr(9).
  175class(fix).
  176neg(class(sendback)).
  177neg(class(ok)).
  178worn(wheel).
  179worn(chain).
  180end(model(9)).
  181
  182begin(model(10)).
  183testnr(10).
  184class(sendback).
  185neg(class(fix)).
  186neg(class(ok)).
  187worn(engine).
  188worn(chain).
  189end(model(10)).
  190
  191begin(model(11)).
  192testnr(11).
  193class(sendback).
  194neg(class(fix)).
  195neg(class(ok)).
  196worn(engine).
  197worn(control_unit).
  198end(model(11)).
  199
  200begin(model(12)).
  201testnr(12).
  202class(fix).
  203neg(class(sendback)).
  204neg(class(ok)).
  205worn(chain).
  206worn(wheel).
  207worn(gear).
  208end(model(12)).
  209
  210begin(model(13)).
  211testnr(13).
  212class(sendback).
  213neg(class(fix)).
  214neg(class(ok)).
  215worn(chain).
  216worn(wheel).
  217worn(gear).
  218worn(engine).
  219end(model(13)).
  220
  221begin(model(14)).
  222testnr(14).
  223class(ok).
  224neg(class(sendback)).
  225neg(class(fix)).
  226end(model(14)).
  227
  228begin(model(15)).
  229testnr(15).
  230class(fix).
  231neg(class(sendback)).
  232neg(class(ok)).
  233worn(wheel).
  234worn(gear).
  235end(model(15))