├── Dockerfile ├── README.md ├── app.py ├── deployment_28042020.pkl ├── requirements.txt ├── static └── style.css └── templates └── home.html /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | RUN pip install virtualenv 4 | ENV VIRTUAL_ENV=/venv 5 | RUN virtualenv venv -p python3 6 | ENV PATH="VIRTUAL_ENV/bin:$PATH" 7 | 8 | WORKDIR /app 9 | ADD . /app 10 | 11 | # Install dependencies 12 | RUN pip install -r requirements.txt 13 | 14 | # Expose port 15 | EXPOSE 5000 16 | 17 | # Run the application: 18 | CMD ["python", "app.py"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deployment on Microsoft Azure using docker container -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,request, url_for, redirect, render_template, jsonify 2 | from pycaret.regression import * 3 | import pandas as pd 4 | import pickle 5 | import numpy as np 6 | 7 | app = Flask(__name__) 8 | 9 | model=load_model('deployment_28042020') 10 | 11 | @app.route('/') 12 | def home(): 13 | return render_template("home.html") 14 | 15 | 16 | @app.route('/predict',methods=['POST']) 17 | def predict(): 18 | int_features=[x for x in request.form.values()] 19 | final=np.array(int_features) 20 | col = ['age', 'sex', 'bmi', 'children', 'smoker', 'region'] 21 | data_unseen = pd.DataFrame([final], columns = col) 22 | print(int_features) 23 | print(final) 24 | prediction=predict_model(model, data=data_unseen, round = 0) 25 | prediction=int(prediction.Label[0]) 26 | return render_template('home.html',pred='Expected Bill will be {}'.format(prediction)) 27 | 28 | @app.route('/predict_api',methods=['POST']) 29 | def predict_api(): 30 | ''' 31 | For direct API calls trought request 32 | ''' 33 | data = request.get_json(force=True) 34 | data_unseen = pd.DataFrame([data]) 35 | prediction = predict_model(model, data=data_unseen) 36 | output = prediction.Label[0] 37 | return jsonify(output) 38 | 39 | if __name__ == '__main__': 40 | app.run(host='0.0.0.0', debug = True) -------------------------------------------------------------------------------- /deployment_28042020.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pycaret/pycaret-deployment-azure/8efc8feb8ba6e6ddc4efc3682890b75d666aa651/deployment_28042020.pkl -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pycaret==1.0.0 2 | Flask==1.1.1 3 | Jinja2==2.10.1 4 | gunicorn==19.9.0 5 | certifi==2019.11.28 6 | itsdangerous==1.1.0 7 | numpy>=1.17 -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Open+Sans); 2 | .btn { display: inline-block; *display: inline; *zoom: 1; padding: 4px 10px 4px; margin-bottom: 0; font-size: 13px; line-height: 18px; color: #333333; text-align: center;text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); vertical-align: middle; background-color: #f5f5f5; background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); background-image: linear-gradient(top, #ffffff, #e6e6e6); background-repeat: repeat-x; filter: progid:dximagetransform.microsoft.gradient(startColorstr=#ffffff, endColorstr=#e6e6e6, GradientType=0); border-color: #e6e6e6 #e6e6e6 #e6e6e6; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); border: 1px solid #e6e6e6; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); cursor: pointer; *margin-left: .3em; } 3 | .btn:hover, .btn:active, .btn.active, .btn.disabled, .btn[disabled] { background-color: #e6e6e6; } 4 | .btn-large { padding: 9px 14px; font-size: 15px; line-height: normal; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } 5 | .btn:hover { color: #333333; text-decoration: none; background-color: #e6e6e6; background-position: 0 -15px; -webkit-transition: background-position 0.1s linear; -moz-transition: background-position 0.1s linear; -ms-transition: background-position 0.1s linear; -o-transition: background-position 0.1s linear; transition: background-position 0.1s linear; } 6 | .btn-primary, .btn-primary:hover { text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); color: #ffffff; } 7 | .btn-primary.active { color: rgba(255, 255, 255, 0.75); } 8 | .btn-primary { background-color: #4a77d4; background-image: -moz-linear-gradient(top, #6eb6de, #4a77d4); background-image: -ms-linear-gradient(top, #6eb6de, #4a77d4); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#6eb6de), to(#4a77d4)); background-image: -webkit-linear-gradient(top, #6eb6de, #4a77d4); background-image: -o-linear-gradient(top, #6eb6de, #4a77d4); background-image: linear-gradient(top, #6eb6de, #4a77d4); background-repeat: repeat-x; filter: progid:dximagetransform.microsoft.gradient(startColorstr=#6eb6de, endColorstr=#4a77d4, GradientType=0); border: 1px solid #3762bc; text-shadow: 1px 1px 1px rgba(0,0,0,0.4); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.5); } 9 | .btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] { filter: none; background-color: #4a77d4; } 10 | .btn-block { width: 100%; display:block; } 11 | 12 | * { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; -ms-box-sizing:border-box; -o-box-sizing:border-box; box-sizing:border-box; } 13 | 14 | html { width: 100%; height:100%; overflow:hidden; } 15 | 16 | body { 17 | width: 100%; 18 | height:100%; 19 | font-family: 'Open Sans', sans-serif; 20 | background: #092756; 21 | color: #fff; 22 | font-size: 18px; 23 | text-align:center; 24 | letter-spacing:1.2px; 25 | background: -moz-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%),-moz-linear-gradient(top, rgba(57,173,219,.25) 0%, rgba(42,60,87,.4) 100%), -moz-linear-gradient(-45deg, #670d10 0%, #092756 100%); 26 | background: -webkit-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -webkit-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -webkit-linear-gradient(-45deg, #670d10 0%,#092756 100%); 27 | background: -o-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -o-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -o-linear-gradient(-45deg, #670d10 0%,#092756 100%); 28 | background: -ms-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), -ms-linear-gradient(top, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), -ms-linear-gradient(-45deg, #670d10 0%,#092756 100%); 29 | background: -webkit-radial-gradient(0% 100%, ellipse cover, rgba(104,128,138,.4) 10%,rgba(138,114,76,0) 40%), linear-gradient(to bottom, rgba(57,173,219,.25) 0%,rgba(42,60,87,.4) 100%), linear-gradient(135deg, #670d10 0%,#092756 100%); 30 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3E1D6D', endColorstr='#092756',GradientType=1 ); 31 | 32 | } 33 | .login { 34 | position: absolute; 35 | top: 40%; 36 | left: 50%; 37 | margin: -150px 0 0 -150px; 38 | width:400px; 39 | height:400px; 40 | } 41 | 42 | .login h1 { color: #fff; text-shadow: 0 0 10px rgba(0,0,0,0.3); letter-spacing:1px; text-align:center; } 43 | 44 | input { 45 | width: 100%; 46 | margin-bottom: 10px; 47 | background: rgba(0,0,0,0.3); 48 | border: none; 49 | outline: none; 50 | padding: 10px; 51 | font-size: 13px; 52 | color: #fff; 53 | text-shadow: 1px 1px 1px rgba(0,0,0,0.3); 54 | border: 1px solid rgba(0,0,0,0.3); 55 | border-radius: 4px; 56 | box-shadow: inset 0 -5px 45px rgba(100,100,100,0.2), 0 1px 1px rgba(255,255,255,0.2); 57 | -webkit-transition: box-shadow .5s ease; 58 | -moz-transition: box-shadow .5s ease; 59 | -o-transition: box-shadow .5s ease; 60 | -ms-transition: box-shadow .5s ease; 61 | transition: box-shadow .5s ease; 62 | } 63 | input:focus { box-shadow: inset 0 -5px 45px rgba(100,100,100,0.4), 0 1px 1px rgba(255,255,255,0.2); } -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Predict Insurance Bill 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

Predict Insurance Bill

18 | 19 | 20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 28 | 29 | 30 |
31 | 32 |
33 |
34 | 35 | 36 |
37 | {{pred}} 38 | 39 | 40 | --------------------------------------------------------------------------------