File Exchange

image thumbnail

Kaggle: seizure prediction MATLAB solution -- LASSO GLM approach

version (11.1 KB) by Jianghao Wang
Starter code for completing the Kaggle seizure prediction competition with MATLAB


Updated 19 Sep 2016

View License

This is a MATLAB solution to the Melbourne University AES/MathWorks/NIH Seizure Prediction (
It is built upon a winning solution ( from a previous Kaggle seizure competition (, using lassoGLM models from the Statistics and Machine Learning Toolbox.
The zip file contains:
1. calculate_features.m -- a function that calculates a set of features from the iEEG sample values
2. step1_generate features -- a function that loads in patient training (and test) iEEG sample data and calculates features (using function calculate_features.m).
3. step2_generate_models.m -- a function that trains a LASSO GLM model using the features extracted from step1_generate_features.m.
4. step3_evaluate_models.m -- a function that evaluates the trainted model and returns in-sample and out-of-sample skill for model assessment. Output is stored to a .csv file for Kaggle submission.
5. step4_predict_seizure.m -- a function that make predictions on test data, with the model trained and evaluated from the previous steps. Output is stored to a .csv file for Kaggle submission.
6. kaggle_seizure_prediction_workflow.m -- a master script that runs through the above-mentioned steps.

Cite As

Jianghao Wang (2021). Kaggle: seizure prediction MATLAB solution -- LASSO GLM approach (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Jianghao Wang

The error message was due to 100% or near 100% data dropout (see A handful of 10-minute segments contain 100% data drop-out and cannot be classified. The data may also contain artifacts such as large amplitude rapid signal transitions that can be removed from analysis), which introduces complex values when calculating features.

Workaround solutions include:
1) only take real parts of the matrix and then run lassoGLM;
2) identify 100% data dropout and artifacts, and exclude them from the beginning of your analysis.

Zhesi Shen

When running step2_generate_models.m, there is an error saying that the X_train is not a real-value 2D matrix in the lassoglm function. Did you have this problem?

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!