{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import hopsworks\n", "from dotenv import load_dotenv\n", "import os\n", "\n", "load_dotenv()" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected. Call `.close()` to terminate connection gracefully.\n", "\n", "Sample data from the feature view:\n", "\n", "( date open sentiment\n", "0 2023-06-26T00:00:00.000Z 250.065 0.119444\n", "1 2023-07-25T00:00:00.000Z 272.380 0.119444\n", "2 2023-01-10T00:00:00.000Z 121.070 0.102207\n", "3 2023-05-11T00:00:00.000Z 168.700 0.141296\n", "4 2023-08-01T00:00:00.000Z 266.260 0.011111\n", ".. ... ... ...\n", "464 2022-12-22T00:00:00.000Z 136.000 0.102207\n", "465 2023-08-23T00:00:00.000Z 229.340 0.024046\n", "466 2022-09-08T00:00:00.000Z 281.300 0.087306\n", "467 2023-07-06T00:00:00.000Z 278.090 0.119444\n", "468 2023-10-27T00:00:00.000Z 210.600 0.164868\n", "\n", "[469 rows x 3 columns], ticker\n", "0 TSLA\n", "1 TSLA\n", "2 TSLA\n", "3 TSLA\n", "4 TSLA\n", ".. ...\n", "464 TSLA\n", "465 TSLA\n", "466 TSLA\n", "467 TSLA\n", "468 TSLA\n", "\n", "[469 rows x 1 columns])\n" ] } ], "source": [ "import hsfs\n", "\n", "# Connection setup\n", "# Connect to Hopsworks\n", "api_key = os.getenv('hopsworks_api')\n", "connection = hsfs.connection()\n", "fs = connection.get_feature_store()\n", "\n", "# Get feature view\n", "feature_view = fs.get_feature_view(\n", " name='tesla_stocks_fv',\n", " version=1\n", ")\n", "td_version, td_job = feature_view.create_train_test_split(\n", " description = 'tesla and news sentiment training dataset',\n", " data_format = \"csv\",\n", " test_size = 0.2,\n", " coalesce = True,\n", " statistics_config={\n", " \"enabled\": True,\n", " \"histograms\": False,\n", " \"correlations\": False\n", " } \n", ")\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "( date open sentiment\n", " 0 2023-06-26T00:00:00.000Z 250.065 0.119444\n", " 1 2023-07-25T00:00:00.000Z 272.380 0.119444\n", " 2 2023-01-10T00:00:00.000Z 121.070 0.102207\n", " 3 2023-05-11T00:00:00.000Z 168.700 0.141296\n", " 4 2023-08-01T00:00:00.000Z 266.260 0.011111\n", " .. ... ... ...\n", " 464 2022-12-22T00:00:00.000Z 136.000 0.102207\n", " 465 2023-08-23T00:00:00.000Z 229.340 0.024046\n", " 466 2022-09-08T00:00:00.000Z 281.300 0.087306\n", " 467 2023-07-06T00:00:00.000Z 278.090 0.119444\n", " 468 2023-10-27T00:00:00.000Z 210.600 0.164868\n", " \n", " [469 rows x 3 columns],\n", " ticker\n", " 0 TSLA\n", " 1 TSLA\n", " 2 TSLA\n", " 3 TSLA\n", " 4 TSLA\n", " .. ...\n", " 464 TSLA\n", " 465 TSLA\n", " 466 TSLA\n", " 467 TSLA\n", " 468 TSLA\n", " \n", " [469 rows x 1 columns])" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sample_data" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }