Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 2.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  1. from flask import Flask, render_template, request
  2. from customer_churn.pipeline.prediction import CustomData, PredictPipeline
  3. application = Flask(__name__)
  4. app=application
  5. @app.route('/')
  6. def index():
  7. return render_template('index.html')
  8. @ app.route('/predictdata', methods=['GET', 'POST'])
  9. def predict_datapoint():
  10. if request.method=='GET':
  11. return render_template('home.html')
  12. else:
  13. data=CustomData(
  14. SeniorCitizen=request.form.get('SeniorCitizen'),
  15. MonthlyCharges=float(request.form.get('MonthlyCharges')),
  16. TotalCharges=float(request.form.get('TotalCharges')),
  17. gender=request.form.get('gender'),
  18. Partner=request.form.get('Partner'),
  19. Dependents=request.form.get('Dependents'),
  20. PhoneService=request.form.get('PhoneService'),
  21. MultipleLines=request.form.get('MultipleLines'),
  22. OnlineSecurity=request.form.get('OnlineSecurity'),
  23. DeviceProtection=request.form.get('DeviceProtection'),
  24. TechSupport=request.form.get('TechSupport'),
  25. StreamingTV=request.form.get('StreamingTV'),
  26. StreamingMovies=request.form.get('StreamingMovies'),
  27. Contract=request.form.get('Contract'),
  28. PaperlessBilling=request.form.get('PaperlessBilling'),
  29. PaymentMethod=request.form.get('PaymentMethod'),
  30. TenureMonths=int(request.form.get('TenureMonths')),
  31. City=request.form.get('City'),
  32. InternetService=request.form.get('InternetService'),
  33. OnlineBackup=request.form.get('OnlineBackup'),
  34. ChurnScore=int(request.form.get('ChurnScore')),
  35. CLTV=int(request.form.get('CLTV'))
  36. )
  37. pred_df = data.get_data_as_data_frame()
  38. print(pred_df)
  39. predict_pipeline = PredictPipeline()
  40. results = predict_pipeline.predict(pred_df)
  41. return render_template('home.html', results=results)
  42. if __name__=="__main__":
  43. app.run(host='0.0.0.0')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...