-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28bf721
commit 8299be8
Showing
6 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
flask = "*" | ||
gunicorn = "*" | ||
scikit-learn = "==1.0" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.8" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn predict:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pickle | ||
|
||
from flask import Flask | ||
from flask import request | ||
from flask import jsonify | ||
|
||
|
||
model_file = 'model1.bin' | ||
dv_file = 'dv.bin' | ||
|
||
with open(model_file, 'rb') as f_model: | ||
model = pickle.load(f_model) | ||
|
||
with open(dv_file, 'rb') as f_dv: | ||
dv = pickle.load(f_dv) | ||
|
||
app = Flask('churn_service') | ||
|
||
@app.route('/predict', methods=['POST']) | ||
def predict(): | ||
customer = request.get_json() | ||
|
||
X = dv.transform([customer]) | ||
y_pred = model.predict_proba(X)[0, 1] | ||
|
||
result = { | ||
'churn_probability': float(y_pred), | ||
} | ||
|
||
return jsonify(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True, host='0.0.0.0', port=9696) |
Binary file not shown.