Ejemplo n.º 1
0
def save(img, value):
    base64Img = imageToBase64(img)
    binpix = getBinaryPix(img).tolist()
    binpix = [str(i) for i in binpix]
    content = ','.join(binpix)
    collection = persistence.openConnection()
    persistence.addImageToCollection(collection, base64Img, content, value)
    return base64Img
Ejemplo n.º 2
0
def cross_validation():
    dataSet, labels = persistence.allData(persistence.openConnection())
    # dataMatrix = mat(dataSet)
    # labelMatrix = mat(labels)
    clf = SVC(kernel='rbf', C=1000)
    clf.fit(dataSet, labels)
    scores = cs.cross_val_score(clf, dataSet, labels, cv=5)
    print('Accuracy: %0.2f (+- %0.2f)' % (scores.mean(), scores.std()))
    return clf
Ejemplo n.º 3
0
 def handleQuerySets(self):
     import persistence
     collection = persistence.openConnection()
     keys = persistence.querySets(collection)
     keys.sort()
     result = {}
     for key in keys:
         result[key] = persistence.querySet(collection, key)
     return result
Ejemplo n.º 4
0
def searchBestParameter():
    parameters = {
        'kernel': ('linear', 'poly', 'rbf', 'sigmoid'),
        'C': [1, 100]
    }
    dataSet, labels = persistence.allData(persistence.openConnection())
    svr = SVC()
    clf = grid_search.GridSearchCV(svr, parameters)
    clf.fit(dataSet, labels)

    print(clf.best_params_)
Ejemplo n.º 5
0
def predict(binImg1, binImg2, binImg3):
    parameters = {
        'kernel': ('linear', 'poly', 'rbf', 'sigmoid'),
        'C': [1, 100]
    }
    dataSet, labels = persistence.allData(persistence.openConnection())
    svr = SVC()
    clf = grid_search.GridSearchCV(svr, parameters)
    clf.fit(dataSet, labels)

    v1 = clf.predict(binImg1)
    v2 = clf.predict(binImg2)
    v3 = clf.predict(binImg3)

    return (v1, v2, v3)