{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":96164,"databundleVersionId":11418275,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Prophet\n\nThis notebook attempted to use Prophet, a library for time series forecasting. Unfortunately, this approach doesn't work in this competition, because the test dataset does not have timestamps.","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom prophet import Prophet\n\n# Load train data\ntrain_df = pd.read_parquet('/kaggle/input/drw-crypto-market-prediction/train.parquet').reset_index()\n\n# Format data for Prophet\n# Prophet expects: 'ds' = datetime, 'y' = target\ndf_prophet = train_df[['timestamp', 'label']].rename(columns={'timestamp': 'ds', 'label': 'y'})\n\n# Convert to datetime if needed\ndf_prophet['ds'] = pd.to_datetime(df_prophet['ds'], unit='s')  # or unit='ms' depending on format\n\n# Fit model\nmodel = Prophet(daily_seasonality=True, weekly_seasonality=True)\nmodel.fit(df_prophet)\n\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:40:45.959148Z","iopub.execute_input":"2025-05-27T10:40:45.959471Z","iopub.status.idle":"2025-05-27T10:45:32.867771Z","shell.execute_reply.started":"2025-05-27T10:40:45.959448Z","shell.execute_reply":"2025-05-27T10:45:32.866774Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:45:32.868913Z","iopub.execute_input":"2025-05-27T10:45:32.869252Z","iopub.status.idle":"2025-05-27T10:45:32.929255Z","shell.execute_reply.started":"2025-05-27T10:45:32.869223Z","shell.execute_reply":"2025-05-27T10:45:32.928354Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:45:32.931398Z","iopub.execute_input":"2025-05-27T10:45:32.931666Z","iopub.status.idle":"2025-05-27T10:45:32.936802Z","shell.execute_reply.started":"2025-05-27T10:45:32.931646Z","shell.execute_reply":"2025-05-27T10:45:32.936028Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prepare test timestamps\ntest_df = pd.read_parquet('/kaggle/input/drw-crypto-market-prediction/test.parquet').reset_index()\n\ntest_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:45:32.937686Z","iopub.execute_input":"2025-05-27T10:45:32.937916Z","iopub.status.idle":"2025-05-27T10:46:00.877647Z","shell.execute_reply.started":"2025-05-27T10:45:32.937897Z","shell.execute_reply":"2025-05-27T10:46:00.876932Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Create dummy datetime index for test: assume 1-min intervals\ntest_df = test_df.reset_index(drop=True)\nstart_time = train_df['timestamp'].max() + pd.Timedelta(minutes=1)\ntest_df['timestamp'] = pd.date_range(start=start_time, periods=len(test_df), freq='T')\n\nX_test = TimeSeries.from_dataframe(test, time_col='timestamp', value_cols=features)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:46:00.878530Z","iopub.execute_input":"2025-05-27T10:46:00.878779Z","iopub.status.idle":"2025-05-27T10:46:02.469541Z","shell.execute_reply.started":"2025-05-27T10:46:00.878760Z","shell.execute_reply":"2025-05-27T10:46:02.468479Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"future = test_df[['ID']].rename(columns={'ID': 'ds'})\nfuture['ds'] = pd.to_datetime(future['ds'], unit='s')  # or unit='ms'\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:46:02.470116Z","iopub.status.idle":"2025-05-27T10:46:02.470361Z","shell.execute_reply.started":"2025-05-27T10:46:02.470242Z","shell.execute_reply":"2025-05-27T10:46:02.470254Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Forecast\nforecast = model.predict(future)\n\n# Prepare submission\nsubmission = pd.read_csv('/kaggle/input/drw-crypto-market-prediction/sample_submission.csv')\nsubmission['label'] = forecast['yhat']\nsubmission.to_csv('submission_prophet.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-27T10:46:02.472008Z","iopub.status.idle":"2025-05-27T10:46:02.472359Z","shell.execute_reply.started":"2025-05-27T10:46:02.472181Z","shell.execute_reply":"2025-05-27T10:46:02.472198Z"}},"outputs":[],"execution_count":null}]}