{"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":"code","source":"from scipy.stats import pearsonr\n\nimport random\nimport numpy as np\nimport pandas as pd","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:31:11.838684Z","iopub.execute_input":"2025-05-23T07:31:11.838985Z","iopub.status.idle":"2025-05-23T07:31:14.232129Z","shell.execute_reply.started":"2025-05-23T07:31:11.838961Z","shell.execute_reply":"2025-05-23T07:31:14.230804Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_parquet('/kaggle/input/drw-crypto-market-prediction/train.parquet')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:31:14.233319Z","iopub.execute_input":"2025-05-23T07:31:14.233823Z","iopub.status.idle":"2025-05-23T07:31:42.054108Z","shell.execute_reply.started":"2025-05-23T07:31:14.233779Z","shell.execute_reply":"2025-05-23T07:31:42.053094Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def pearson_metric(y_true, y_pred):\n    corr, _ = pearsonr(y_true, y_pred)\n    return corr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:33:21.077009Z","iopub.execute_input":"2025-05-23T07:33:21.077354Z","iopub.status.idle":"2025-05-23T07:33:21.082264Z","shell.execute_reply.started":"2025-05-23T07:33:21.077330Z","shell.execute_reply":"2025-05-23T07:33:21.081190Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# TRAIN","metadata":{}},{"cell_type":"code","source":"y_true = train['label'].values","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:34:44.971446Z","iopub.execute_input":"2025-05-23T07:34:44.971767Z","iopub.status.idle":"2025-05-23T07:34:44.977071Z","shell.execute_reply.started":"2025-05-23T07:34:44.971743Z","shell.execute_reply":"2025-05-23T07:34:44.975765Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"preds = {\n    \"Perfect\": y_true.copy(),\n    \"Shifted\": y_true + 100,\n    \"Noisy\": y_true + np.random.normal(0, 0.1 * np.std(y_true), size=len(y_true)),\n    \"Random\": np.random.permutation(y_true),\n    \"Inverted\": -y_true,\n}\n\nprint(\"Pearson Correlation Scores:\")\nfor name, pred in preds.items():\n    corr, _ = pearsonr(y_true, pred)\n    print(f\"{name:10s}: {corr:.4f}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:38:54.373277Z","iopub.execute_input":"2025-05-23T07:38:54.373593Z","iopub.status.idle":"2025-05-23T07:38:54.485877Z","shell.execute_reply.started":"2025-05-23T07:38:54.373571Z","shell.execute_reply":"2025-05-23T07:38:54.484979Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"The Pearson correlation coefficient measures the linear relationship between two variables by comparing how they co-vary. However, if your predicted values are constant — such as always equal to the mean, median, or zero — then the standard deviation of the predictions is zero.","metadata":{}},{"cell_type":"markdown","source":"# TEST\n\n**For randomly generated numbers within the same range as the training labels (i.e., between the minimum and maximum of y_train), the Pearson correlation score is 0.00148**","metadata":{}},{"cell_type":"code","source":"sub = pd.read_csv('/kaggle/input/drw-crypto-market-prediction/sample_submission.csv')\n\ny_min = train['label'].min()\ny_max = train['label'].max()\n\nsub['prediction'] = np.random.uniform(low=y_min, high=y_max, size=len(sub))\n\nsub.to_csv('submission.csv', index = False)\nsub","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-23T07:40:28.073240Z","iopub.execute_input":"2025-05-23T07:40:28.073520Z","iopub.status.idle":"2025-05-23T07:40:29.723100Z","shell.execute_reply.started":"2025-05-23T07:40:28.073501Z","shell.execute_reply":"2025-05-23T07:40:29.722119Z"}},"outputs":[],"execution_count":null}]}