def predict():
    '''
    For rendering results on HTML GUI
    '''
    int_features = [x for x in request.form.values()]
    result_knn,result_tfidf,result,result_collaborative = model_final.get_input(int_features)
    result_word=[]
    for i in result:
        result_word.append(i[0])
    print(result_collaborative)
    return render_template ( 'index.html',result_knn=result_knn,result_tfidf=result_tfidf,result_word=result_word,result_collaborative=result_collaborative)
Exemple #2
0
def postentry():
    year = request.form["year"]
    month = request.form["month"]
    date = request.form["date"]
    type = request.form["type"]
    order = request.form["order"]
    return render_template("result.html",
                           entries=model.get_input(year, month, date, type,
                                                   order),
                           year=year,
                           month=month,
                           date=date,
                           type=type,
                           order=order)
Exemple #3
0
 def test_input(self) -> None:
     global my_dic, output
     my_dic = {"age":int(self.l1.text()), "Medu":int(self.l2.text()),"Fedu":int(self.l3.text()), "traveltime":int(self.l4.text()), "failures": int(self.l5.text()),
               "schoolsup": int(self.l6.text()),"famsup": int(self.l7.text()),"paid": int(self.l8.text()),"activities": int(self.l9.text()),"internet": int(self.l10.text()),
               "freetime": int(self.l11.text()),"goout": int(self.l12.text()),"Dalc": int(self.l13.text()),"Walc": int(self.l14.text()),"health": int(self.l15.text()),"absences": int(self.l5.text()),
               "G1": int(self.l17.text()),"G2": int(self.l18.text())}
     
     output = model.get_input(my_dic)
     self.report_subhead.setText("About")
     self.model_details.setText("This model uses Naive Bayes Algorithm. We have used student dataset from UCI archive.")
     if output == 0:
         self.results.setText("The model predicts that the academic performance based on the given data attributes will be POOR")
     elif output == 1:
         self.results.setText("The model predicts that the academic performance based on the given data attributes will be FAIR")
     else:
         self.results.setText("The model predicts that the academic performance based on the given data attributes will be GOOD")
     self.results.setFont(QFont("Arial",14, weight=QFont.Bold))        
def predict():
    """Classifies JPEG image passed in as POST data
    
    Assuming a JPEG file is passed in (as raw bytes), this function saves the 
    image to a the local temp directory, passes in the image to the TensorFlow
    model, and returns the top-5 guesses and path to the saved image to be 
    rendered to the client.

    NOTE: This function is NOT SAFE. Strictly for demonstration purposes. Does
    not do any safe-checking of the data being saved locally. Only use locally.
    """
    results = []
    filename = None
    if 'file' not in request.files:
        flash('No file part')
        return redirect(request.url)
    file = request.files['file']
    if file.filename == '':
        flash('No selected file')
        return redirect(request.url)
    if file:
        for f in os.listdir(app.config['UPLOAD_FOLDER']):
            os.remove(os.path.join(app.config['UPLOAD_FOLDER'], f))
        filename = os.path.join(app.config['UPLOAD_FOLDER'],
                                '{}.jpg'.format(random.randint(0, 999999999)))
        file.save(filename)
        file.seek(0)
        data = file.read()
        feed_dict = {model.get_input(sess): data}
        prediction = sess.run(model.get_predictions(sess), feed_dict)
        top_k = prediction.argsort()[0][-5:][::-1]
        descriptions = get_descriptions()
        for idx in top_k:
            description = descriptions[idx]
            score = prediction[0][idx]
            print('{} (score = {})'.format(description, score))
            results.append((description, score))
    return render_template('predict.html', results=results, filename=filename)
Exemple #5
0
 def POST(self):
     searchinput = model.get_input()
     return render.search(searchinput)