From dcdfe5ffb7bfa314175f2888114475a71ff0c37d Mon Sep 17 00:00:00 2001 From: vandreslime Date: Mon, 12 Dec 2022 15:46:04 +0100 Subject: [PATCH 1/3] test commit --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29 From 59d7f6da5ccef37ec5209e2130d9309e85f0cd1f Mon Sep 17 00:00:00 2001 From: vandreslime Date: Thu, 15 Dec 2022 17:26:52 +0100 Subject: [PATCH 2/3] added for digethic --- data/prediction-data.csv | 1 + requirements.txt | 121 ++++++++------------------------------- src/api.py | 10 ++-- src/api_requests.py | 15 +++++ src/predict.py | 2 +- wsgi.py | 5 +- 6 files changed, 52 insertions(+), 102 deletions(-) create mode 100644 src/api_requests.py diff --git a/data/prediction-data.csv b/data/prediction-data.csv index e62d978..7e9ba04 100644 --- a/data/prediction-data.csv +++ b/data/prediction-data.csv @@ -1,3 +1,4 @@ +zylinder;ps;gewicht;beschleunigung;baujahr 8;130;3504;12;70 8;165;3693;11.5;70 8;150;3436;11;70 diff --git a/requirements.txt b/requirements.txt index 3f9f4b1..447ef4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,101 +1,30 @@ -anyio==3.3.1 -appnope==0.1.2 -argon2-cffi==21.1.0 -attrs==21.2.0 -Babel==2.9.1 -backcall==0.2.0 -black==21.8b0 -bleach==4.1.0 -certifi==2021.5.30 -cffi==1.14.6 -charset-normalizer==2.0.4 -click==8.0.1 -cycler==0.10.0 -debugpy==1.4.3 -decorator==5.1.0 -defusedxml==0.7.1 -entrypoints==0.3 -Flask==2.0.2 +attrs==22.1.0 +certifi==2022.12.7 +charset-normalizer==2.1.1 +click==8.1.3 +exceptiongroup==1.0.4 +Flask==2.2.2 Flask-Cors==3.0.10 -idna==3.2 +idna==3.4 +importlib-metadata==5.1.0 iniconfig==1.1.1 -ipykernel==6.4.1 -ipython==7.27.0 -ipython-genutils==0.2.0 -ipywidgets==7.6.5 -itsdangerous==2.0.1 -jedi==0.18.0 -Jinja2==3.0.1 -joblib==1.0.1 -json5==0.9.6 -jsonschema==3.2.0 -jupyter-client==7.0.2 -jupyter-core==4.7.1 -jupyter-server==1.11.0 -jupyterlab==3.1.11 -jupyterlab-pygments==0.1.2 -jupyterlab-server==2.8.1 -jupyterlab-widgets==1.0.2 -kiwisolver==1.3.2 -MarkupSafe==2.0.1 -matplotlib==3.4.3 -matplotlib-inline==0.1.3 -mccabe==0.6.1 -mistune==0.8.4 -mypy-extensions==0.4.3 -nbclassic==0.3.1 -nbclient==0.5.4 -nbconvert==6.1.0 -nbformat==5.1.3 -nest-asyncio==1.5.1 -notebook==6.4.3 -numpy==1.21.2 -packaging==21.0 -pandas==1.3.3 -pandocfilters==1.4.3 -parso==0.8.2 -pathspec==0.9.0 -pexpect==4.8.0 -pickleshare==0.7.5 -Pillow==8.3.2 -platformdirs==2.3.0 +itsdangerous==2.1.2 +Jinja2==3.1.2 +joblib==1.1.0 +MarkupSafe==2.1.1 +numpy==1.22.2 +packaging==22.0 +pandas==1.4.0 pluggy==1.0.0 -prometheus-client==0.11.0 -prompt-toolkit==3.0.20 -ptyprocess==0.7.0 -py==1.11.0 -pycodestyle==2.8.0 -pycparser==2.20 -pyflakes==2.3.1 -Pygments==2.10.0 -pyparsing==2.4.7 -pyrsistent==0.18.0 -pytest==6.2.5 +pytest==7.2.0 python-dateutil==2.8.2 -pytz==2021.1 -pyzmq==22.2.1 -regex==2021.8.28 -requests==2.26.0 -requests-unixsocket==0.2.0 -scikit-learn==0.24.2 -scipy==1.7.1 -Send2Trash==1.8.0 +pytz==2021.3 +requests==2.28.1 +scikit-learn==1.0.2 +scipy==1.8.0 six==1.16.0 -sniffio==1.2.0 -terminado==0.12.1 -testpath==0.5.0 -threadpoolctl==2.2.0 -toml==0.10.2 -tomli==1.2.1 -torch==1.9.0 -tornado==6.1 -tqdm==4.62.2 -traitlets==5.1.0 -typing-extensions==3.10.0.2 -urllib3==1.26.6 -wcwidth==0.2.5 -webencodings==0.5.1 -websocket-client==1.2.1 -Werkzeug==2.0.2 -widgetsnbextension==3.5.1 -xgboost==1.4.2 +threadpoolctl==3.1.0 +tomli==2.0.1 +urllib3==1.26.13 +Werkzeug==2.2.2 +zipp==3.11.0 diff --git a/src/api.py b/src/api.py index 85b98ef..8c5d14f 100644 --- a/src/api.py +++ b/src/api.py @@ -29,7 +29,7 @@ def hello_world(): def get_training_data(): return Response(training_data.to_json(), mimetype='application/json') - +# http://127.0.0.1:5000/predict?zylinder=2&ps=100&gewicht=200&beschleunigung=10&baujahr=2000 @app.route("/predict", methods=["GET"]) def predict(): zylinder = request.args.get('zylinder') @@ -38,7 +38,9 @@ def predict(): beschleunigung = request.args.get('beschleunigung') baujahr = request.args.get('baujahr') - prediction = trained_model.predict([[zylinder, ps, gewicht, beschleunigung, baujahr]]) - - return {"result": prediction[0]} + if (zylinder and ps and gewicht and beschleunigung and baujahr): + prediction = trained_model.predict([[zylinder, ps, gewicht, beschleunigung, baujahr]]) + return {"result": prediction[0]} + else: + return Response("Please provide all necessary parameters to get a pediction: zylinder, ps, gewicht, beschleunigung, baujahr", mimetype='application/json') diff --git a/src/api_requests.py b/src/api_requests.py new file mode 100644 index 0000000..01d423d --- /dev/null +++ b/src/api_requests.py @@ -0,0 +1,15 @@ +import requests +params = { + "latitude": 52.52, + "longitude": 13.41, + "hourly": "temperature_2m" +} +headers = {"Content-Type": "application/json"} +result = requests.get( + "https://api.open-meteo.com/v1/forecast", + params=params, + headers=headers +) +print(result) +json = result.json() +print("JSON response: ", json) diff --git a/src/predict.py b/src/predict.py index 4a85a35..e795c1e 100644 --- a/src/predict.py +++ b/src/predict.py @@ -8,5 +8,5 @@ # load data that we want predictions for prediction_data = pd.read_csv('data/prediction-data.csv', sep=";") - +print(prediction_data) print(trained_model.predict(prediction_data)) diff --git a/wsgi.py b/wsgi.py index 3e00c18..34c5f8b 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,4 +1,7 @@ -from api import app +# Web server gateway interface. +# + +from src.api import app if __name__ == '__main__': From ea4e341f1688dbe9dca7849373fc6bed2763e7aa Mon Sep 17 00:00:00 2001 From: vandreslime Date: Fri, 21 Apr 2023 16:44:24 +0200 Subject: [PATCH 3/3] #232 test commit --- test.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..e69de29