Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
 def score(self, testset):
     accuracy = getAccuracy(testset, self.predictions)
     return accuracy
	def score(self, testset):
		accuracy = getAccuracy(testset, self.predictions)
		return accuracy