def predict(): form = PredictForm() value = randint(2000, 5000) if form.validate_on_submit(): flash(f"Prediction: {value}", "success") return redirect(url_for("home")) return render_template("predict.html", title="Predict", form=form)
def bangalore(): form = PredictForm() name = getareanames() if form.validate_on_submit(): return redirect(url_for('test1')) return render_template('bangalore.html', form=form, data=name, title='Home')
def predictOutput(): form = PredictForm() if form.validate_on_submit(): habitants = form.habitants.data csvText = form.csvText.data ht = lstmPredict(csvText, habitants) return render_template("pages/predictOutput.html", out=habitants, csvText=csvText, ht=ht) return render_template("pages/predictOutput.html")
def predict(): form = PredictForm() if form.validate_on_submit(): sex,exang,ca,cp,restecg,slope,thal = form.data['sex'],\ form.data['exang'],\ form.data['ca'],\ form.data['cp'],\ form.data['restecg'],\ form.data['slope'],\ form.data['thal'] flash("Have Heart Disease" if prediction(sex,exang,ca,cp,restecg,slope,thal)\ else "No Heart Disease" ,'success') return render_template('predict.html', title='predict the heart disease', form=form)
def linear(): form = PredictForm() if form.validate_on_submit(): stock = request.form["stockTicker"] days = int(request.form["daysToPredict"]) stock_csv(stock) prediction = predictPrice(stock, days) if (days == 1): flash("Linear Regression | " + str(stock) + "'s High in " + str(days) + " day will be: $" + str(round(prediction[0], 2)) + ".") else: flash("Linear Regression | " + str(stock) + "'s High in " + str(days) + " days will be: $" + str(round(prediction[0], 2)) + ".") return render_template('linear.html', title='Linear Regression', form=form)
def home(): form = PredictForm() if form.validate_on_submit(): cleaned = pattern.sub(' ', form.example.data.lower()) new_examples = [cleaned] predictions, probs = classifier.predict(new_examples) return render_template('result.html', max_coef=classifier.get_max_coefficient(), words=classifier.get_coefficients_for( new_examples[0]), example=new_examples[0], pos_prob=probs[1], neg_prob=probs[0], form=TrainForm()) return render_template('index.html', form=form)
def home(): form = PredictForm() if form.validate_on_submit(): cleaned = pattern.sub(' ', form.example.data.lower()) new_examples = [cleaned] predictions, probs = classifier.predict(new_examples) return render_template('result.html', max_coef = classifier.get_max_coefficient(), words = classifier.get_coefficients_for(new_examples[0]), example = new_examples[0], pos_prob = probs[1], neg_prob = probs[0], form = TrainForm()) return render_template('index.html', form = form)
def indexfunc(): form=PredictForm() model = keras.models.load_model("hospital_model.h5") transformer = joblib.load("data_transformer.joblib") prediction_text='Result will appear here...' if form.validate_on_submit(): newdict={ 'age': [str(form.age.data)], 'time_in_hospital': [int(form.time_in_hospital.data)], 'num_medications': [int(form.num_medications.data)], 'number_diagnoses': [int(form.number_diagnoses.data)], 'metformin':[str(form.metformin.data)], 'chlorpropamide':[str(form.chlorpropamide.data)], 'glimepiride':[str(form.glimepiride.data)], 'tolazamide':[str(form.tolazamide.data)], 'insulin':[str(form.insulin.data)], 'race':[str(form.race.data)], 'admission_type_id':[int(form.admission_type_id.data)], 'admission_source_id':[int(form.admission_source_id.data)], 'max_glu_serum':[str(form.max_glu_serum.data)], 'A1Cresult':[str(form.A1Cresult.data)] } newds=pd.DataFrame(newdict) prediction = model.predict(transformer.transform(newds)) max_index_col = np.argmax(prediction, axis=1) if max_index_col==0: prediction_text=' The Patient will be readmitted more than 30 Times ' if max_index_col==1: prediction_text=' The Patient will be readmitted less than 30 Times ' if max_index_col==2: prediction_text=' The Patient will be not be readmitted ' return render_template('regression.html', form=form,prediction_text=prediction_text)