{
  "id": 589480,
  "title": "Error \"Notebook Inference Server Never Started\"",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/589480",
  "author_name": "Giancarlo Ronci",
  "post_date": "2025-07-13T09:13:21.440000",
  "votes": 0,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Good morning, everyone. I have a issue submitting the ML model for the \"CMI - Detect Behavior with Sensor Data\" competition. <br>\nI wanted to ask you for some help (which should be very quick) in submitting the notebook, as I repeatedly get the error \"Notebook Inference Server Never Started.\" Could you please point me to the lines of code that solve this problem? I'll also leave you the code for my notebook. I would be grateful if you could help me submit my result.</p>\n<p>Code:</p>\n<h1>-------------------------</h1>\n<h1>STEP 1 - IMPORTS &amp; LOAD DATA</h1>\n<h1>-------------------------</h1>\n<p>import pandas as pd<br>\nimport numpy as np<br>\nfrom lightgbm import LGBMClassifier<br>\nfrom sklearn.model_selection import train_test_split<br>\nfrom sklearn.preprocessing import LabelEncoder<br>\nfrom sklearn.metrics import f1_score</p>\n<h1>-------------------------</h1>\n<h1>STEP 2 - READ TRAINING DATA</h1>\n<h1>-------------------------</h1>\n<p>df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/train.csv\")</p>\n<h1>Select columns</h1>\n<p>imu_cols = ['acc_x', 'acc_y', 'acc_z', 'rot_w', 'rot_x', 'rot_y', 'rot_z']<br>\nthm_cols = [col for col in df.columns if col.startswith('thm_')]<br>\ntof_cols = [col for col in df.columns if col.startswith('tof_')]<br>\nsensor_cols = imu_cols + thm_cols + tof_cols</p>\n<h1>Keep only needed columns</h1>\n<p>df = df[['sequence_id', 'sequence_type', 'gesture'] + sensor_cols]</p>\n<h1>-------------------------</h1>\n<h1>STEP 3 - AGGREGATE FEATURES</h1>\n<h1>-------------------------</h1>\n<p>agg_funcs = ['mean', 'std', 'min', 'max']<br>\nX = df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)<br>\nX.columns = ['_'.join(col) for col in X.columns]<br>\nX.reset_index(inplace=True)</p>\n<h1>-------------------------</h1>\n<h1>STEP 4 - PREPARE LABELS</h1>\n<h1>-------------------------</h1>\n<p>labels = df[['sequence_id', 'sequence_type', 'gesture']].drop_duplicates('sequence_id')<br>\nlabels['gesture_label'] = labels.apply(<br>\n    lambda row: row['gesture'] if row['sequence_type'] == 'Target' else 'non_target', axis=1<br>\n)</p>\n<p>top_gestures = labels['gesture_label'].value_counts().head(3).index.tolist()<br>\nlabels['gesture_label'] = labels['gesture_label'].apply(<br>\n    lambda x: x if x in top_gestures else 'non_target'<br>\n)</p>\n<h1>Merge</h1>\n<p>data = pd.merge(X, labels[['sequence_id', 'gesture_label']], on='sequence_id')</p>\n<h1>Encode labels</h1>\n<p>le = LabelEncoder()<br>\ndata['gesture_encoded'] = le.fit_transform(data['gesture_label'])</p>\n<h1>-------------------------</h1>\n<h1>STEP 5 - TRAIN MODEL</h1>\n<h1>-------------------------</h1>\n<p>X_mc = data.drop(columns=['sequence_id', 'gesture_label', 'gesture_encoded'])<br>\ny_mc = data['gesture_encoded']</p>\n<p>X_train, X_val, y_train, y_val = train_test_split(X_mc, y_mc, test_size=0.2, random_state=42, stratify=y_mc)</p>\n<p>model = LGBMClassifier(random_state=42)<br>\nmodel.fit(X_train, y_train)</p>\n<h1>-------------------------</h1>\n<h1>STEP 6 - DEFINE PREDICT FUNCTION</h1>\n<h1>-------------------------</h1>\n<p>def predict(test_df: pd.DataFrame) -&gt; pd.DataFrame:<br>\n    test_df = test_df[['sequence_id'] + sensor_cols]<br>\n    X_test = test_df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)<br>\n    X_test.columns = ['_'.join(col) for col in X_test.columns]<br>\n    X_test.reset_index(inplace=True)</p>\n<pre><code>y_pred_encoded = model(X_test(=[]))\ny_pred_label = le(y_pred_encoded)\n\nsubmission = pd({\n    : X_test,\n    : y_pred_label\n})\nsubmission(, index=False)\nreturn submission\n</code></pre>\n<h1>-------------------------</h1>\n<h1>STEP 7 - CREATE SUBMISSION FILE</h1>\n<h1>-------------------------</h1>\n<p>test_df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv\")<br>\nsubmission = predict(test_df)<br>\nprint(\"✅ submission.parquet created.\")</p>",
  "messages": [
    {
      "id": 3248405,
      "postDate": "2025-07-14T13:59:56.497Z",
      "content": "<p><a href=\"https://www.kaggle.com/giancarloronci\" target=\"_blank\">@giancarloronci</a> The issue is you're trying to create a parquet file manually but this competition uses an inference server instead. That's why you're getting the \"Notebook Inference Server Never Started\" error - you're missing the inference server setup completely.</p>\n<p>You need to import kaggle_evaluation.cmi_inference_server and set it up properly. Also your predict function should just return the prediction string, not create any files. The inference server handles all the submission stuff automatically, so remove that parquet creation part.</p>\n<p>Basically this competition format is different from the usual submit-a-file approach - it runs your prediction function through their server instead.</p>\n<p>Heres an example:<br>\n<a href=\"https://www.kaggle.com/code/sohier/cmi-2025-demo-submission\" target=\"_blank\">Example</a><br>\nHope it helps!</p>",
      "rawMarkdown": "@giancarloronci The issue is you're trying to create a parquet file manually but this competition uses an inference server instead. That's why you're getting the \"Notebook Inference Server Never Started\" error - you're missing the inference server setup completely.\n\nYou need to import kaggle_evaluation.cmi_inference_server and set it up properly. Also your predict function should just return the prediction string, not create any files. The inference server handles all the submission stuff automatically, so remove that parquet creation part.\n\nBasically this competition format is different from the usual submit-a-file approach - it runs your prediction function through their server instead.\n\nHeres an example:\n[Example](https://www.kaggle.com/code/sohier/cmi-2025-demo-submission)\nHope it helps!",
      "replies": [
        {
          "id": 3248418,
          "postDate": "2025-07-14T14:47:21.743Z",
          "content": "<p>Many thanks Abdul !!! I will let you know if it works</p>",
          "rawMarkdown": "Many thanks Abdul !!! I will let you know if it works"
        }
      ]
    },
    {
      "id": 3247701,
      "postDate": "2025-07-13T09:13:21.440Z",
      "content": "<p>Good morning, everyone. I have a issue submitting the ML model for the \"CMI - Detect Behavior with Sensor Data\" competition. <br>\nI wanted to ask you for some help (which should be very quick) in submitting the notebook, as I repeatedly get the error \"Notebook Inference Server Never Started.\" Could you please point me to the lines of code that solve this problem? I'll also leave you the code for my notebook. I would be grateful if you could help me submit my result.</p>\n<p>Code:</p>\n<h1>-------------------------</h1>\n<h1>STEP 1 - IMPORTS &amp; LOAD DATA</h1>\n<h1>-------------------------</h1>\n<p>import pandas as pd<br>\nimport numpy as np<br>\nfrom lightgbm import LGBMClassifier<br>\nfrom sklearn.model_selection import train_test_split<br>\nfrom sklearn.preprocessing import LabelEncoder<br>\nfrom sklearn.metrics import f1_score</p>\n<h1>-------------------------</h1>\n<h1>STEP 2 - READ TRAINING DATA</h1>\n<h1>-------------------------</h1>\n<p>df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/train.csv\")</p>\n<h1>Select columns</h1>\n<p>imu_cols = ['acc_x', 'acc_y', 'acc_z', 'rot_w', 'rot_x', 'rot_y', 'rot_z']<br>\nthm_cols = [col for col in df.columns if col.startswith('thm_')]<br>\ntof_cols = [col for col in df.columns if col.startswith('tof_')]<br>\nsensor_cols = imu_cols + thm_cols + tof_cols</p>\n<h1>Keep only needed columns</h1>\n<p>df = df[['sequence_id', 'sequence_type', 'gesture'] + sensor_cols]</p>\n<h1>-------------------------</h1>\n<h1>STEP 3 - AGGREGATE FEATURES</h1>\n<h1>-------------------------</h1>\n<p>agg_funcs = ['mean', 'std', 'min', 'max']<br>\nX = df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)<br>\nX.columns = ['_'.join(col) for col in X.columns]<br>\nX.reset_index(inplace=True)</p>\n<h1>-------------------------</h1>\n<h1>STEP 4 - PREPARE LABELS</h1>\n<h1>-------------------------</h1>\n<p>labels = df[['sequence_id', 'sequence_type', 'gesture']].drop_duplicates('sequence_id')<br>\nlabels['gesture_label'] = labels.apply(<br>\n    lambda row: row['gesture'] if row['sequence_type'] == 'Target' else 'non_target', axis=1<br>\n)</p>\n<p>top_gestures = labels['gesture_label'].value_counts().head(3).index.tolist()<br>\nlabels['gesture_label'] = labels['gesture_label'].apply(<br>\n    lambda x: x if x in top_gestures else 'non_target'<br>\n)</p>\n<h1>Merge</h1>\n<p>data = pd.merge(X, labels[['sequence_id', 'gesture_label']], on='sequence_id')</p>\n<h1>Encode labels</h1>\n<p>le = LabelEncoder()<br>\ndata['gesture_encoded'] = le.fit_transform(data['gesture_label'])</p>\n<h1>-------------------------</h1>\n<h1>STEP 5 - TRAIN MODEL</h1>\n<h1>-------------------------</h1>\n<p>X_mc = data.drop(columns=['sequence_id', 'gesture_label', 'gesture_encoded'])<br>\ny_mc = data['gesture_encoded']</p>\n<p>X_train, X_val, y_train, y_val = train_test_split(X_mc, y_mc, test_size=0.2, random_state=42, stratify=y_mc)</p>\n<p>model = LGBMClassifier(random_state=42)<br>\nmodel.fit(X_train, y_train)</p>\n<h1>-------------------------</h1>\n<h1>STEP 6 - DEFINE PREDICT FUNCTION</h1>\n<h1>-------------------------</h1>\n<p>def predict(test_df: pd.DataFrame) -&gt; pd.DataFrame:<br>\n    test_df = test_df[['sequence_id'] + sensor_cols]<br>\n    X_test = test_df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)<br>\n    X_test.columns = ['_'.join(col) for col in X_test.columns]<br>\n    X_test.reset_index(inplace=True)</p>\n<pre><code>y_pred_encoded = model(X_test(=[]))\ny_pred_label = le(y_pred_encoded)\n\nsubmission = pd({\n    : X_test,\n    : y_pred_label\n})\nsubmission(, index=False)\nreturn submission\n</code></pre>\n<h1>-------------------------</h1>\n<h1>STEP 7 - CREATE SUBMISSION FILE</h1>\n<h1>-------------------------</h1>\n<p>test_df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv\")<br>\nsubmission = predict(test_df)<br>\nprint(\"✅ submission.parquet created.\")</p>",
      "rawMarkdown": "Good morning, everyone. I have a issue submitting the ML model for the \"CMI - Detect Behavior with Sensor Data\" competition. \nI wanted to ask you for some help (which should be very quick) in submitting the notebook, as I repeatedly get the error \"Notebook Inference Server Never Started.\" Could you please point me to the lines of code that solve this problem? I'll also leave you the code for my notebook. I would be grateful if you could help me submit my result.\n\nCode:\n# -------------------------\n# STEP 1 - IMPORTS & LOAD DATA\n# -------------------------\nimport pandas as pd\nimport numpy as np\nfrom lightgbm import LGBMClassifier\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.metrics import f1_score\n\n# -------------------------\n# STEP 2 - READ TRAINING DATA\n# -------------------------\ndf = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/train.csv\")\n\n# Select columns\nimu_cols = ['acc_x', 'acc_y', 'acc_z', 'rot_w', 'rot_x', 'rot_y', 'rot_z']\nthm_cols = [col for col in df.columns if col.startswith('thm_')]\ntof_cols = [col for col in df.columns if col.startswith('tof_')]\nsensor_cols = imu_cols + thm_cols + tof_cols\n\n# Keep only needed columns\ndf = df[['sequence_id', 'sequence_type', 'gesture'] + sensor_cols]\n\n# -------------------------\n# STEP 3 - AGGREGATE FEATURES\n# -------------------------\nagg_funcs = ['mean', 'std', 'min', 'max']\nX = df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)\nX.columns = ['_'.join(col) for col in X.columns]\nX.reset_index(inplace=True)\n\n# -------------------------\n# STEP 4 - PREPARE LABELS\n# -------------------------\nlabels = df[['sequence_id', 'sequence_type', 'gesture']].drop_duplicates('sequence_id')\nlabels['gesture_label'] = labels.apply(\n    lambda row: row['gesture'] if row['sequence_type'] == 'Target' else 'non_target', axis=1\n)\n\ntop_gestures = labels['gesture_label'].value_counts().head(3).index.tolist()\nlabels['gesture_label'] = labels['gesture_label'].apply(\n    lambda x: x if x in top_gestures else 'non_target'\n)\n\n# Merge\ndata = pd.merge(X, labels[['sequence_id', 'gesture_label']], on='sequence_id')\n\n# Encode labels\nle = LabelEncoder()\ndata['gesture_encoded'] = le.fit_transform(data['gesture_label'])\n\n# -------------------------\n# STEP 5 - TRAIN MODEL\n# -------------------------\nX_mc = data.drop(columns=['sequence_id', 'gesture_label', 'gesture_encoded'])\ny_mc = data['gesture_encoded']\n\nX_train, X_val, y_train, y_val = train_test_split(X_mc, y_mc, test_size=0.2, random_state=42, stratify=y_mc)\n\nmodel = LGBMClassifier(random_state=42)\nmodel.fit(X_train, y_train)\n\n# -------------------------\n# STEP 6 - DEFINE PREDICT FUNCTION\n# -------------------------\ndef predict(test_df: pd.DataFrame) -> pd.DataFrame:\n    test_df = test_df[['sequence_id'] + sensor_cols]\n    X_test = test_df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)\n    X_test.columns = ['_'.join(col) for col in X_test.columns]\n    X_test.reset_index(inplace=True)\n    \n    y_pred_encoded = model.predict(X_test.drop(columns=['sequence_id']))\n    y_pred_label = le.inverse_transform(y_pred_encoded)\n    \n    submission = pd.DataFrame({\n        'sequence_id': X_test['sequence_id'],\n        'gesture': y_pred_label\n    })\n    submission.to_parquet(\"/kaggle/working/submission.parquet\", index=False)\n    return submission\n\n# -------------------------\n# STEP 7 - CREATE SUBMISSION FILE\n# -------------------------\ntest_df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv\")\nsubmission = predict(test_df)\nprint(\"✅ submission.parquet created.\")\n"
    },
    {
      "id": 3247709,
      "postDate": "2025-07-13T09:33:54.707Z",
      "rawMarkdown": "",
      "votes": -1,
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 3248405,
      "author_name": "Hanan",
      "author_url": "",
      "post_date": "2025-07-14T13:59:56.497000",
      "content": "<p><a href=\"https://www.kaggle.com/giancarloronci\" target=\"_blank\">@giancarloronci</a> The issue is you're trying to create a parquet file manually but this competition uses an inference server instead. That's why you're getting the \"Notebook Inference Server Never Started\" error - you're missing the inference server setup completely.</p>\n<p>You need to import kaggle_evaluation.cmi_inference_server and set it up properly. Also your predict function should just return the prediction string, not create any files. The inference server handles all the submission stuff automatically, so remove that parquet creation part.</p>\n<p>Basically this competition format is different from the usual submit-a-file approach - it runs your prediction function through their server instead.</p>\n<p>Heres an example:<br>\n<a href=\"https://www.kaggle.com/code/sohier/cmi-2025-demo-submission\" target=\"_blank\">Example</a><br>\nHope it helps!</p>",
      "votes": 0,
      "replies": [
        {
          "id": 3248418,
          "author_name": "Giancarlo Ronci",
          "author_url": "",
          "post_date": "2025-07-14T14:47:21.743000",
          "content": "<p>Many thanks Abdul !!! I will let you know if it works</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 3247709,
      "author_name": "",
      "author_url": "",
      "post_date": "2025-07-13T09:33:54.707000",
      "content": "",
      "votes": -1,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3248405": "@giancarloronci The issue is you're trying to create a parquet file manually but this competition uses an inference server instead. That's why you're getting the \"Notebook Inference Server Never Started\" error - you're missing the inference server setup completely.\n\nYou need to import kaggle_evaluation.cmi_inference_server and set it up properly. Also your predict function should just return the prediction string, not create any files. The inference server handles all the submission stuff automatically, so remove that parquet creation part.\n\nBasically this competition format is different from the usual submit-a-file approach - it runs your prediction function through their server instead.\n\nHeres an example:\n[Example](https://www.kaggle.com/code/sohier/cmi-2025-demo-submission)\nHope it helps!",
    "3247701": "Good morning, everyone. I have a issue submitting the ML model for the \"CMI - Detect Behavior with Sensor Data\" competition. \nI wanted to ask you for some help (which should be very quick) in submitting the notebook, as I repeatedly get the error \"Notebook Inference Server Never Started.\" Could you please point me to the lines of code that solve this problem? I'll also leave you the code for my notebook. I would be grateful if you could help me submit my result.\n\nCode:\n# -------------------------\n# STEP 1 - IMPORTS & LOAD DATA\n# -------------------------\nimport pandas as pd\nimport numpy as np\nfrom lightgbm import LGBMClassifier\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.metrics import f1_score\n\n# -------------------------\n# STEP 2 - READ TRAINING DATA\n# -------------------------\ndf = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/train.csv\")\n\n# Select columns\nimu_cols = ['acc_x', 'acc_y', 'acc_z', 'rot_w', 'rot_x', 'rot_y', 'rot_z']\nthm_cols = [col for col in df.columns if col.startswith('thm_')]\ntof_cols = [col for col in df.columns if col.startswith('tof_')]\nsensor_cols = imu_cols + thm_cols + tof_cols\n\n# Keep only needed columns\ndf = df[['sequence_id', 'sequence_type', 'gesture'] + sensor_cols]\n\n# -------------------------\n# STEP 3 - AGGREGATE FEATURES\n# -------------------------\nagg_funcs = ['mean', 'std', 'min', 'max']\nX = df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)\nX.columns = ['_'.join(col) for col in X.columns]\nX.reset_index(inplace=True)\n\n# -------------------------\n# STEP 4 - PREPARE LABELS\n# -------------------------\nlabels = df[['sequence_id', 'sequence_type', 'gesture']].drop_duplicates('sequence_id')\nlabels['gesture_label'] = labels.apply(\n    lambda row: row['gesture'] if row['sequence_type'] == 'Target' else 'non_target', axis=1\n)\n\ntop_gestures = labels['gesture_label'].value_counts().head(3).index.tolist()\nlabels['gesture_label'] = labels['gesture_label'].apply(\n    lambda x: x if x in top_gestures else 'non_target'\n)\n\n# Merge\ndata = pd.merge(X, labels[['sequence_id', 'gesture_label']], on='sequence_id')\n\n# Encode labels\nle = LabelEncoder()\ndata['gesture_encoded'] = le.fit_transform(data['gesture_label'])\n\n# -------------------------\n# STEP 5 - TRAIN MODEL\n# -------------------------\nX_mc = data.drop(columns=['sequence_id', 'gesture_label', 'gesture_encoded'])\ny_mc = data['gesture_encoded']\n\nX_train, X_val, y_train, y_val = train_test_split(X_mc, y_mc, test_size=0.2, random_state=42, stratify=y_mc)\n\nmodel = LGBMClassifier(random_state=42)\nmodel.fit(X_train, y_train)\n\n# -------------------------\n# STEP 6 - DEFINE PREDICT FUNCTION\n# -------------------------\ndef predict(test_df: pd.DataFrame) -> pd.DataFrame:\n    test_df = test_df[['sequence_id'] + sensor_cols]\n    X_test = test_df.groupby('sequence_id')[sensor_cols].agg(agg_funcs)\n    X_test.columns = ['_'.join(col) for col in X_test.columns]\n    X_test.reset_index(inplace=True)\n    \n    y_pred_encoded = model.predict(X_test.drop(columns=['sequence_id']))\n    y_pred_label = le.inverse_transform(y_pred_encoded)\n    \n    submission = pd.DataFrame({\n        'sequence_id': X_test['sequence_id'],\n        'gesture': y_pred_label\n    })\n    submission.to_parquet(\"/kaggle/working/submission.parquet\", index=False)\n    return submission\n\n# -------------------------\n# STEP 7 - CREATE SUBMISSION FILE\n# -------------------------\ntest_df = pd.read_csv(\"/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv\")\nsubmission = predict(test_df)\nprint(\"✅ submission.parquet created.\")\n",
    "3247709": ""
  }
}