Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/prediction-data.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down
121 changes: 25 additions & 96 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
15 changes: 15 additions & 0 deletions src/api_requests.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion src/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Empty file added test.py
Empty file.
Empty file added test.txt
Empty file.
5 changes: 4 additions & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from api import app
# Web server gateway interface.
#

from src.api import app


if __name__ == '__main__':
Expand Down