Esempio n. 1
0
def mlp_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    mlpModel = classify(dataModel.trainFeat, dataModel.trainLabels)
    accmlpModel = getAccuracy(mlpModel, dataModel.testFeat,
                              dataModel.testLabels)
    print("MLP Classifier accuracy: {:.2f}%".format(accmlpModel * 100))
    saveModel(mlpModel)
Esempio n. 2
0
def knn_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    knnModel = classify(dataModel.trainFeat, dataModel.trainLabels)
    accKnnModel = getAccuracy(knnModel, dataModel.testFeat,
                              dataModel.testLabels)
    print("KNNClassifier accuracy: {:.2f}%".format(accKnnModel * 100))
    saveModel(knnModel)
def random_forest_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    random_forestModel = classify(dataModel.trainFeat, dataModel.trainLabels)
    accModel = getAccuracy(random_forestModel, dataModel.testFeat,
                           dataModel.testLabels)
    print("Random Forest Classifier accuracy: {:.2f}%".format(accModel * 100))
    saveModel(random_forestModel)
Esempio n. 4
0
def decision_tree_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    decisionTreeModel = classify(dataModel.trainFeat, dataModel.trainLabels)
    accDecitionTree = getAccuracy(decisionTreeModel, dataModel.testFeat,
                                  dataModel.testLabels)
    print("DecisionTreeClassifier accuracy: {:.2f}%".format(accDecitionTree *
                                                            100))
    saveModel(decisionTreeModel)
def chooseClassifier(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    decisionTreeModel = dtc(dataModel.trainFeat, dataModel.trainLabels)
    knnModel = kc(dataModel.trainFeat, dataModel.trainLabels)
    accDecitionTree = getAccuracy(decisionTreeModel, dataModel.testFeat,
                                  dataModel.testLabels)
    accKnnModel = getAccuracy(knnModel, dataModel.testFeat,
                              dataModel.testLabels)
    print("DecisionTreeClassifier accuracy: {:.2f}%".format(accDecitionTree *
                                                            100))
    print("KNNClassifier accuracy: {:.2f}%".format(accKnnModel * 100))
    acc = accDecitionTree
    if accKnnModel > acc:
        acc = accKnnModel
        print("Knn is saved")
        saveModel(knnModel)
    else:
        print("Decition tree is saved")
        saveModel(decisionTreeModel)

    return acc
def logistic_regression_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    model = classify(dataModel.trainFeat, dataModel.trainLabels)
    acc = getAccuracy(model, dataModel.testFeat, dataModel.testLabels)
    print("Logistic Regression accuracy: {:.2f}%".format(acc * 100))
    saveModel(model)
Esempio n. 7
0
def svm_maker_algoritm(trainfolderpath):
    dataModel = get_data_from_folder(trainfolderpath)
    svmModel = classify(dataModel.trainFeat, dataModel.trainLabels)
    accSVMModel = getAccuracy(svmModel, dataModel.testFeat, dataModel.testLabels)
    print("SVMClassifier accuracy: {:.2f}%".format(accSVMModel * 100))
    saveModel(svmModel)
Esempio n. 8
0
 def testKNNClassifier(self):
     dataModel = get_data_from_folder(
         "C:/Users/Anna/PycharmProjects/Projekt/train2")
     model = classify(dataModel.trainFeat, dataModel.trainLabels)
     assert np.array_equal(model.classes_,
                           ['cat', 'dog']), "Błąd klasyfikatora"
 def testDecisionTreeClassifier(self):
     dataModel = get_data_from_folder(
         "C:/Users/Anna/PycharmProjects/Projekt/train2")
     model = classify(dataModel.trainFeat, dataModel.trainLabels)
     assert model.tree_.node_count > 0, "Błąd klasyfikatora"