コード例 #1
0
    def __init__(self, config):
        BaseAgent.__init__(self, config)
        plt.ion()

        self.dataset = Dataset('data', self.subsets)
        #self.dataset.loadDataset()
        self.accs = defaultdict(list)
        self.correct = defaultdict(int)
        fig, self.ax = plt.subplots(nrows=6, ncols=4)
コード例 #2
0
def uploadDataset():
    if not request.json or not 'name' in request.json:
        return jsonify({"result": False, "msg": "Failed to Upload Dataset!"})

    dataset = Dataset(request.json['name'], request.json['purpose'],
                      request.json['user'], request.json['datafile'])

    result = Dataset.addDataset(dataset, mysql)

    if result is True:
        return jsonify({
            "result": True,
            "msg": "Successfully Uploaded Dataset!"
        })

    return jsonify({"result": False, "msg": "Failed to Upload Dataset!"})
コード例 #3
0
def updateDataset(dataset_id):
    if not request.json or not 'name' in request.json or not 'id' in request.json:
        return jsonify({"result": False, "msg": "Failed to Update Dataset!"})

    dataset = Dataset(request.json['name'],
                      request.json['purpose'],
                      request.json['user'],
                      id=request.json['id'])

    result = Dataset.updateDataset(dataset_id, dataset, mysql)

    if result is True:
        return jsonify({
            "result": True,
            "msg": "Successfully Updated Dataset!"
        })

    return jsonify({"result": False, "msg": "Failed to Update Dataset!"})
コード例 #4
0
ファイル: app.py プロジェクト: nidawi/2DV515-A4
from models.Dataset import Dataset
from models.NaiveBayes import NaiveBayes
from models.CrossValidation import crossval_predict, crossval_predict_evaluation
from lib.utils import accuracy_score, confusion_matrix, present_matrix, present_accuracies

BANKNOTE_FILE = "data/banknote_authentication.csv"
IRIS_FILE = "data/iris.csv"
CROSS_VAL_FOLDS = 5

# parse selected file
fdb = Dataset(IRIS_FILE)


def run_naive_bayes_example():
    print("Naive Bayes @ training data")

    # create and train model using the previously loaded file
    model = NaiveBayes()
    model.fit(fdb.get_data(), fdb.get_labels())
    print("Naive Bayes model was trained with data from %s in %s seconds." %
          (fdb.get_file_name(), model.get_fit_time()))

    # run predictions
    predictions = model.predict(fdb.get_data())
    actuals = fdb.get_labels()

    print("Predictions complete after %s seconds." % model.get_predict_time())

    # calculate accuracy
    accuracy = accuracy_score(predictions, actuals)