コード例 #1
0
if (docrossvalidation == 1):
    df_scores = cross_validation_mse(names, classifiers, X_train, y_train, 10,
                                     ncores)
    plot_cross_validation_mse(names, df_scores, suffix)

if (doRoCLearning == 1):
    confusion(mylistvariables, names, classifiers, suffix, X_train, y_train, 5)
    precision_recall(mylistvariables, names, classifiers, suffix, X_train,
                     y_train, 5)
    plot_learning_curves(names, classifiers, suffix, X_train, y_train, 100,
                         12000, 300)

if (dotesting == 1):
    filenametest_set_ML = "output/testsample%sMLdecision.pkl" % (suffix)
    ntuplename = "fTreeFlagged%s" % (optionClassification)
    test_setML = test(names, trainedmodels, X_test, test_set)
    test_set.to_pickle(filenametest_set_ML)

if (doBoundary == 1):
    mydecisionboundaries = decisionboundaries(names, trainedmodels, suffix,
                                              X_train, y_train)
    X_train_2PC, pca = GetPCADataFrameAndPC(X_train, 2)
    trainedmodels = fit(names, classifiers, X_train_2PC, y_train)
    mydecisionboundaries = decisionboundaries(names, trainedmodels,
                                              suffix + "PCAdecomposition",
                                              X_train_2PC, y_train)

if (doBinarySearch == 1):
    namesCV, classifiersCV, param_gridCV, changeparameter = getgridsearchparameters(
        optionClassification)
    grid_search_models, grid_search_bests = do_gridsearch(
if (activateKerasModels == 1):
    classifiersDNN, namesDNN = getclassifiersDNN(len(X_train.columns))
    classifiers = classifiers + classifiersDNN
    names = names + namesDNN

if (dotraining == 1):
    trainedmodels = fit(names, classifiers, X_train, y_train)
    savemodels(names, trainedmodels, output, suffix)

if (dotesting == 1):
    filenametest_set_ML = output + "/testsample%sMLdecision.pkl" % (suffix)
    filenametest_set_ML_root = output + "/testsample%sMLdecision.root" % (
        suffix)
    ntuplename = getTreeName(optionClassification) + "Tested"
    test_setML = test(names, trainedmodels, test_set, mylistvariables,
                      myvariablesy)
    test_setML.to_pickle(filenametest_set_ML)
    writeTree(filenametest_set_ML_root, ntuplename, test_setML)

if (doRoCLearning == 1):
    #   confusion(mylistvariables,names,classifiers,suffix,X_train,y_train,5)
    precision_recall(mylistvariables, names, classifiers, suffix, X_train,
                     y_train, 5, plotdir)
    plot_learning_curves(names, classifiers, suffix, plotdir, X_train, y_train,
                         500, nevents, 4000)

if (doOptimisation == 1):
    if not ((classtype == "HFmeson") & (optionClassification == "Ds")):
        print("==================ERROR==================")
        print(
            "Optimisation is not implemented for this classification problem. The code is going to fail"