Ejemplo n.º 1
0
def run_test():

  from options import TestOptions
  opt = TestOptions()

  from do_classification import classifier
  classifier(opt)
Ejemplo n.º 2
0
def run_test():

    from options import TestOptions
    opt = TestOptions()

    from do_classification import classifier
    classifier(opt)
Ejemplo n.º 3
0
def run_unsupervised():

    from options import MultiOptions
    opt = MultiOptions()
    opt.opdict['method'] = 'kmean'

    from unsupervised import classifier
    classifier(opt)
Ejemplo n.º 4
0
def run_unsupervised():

  from options import MultiOptions
  opt = MultiOptions()
  opt.opdict['method'] = 'kmean'

  from unsupervised import classifier
  classifier(opt)
Ejemplo n.º 5
0
def run_all():

  from options import MultiOptions
  opt = MultiOptions()
  #opt.count_number_of_events()
 
  from do_classification import classifier
  classifier(opt)

  if opt.opdict['method'] == 'lr' or opt.opdict['method'] == 'svm' or opt.opdict['method'] == 'lrsk':
    from results import AnalyseResults
    res = AnalyseResults()
    if res.opdict['plot_confusion']:
      res.plot_confusion()

  else:
    from results import AnalyseResultsExtraction
    res = AnalyseResultsExtraction()
Ejemplo n.º 6
0
def run_all():

    from options import MultiOptions
    opt = MultiOptions()
    #opt.count_number_of_events()

    from do_classification import classifier
    classifier(opt)

    if opt.opdict['method'] == 'lr' or opt.opdict[
            'method'] == 'svm' or opt.opdict['method'] == 'lrsk':
        from results import AnalyseResults
        res = AnalyseResults()
        if res.opdict['plot_confusion']:
            res.plot_confusion()

    else:
        from results import AnalyseResultsExtraction
        res = AnalyseResultsExtraction()
Ejemplo n.º 7
0
def run_all():

  from options import MultiOptions
  opt = MultiOptions()
  #opt.count_number_of_events()

  ### UNSUPERVISED METHOD ### 
  if opt.opdict['method'] == 'kmeans':
    from unsupervised import classifier
    classifier(opt)

  ### SUPERVISED METHODS ###
  elif opt.opdict['method'] in ['lr','svm','svm_nl','lrsk']:
    from do_classification import classifier
    classifier(opt)

    from results import AnalyseResults
    res = AnalyseResults()
    if res.opdict['plot_confusion']:
      res.plot_confusion()

  elif opt.opdict['method'] in ['ova','1b1']:
    from do_classification import classifier
    classifier(opt)

    from results import AnalyseResultsExtraction
    res = AnalyseResultsExtraction()
Ejemplo n.º 8
0
def plot_sep(opt):

    opt.set_params()
    opt.opdict['fig_path'] = os.path.join(opt.opdict['outdir'], 'figures')

    from do_classification import classifier
    ### LINEAR SVM ###
    opt.opdict['method'] = 'svm'
    classifier(opt)
    #opt.plot_PDFs()
    out_svm = opt.out
    print "SVM", out_svm['thetas']

    x_train = opt.train_x
    x_test = opt.x
    y_train = opt.train_y
    y_test = opt.y

    # *** Plot ***
    plot_2f_synthetics(out_svm, x_train, x_test, y_test, y_train=y_train)
    #plt.savefig('%s/Test_%dc_%s_SVM.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()

    ### LOGISTIC REGRESSION ###
    opt.opdict['method'] = 'lr'
    out_lr = {}
    for b in range(1):
        opt.opdict['learn_file'] = os.path.join(opt.opdict['libdir'],
                                                'LR_%d' % b)
        #os.remove(opt.opdict['learn_file'])
        classifier(opt)
        out_lr[b] = opt.out

    print "LR", out_lr[0]['thetas']

    # *** Plot ***
    if b == 0:
        print sorted(out_lr[0])
        plot_2f_synthetics(out_lr[0], x_train, x_test, y_test, y_train=y_train)
        #plt.savefig('%s/Test_%dc_%s_LR.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
        plt.show()

    else:
        plot_2f_synth_var(out_lr, x_train, x_test, y_test, opt.NB_test)
        #plt.savefig('%s/Test_%dc_LR_%s.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
        plt.show()

    if opt.opdict['plot_prec_rec']:
        plot_2f_synth_var(out_lr, x_train, x_test, y_test, opt.NB_test)
        #plt.savefig('%s/Test_%dc_bad_threshold.png'%(opt.opdict['fig_path'],len(opt.types)))
        plt.show()

    ### NON LINEAR SVM ###
    opt.opdict['method'] = 'svm_nl'
    classifier(opt)
    out_svm_nl = opt.out
    plot_2f_nonlinear(out_svm_nl,
                      x_train,
                      x_test,
                      y_test,
                      y_train=y_train,
                      synth=True)
    #plt.savefig('%s/Test_%dc_%s_SVM_NL.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()

    ### COMPARE ALL 3 METHODS ON THE SAME PLOT ###
    plot_2f_synthetics(out_lr[0],
                       x_train,
                       x_test,
                       y_test,
                       out_comp=out_svm,
                       y_train=y_train,
                       map_nl=out_svm_nl)
    #plt.savefig('%s/Test_%dc_%s.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()
Ejemplo n.º 9
0
def plot_sep(opt):

    opt.set_params()
    opt.opdict['fig_path'] = os.path.join(opt.opdict['outdir'],'figures')

    from do_classification import classifier
    ### LINEAR SVM ###
    opt.opdict['method'] = 'svm'
    classifier(opt)
    #opt.plot_PDFs()
    out_svm = opt.out
    print "SVM", out_svm['thetas']

    x_train = opt.train_x
    x_test = opt.x
    y_train = opt.train_y
    y_test = opt.y

    # *** Plot ***
    plot_2f_synthetics(out_svm,x_train,x_test,y_test,y_train=y_train)
    #plt.savefig('%s/Test_%dc_%s_SVM.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()

    ### LOGISTIC REGRESSION ###
    opt.opdict['method'] = 'lr'
    out_lr = {}
    for b in range(1):
      opt.opdict['learn_file'] = os.path.join(opt.opdict['libdir'],'LR_%d'%b)
      #os.remove(opt.opdict['learn_file'])
      classifier(opt)
      out_lr[b] = opt.out

    print "LR", out_lr[0]['thetas']

    # *** Plot ***
    if b == 0:
      print sorted(out_lr[0])
      plot_2f_synthetics(out_lr[0],x_train,x_test,y_test,y_train=y_train)
      #plt.savefig('%s/Test_%dc_%s_LR.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
      plt.show()

    else:
      plot_2f_synth_var(out_lr,x_train,x_test,y_test,opt.NB_test)
      #plt.savefig('%s/Test_%dc_LR_%s.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
      plt.show()

    if opt.opdict['plot_prec_rec']:
      plot_2f_synth_var(out_lr,x_train,x_test,y_test,opt.NB_test)
      #plt.savefig('%s/Test_%dc_bad_threshold.png'%(opt.opdict['fig_path'],len(opt.types)))
      plt.show()


    ### NON LINEAR SVM ###
    opt.opdict['method'] = 'svm_nl'
    classifier(opt)
    out_svm_nl = opt.out
    plot_2f_nonlinear(out_svm_nl,x_train,x_test,y_test,y_train=y_train,synth=True)
    #plt.savefig('%s/Test_%dc_%s_SVM_NL.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()

    ### COMPARE ALL 3 METHODS ON THE SAME PLOT ###
    plot_2f_synthetics(out_lr[0],x_train,x_test,y_test,out_comp=out_svm,y_train=y_train,map_nl=out_svm_nl)
    #plt.savefig('%s/Test_%dc_%s.png'%(opt.opdict['fig_path'],len(opt.types),opt.sep))
    plt.show()