{"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":102335,"databundleVersionId":12518947,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\n\nimport pandas as pd\nimport polars as pl\nimport numpy as np\n\nimport kaggle_evaluation.cmi_inference_server","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-08-12T18:45:09.331419Z","iopub.execute_input":"2025-08-12T18:45:09.331871Z","iopub.status.idle":"2025-08-12T18:45:09.944500Z","shell.execute_reply.started":"2025-08-12T18:45:09.331839Z","shell.execute_reply":"2025-08-12T18:45:09.943376Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"The evaluation API requires that you set up a server which will respond to inference requests. We have already defined the server; you just need write the predict function. When we evaluate your submission on the hidden test set the client defined in the gateway will run in a different container with direct access to the hidden test set and hand off the one sequence at a time.\n\nYour code will always have access to the published copies of the files.","metadata":{"execution":{"iopub.status.busy":"2025-05-29T22:29:18.955791Z","iopub.execute_input":"2025-05-29T22:29:18.956193Z","iopub.status.idle":"2025-05-29T22:29:18.965179Z","shell.execute_reply.started":"2025-05-29T22:29:18.956169Z","shell.execute_reply":"2025-05-29T22:29:18.963797Z"}}},{"cell_type":"code","source":"def predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -> str:\n    # Check if any column has null values\n    has_nulls = demographics.null_count().sum_horizontal().item() > 0\n    \n    if has_nulls:\n        return ''\n    \n    return 'Text on phone'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-12T18:45:09.946712Z","iopub.execute_input":"2025-08-12T18:45:09.947379Z","iopub.status.idle":"2025-08-12T18:45:09.954431Z","shell.execute_reply.started":"2025-08-12T18:45:09.947342Z","shell.execute_reply":"2025-08-12T18:45:09.953259Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"inference_server = kaggle_evaluation.cmi_inference_server.CMIInferenceServer(predict)\n\nif os.getenv('KAGGLE_IS_COMPETITION_RERUN'):\n    inference_server.serve()\nelse:\n    inference_server.run_local_gateway(\n        data_paths=(\n            '/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv',\n            '/kaggle/input/cmi-detect-behavior-with-sensor-data/test_demographics.csv',\n        )\n    )","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-12T18:45:09.955441Z","iopub.execute_input":"2025-08-12T18:45:09.955736Z","iopub.status.idle":"2025-08-12T18:45:11.162691Z","shell.execute_reply.started":"2025-08-12T18:45:09.955714Z","shell.execute_reply":"2025-08-12T18:45:11.160818Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}