└── MLForCloudDeployment_Heroku ├── MLForCloudDeployment_Heroku.pdf ├── app.py ├── finalized_model.pickle ├── requirements.txt ├── static └── css │ ├── main.css │ └── style.css ├── templates ├── base.html ├── index.html └── results.html └── train.py /MLForCloudDeployment_Heroku/MLForCloudDeployment_Heroku.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iNeuronai/MachineLearningModelToHeroku/cc979fb3cd8146f515e925abca6701de6bb581ab/MLForCloudDeployment_Heroku/MLForCloudDeployment_Heroku.pdf -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/app.py: -------------------------------------------------------------------------------- 1 | 2 | # importing the necessary dependencies 3 | from flask import Flask, render_template, request,jsonify 4 | from flask_cors import CORS,cross_origin 5 | import pickle 6 | 7 | app = Flask(__name__) # initializing a flask app 8 | 9 | @app.route('/',methods=['GET']) # route to display the home page 10 | @cross_origin() 11 | def homePage(): 12 | return render_template("index.html") 13 | 14 | @app.route('/predict',methods=['POST','GET']) # route to show the predictions in a web UI 15 | @cross_origin() 16 | def index(): 17 | if request.method == 'POST': 18 | try: 19 | # reading the inputs given by the user 20 | gre_score=float(request.form['gre_score']) 21 | toefl_score = float(request.form['toefl_score']) 22 | university_rating = float(request.form['university_rating']) 23 | sop = float(request.form['sop']) 24 | lor = float(request.form['lor']) 25 | cgpa = float(request.form['cgpa']) 26 | is_research = request.form['research'] 27 | if(is_research=='yes'): 28 | research=1 29 | else: 30 | research=0 31 | filename = 'finalized_model.pickle' 32 | loaded_model = pickle.load(open(filename, 'rb')) # loading the model file from the storage 33 | # predictions using the loaded model file 34 | prediction=loaded_model.predict([[gre_score,toefl_score,university_rating,sop,lor,cgpa,research]]) 35 | print('prediction is', prediction) 36 | # showing the prediction results in a UI 37 | return render_template('results.html',prediction=round(100*prediction[0])) 38 | except Exception as e: 39 | print('The Exception message is: ',e) 40 | return 'something is wrong' 41 | # return render_template('results.html') 42 | else: 43 | return render_template('index.html') 44 | 45 | 46 | 47 | if __name__ == "__main__": 48 | #app.run(host='127.0.0.1', port=8001, debug=True) 49 | app.run(debug=True) # running the app -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/finalized_model.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iNeuronai/MachineLearningModelToHeroku/cc979fb3cd8146f515e925abca6701de6bb581ab/MLForCloudDeployment_Heroku/finalized_model.pickle -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2019.11.28 2 | Click==7.0 3 | Flask==1.1.1 4 | Flask-Cors==3.0.8 5 | gunicorn==20.0.4 6 | itsdangerous==1.1.0 7 | Jinja2==2.10.3 8 | joblib==0.14.0 9 | MarkupSafe==1.1.1 10 | numpy==1.17.4 11 | scikit-learn==0.21.3 12 | scipy==1.3.2 13 | six==1.13.0 14 | Werkzeug==0.16.0 15 | -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/static/css/main.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin: 0; 3 | font-family: sans-serif; 4 | } 5 | 6 | .content { 7 | margin: 0 auto; 8 | width: 400px; 9 | } 10 | 11 | table, td, th { 12 | border: 1px solid #aaa; 13 | } 14 | 15 | table { 16 | border-collapse: collapse; 17 | width: 100%; 18 | } 19 | 20 | th { 21 | height: 30px; 22 | } 23 | 24 | td { 25 | text-align: center; 26 | padding: 5px; 27 | } 28 | 29 | .form { 30 | margin-top: 20px; 31 | } 32 | 33 | #content { 34 | width: 70%; 35 | } -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/static/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #91ced4; 3 | } 4 | body * { 5 | box-sizing: border-box; 6 | } 7 | 8 | .header { 9 | background-color: #327a81; 10 | color: white; 11 | font-size: 1.5em; 12 | padding: 1rem; 13 | text-align: center; 14 | text-transform: uppercase; 15 | } 16 | 17 | img { 18 | border-radius: 50%; 19 | height: 60px; 20 | width: 60px; 21 | } 22 | 23 | .table-users { 24 | border: 1px solid #327a81; 25 | border-radius: 10px; 26 | box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1); 27 | max-width: calc(100% - 2em); 28 | margin: 1em auto; 29 | overflow: hidden; 30 | width: 800px; 31 | } 32 | 33 | table { 34 | width: 100%; 35 | } 36 | table td, table th { 37 | color: #2b686e; 38 | padding: 10px; 39 | } 40 | table td { 41 | text-align: center; 42 | vertical-align: middle; 43 | } 44 | table td:last-child { 45 | font-size: 0.95em; 46 | line-height: 1.4; 47 | text-align: left; 48 | } 49 | table th { 50 | background-color: #daeff1; 51 | font-weight: 300; 52 | } 53 | table tr:nth-child(2n) { 54 | background-color: white; 55 | } 56 | table tr:nth-child(2n+1) { 57 | background-color: #edf7f8; 58 | } 59 | 60 | @media screen and (max-width: 700px) { 61 | table, tr, td { 62 | display: block; 63 | } 64 | 65 | td:first-child { 66 | position: absolute; 67 | top: 50%; 68 | -webkit-transform: translateY(-50%); 69 | transform: translateY(-50%); 70 | width: 100px; 71 | } 72 | td:not(:first-child) { 73 | clear: both; 74 | margin-left: 100px; 75 | padding: 4px 20px 4px 90px; 76 | position: relative; 77 | text-align: left; 78 | } 79 | td:not(:first-child):before { 80 | color: #91ced4; 81 | content: ''; 82 | display: block; 83 | left: 0; 84 | position: absolute; 85 | } 86 | td:nth-child(2):before { 87 | content: 'Name:'; 88 | } 89 | td:nth-child(3):before { 90 | content: 'Email:'; 91 | } 92 | td:nth-child(4):before { 93 | content: 'Phone:'; 94 | } 95 | td:nth-child(5):before { 96 | content: 'Comments:'; 97 | } 98 | 99 | tr { 100 | padding: 10px 0; 101 | position: relative; 102 | } 103 | tr:first-child { 104 | display: none; 105 | } 106 | } 107 | @media screen and (max-width: 500px) { 108 | .header { 109 | background-color: transparent; 110 | color: white; 111 | font-size: 2em; 112 | font-weight: 700; 113 | padding: 0; 114 | text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1); 115 | } 116 | 117 | img { 118 | border: 3px solid; 119 | border-color: #daeff1; 120 | height: 100px; 121 | margin: 0.5rem 0; 122 | width: 100px; 123 | } 124 | 125 | td:first-child { 126 | background-color: #c8e7ea; 127 | border-bottom: 1px solid #91ced4; 128 | border-radius: 10px 10px 0 0; 129 | position: relative; 130 | top: 0; 131 | -webkit-transform: translateY(0); 132 | transform: translateY(0); 133 | width: 100%; 134 | } 135 | td:not(:first-child) { 136 | margin: 0; 137 | padding: 5px 1em; 138 | width: 100%; 139 | } 140 | td:not(:first-child):before { 141 | font-size: .8em; 142 | padding-top: 0.3em; 143 | position: relative; 144 | } 145 | td:last-child { 146 | padding-bottom: 1rem !important; 147 | } 148 | 149 | tr { 150 | background-color: white !important; 151 | border: 1px solid #6cbec6; 152 | border-radius: 10px; 153 | box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1); 154 | margin: 0.5rem 0; 155 | padding: 0; 156 | } 157 | 158 | .table-users { 159 | border: none; 160 | box-shadow: none; 161 | overflow: visible; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | {% block head %}{% endblock %} 9 | 10 | 11 | {% block body %}{% endblock %} 12 | 13 | -------------------------------------------------------------------------------- /MLForCloudDeployment_Heroku/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block head %} 4 | 5 |Your chance for admission is {{prediction}} percent
23 |