Commit
·
0091ee4
1
Parent(s):
a45959e
dtype bug
Browse files
app.py
CHANGED
@@ -10,14 +10,20 @@ def get_stock_data(ticker, period):
|
|
10 |
return data
|
11 |
|
12 |
# Function to prepare the data for Chronos-Bolt
|
|
|
13 |
def prepare_data_chronos(data):
|
14 |
data = data.reset_index()
|
15 |
data = data.rename(columns={"Date": "timestamp", "Close": "target"})
|
16 |
data = data[["timestamp", "target"]]
|
17 |
data["item_id"] = "stock"
|
18 |
data["timestamp"] = pd.to_datetime(data["timestamp"])
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
# Function to fetch stock indices (you already defined these)
|
22 |
def get_tw0050_stocks():
|
23 |
response = requests.get('https://answerbook.david888.com/TW0050')
|
|
|
10 |
return data
|
11 |
|
12 |
# Function to prepare the data for Chronos-Bolt
|
13 |
+
|
14 |
def prepare_data_chronos(data):
|
15 |
data = data.reset_index()
|
16 |
data = data.rename(columns={"Date": "timestamp", "Close": "target"})
|
17 |
data = data[["timestamp", "target"]]
|
18 |
data["item_id"] = "stock"
|
19 |
data["timestamp"] = pd.to_datetime(data["timestamp"])
|
20 |
+
data["target"] = data["target"].astype('float32') # specify dtype for target
|
21 |
+
return TimeSeriesDataFrame(
|
22 |
+
data,
|
23 |
+
id_column="item_id",
|
24 |
+
timestamp_column="timestamp",
|
25 |
+
target_column="target"
|
26 |
+
)
|
27 |
# Function to fetch stock indices (you already defined these)
|
28 |
def get_tw0050_stocks():
|
29 |
response = requests.get('https://answerbook.david888.com/TW0050')
|