Spaces:
No application file
No application file
File size: 4,526 Bytes
282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 b6d3c53 282d804 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
{
"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",
"<class 'tuple'>\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
}
|