Esempio n. 1
0
def evalKNN(data, classifyTrained, classifySurface, selectFeatures):
    classifier = cl.classifyDataKNN(data, classifyTrained,
                                    classifySurface, selectFeatures)
    classifier.crossValidation()
#     classifier.showKNeighborsGraph()
    if (plotSurfaces):
        classifier.plotDecisionSurface()
Esempio n. 2
0
def predict(data, samples, classifier='SVM',
            classification='combined', selectFeatures=('CUK', 10)):
    """
    Learns the data-set with the given classifier and
    gives a prediction for each of the samples.
    """
    if (classification == "trained"):
        classifyTrained = True
        classifySurface = False
    elif (classification == 'surface'):
        classifyTrained = False
        classifySurface = True
    else:
        classifyTrained = True
        classifySurface = True
    if (classifier == "SVM"):
        clf = cl.classifyDataSVM(data, classifyTrained,
                                 classifySurface, selectFeatures,scaling=False)
    elif (classifier == "DT"):
        clf = cl.classifyDataDT(data, classifyTrained,
                                classifySurface, selectFeatures,scaling=False)
    elif (classifier == "KNN"):
        clf = cl.classifyDataKNN(data, classifyTrained,
                                 classifySurface, selectFeatures,scaling=False)
    elif (classifier == "LogReg"):
        clf = cl.classifyDataLR(data, classifyTrained,
                                classifySurface, selectFeatures,scaling=False)
    else:
        print (str(classifier) + " is not a valid option")
        
    [samples, _,_,_] = clf.extractData(samples,scaling=False)
    
    predictions = [clf.predict(s) for s in samples]
    return predictions