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)
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!"})
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!"})
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)