{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['/home/robert/anaconda3/lib/python312.zip', '/home/robert/anaconda3/lib/python3.12', '/home/robert/anaconda3/lib/python3.12/lib-dynload', '', '/home/robert/Documents/scalable-ml/lab1-new/hbg-weather/.venv/lib/python3.12/site-packages']\n", "Connected. Call `.close()` to terminate connection gracefully.\n", "\n", "Logged in to project, explore it here https://c.app.hopsworks.ai:443/p/1160344\n", "2024-11-20 18:13:36,962 WARNING: using legacy validation callback\n", "Connected. Call `.close()` to terminate connection gracefully.\n", "Connected. Call `.close()` to terminate connection gracefully.\n" ] } ], "source": [ "import datetime\n", "import pandas as pd\n", "from xgboost import XGBRegressor\n", "import hopsworks\n", "import json\n", "from functions import util\n", "import os\n", "\n", "# Set up\n", "\n", "api_key = os.getenv('HOPSWORKS_API_KEY')\n", "project_name = os.getenv('HOPSWORKS_PROJECT')\n", "\n", "project = hopsworks.login(project=project_name, api_key_value=api_key)\n", "fs = project.get_feature_store() \n", "secrets = util.secrets_api(project.name)\n", "location_str = secrets.get_secret(\"SENSOR_LOCATION_JSON\").value\n", "location = json.loads(location_str)\n", "country=location['country']\n", "city=location['city']\n", "street=location['street']\n", "\n", "AQI_API_KEY = secrets.get_secret(\"AQI_API_KEY\").value\n", "location_str = secrets.get_secret(\"SENSOR_LOCATION_JSON\").value\n", "location = json.loads(location_str)\n", "\n", "today = datetime.datetime.now() - datetime.timedelta(0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Finished: Reading data from Hopsworks, using Hopsworks Feature Query Service (1.80s) \n" ] }, { "data": { "text/html": [ "
\n", " | past_air_quality | \n", "date | \n", "temperature_2m_mean | \n", "precipitation_sum | \n", "wind_speed_10m_max | \n", "wind_direction_10m_dominant | \n", "city | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "42.354327 | \n", "2019-12-09 00:00:00+00:00 | \n", "14.900082 | \n", "0.2 | \n", "9.422101 | \n", "11.842063 | \n", "lahore | \n", "
1 | \n", "42.354327 | \n", "2019-12-10 00:00:00+00:00 | \n", "14.052165 | \n", "0.0 | \n", "8.534353 | \n", "69.443985 | \n", "lahore | \n", "
2 | \n", "264.953334 | \n", "2019-12-11 00:00:00+00:00 | \n", "14.975082 | \n", "2.3 | \n", "8.089993 | \n", "99.649574 | \n", "lahore | \n", "
3 | \n", "199.996670 | \n", "2019-12-12 00:00:00+00:00 | \n", "13.347999 | \n", "15.8 | \n", "16.904673 | \n", "72.617531 | \n", "lahore | \n", "
4 | \n", "125.423336 | \n", "2019-12-13 00:00:00+00:00 | \n", "12.170915 | \n", "0.0 | \n", "11.525623 | \n", "243.006943 | \n", "lahore | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1796 | \n", "164.996668 | \n", "2024-11-15 00:00:00+00:00 | \n", "20.023001 | \n", "1.6 | \n", "12.982480 | \n", "17.241518 | \n", "lahore | \n", "
1797 | \n", "188.106669 | \n", "2024-11-16 00:00:00+00:00 | \n", "18.385500 | \n", "0.0 | \n", "6.330782 | \n", "24.163300 | \n", "lahore | \n", "
1798 | \n", "128.040002 | \n", "2024-11-17 00:00:00+00:00 | \n", "17.897999 | \n", "0.0 | \n", "7.040739 | \n", "297.781921 | \n", "lahore | \n", "
1799 | \n", "84.966668 | \n", "2024-11-17 00:00:00+00:00 | \n", "17.897999 | \n", "0.0 | \n", "7.040739 | \n", "297.781921 | \n", "lahore | \n", "
1800 | \n", "84.966667 | \n", "2024-11-19 00:00:00+00:00 | \n", "21.299999 | \n", "0.0 | \n", "6.618519 | \n", "292.380188 | \n", "lahore | \n", "
1801 rows × 7 columns
\n", "