Giter Club home page Giter Club logo

simple-kan-4-time-series's Introduction

KAN it be used for Time Series Classification ?

Star History Chart

author : Ali Ismail-Fawaz - @hadifawaz1999

In this repository, we present a feature-based Time Series Classifier based on Kolmogorov–Arnold Networks (KANs) proposed by Liu et al. 2024 [1]. Given that a KAN model is still a fully connected network, it will not be able to detect temporal dependencies on time series data, however it will be able to work on extracted features from these series. In this repository, we present a classifier based on extracting the Catch22 features Lubba et al. 2019 [2] followed by KAN classifier. In order to showcase the performance of KAN, we compare it to using a softmax classifier on top of the Catch22 features. The model of course can work with any type of transformation on time series data, we chose Catch22 for simpliciy. We use the aeon python package for the feature extraction part.

Datasets

In this repository we utilize the amazing publicly available UCR archive by Dau et al. 2019 [3], the largest repository of unvariate Time Series Classification datasets. Make sure to download the datasets and extract the zip folder.

Docker image

If you are familiar with docker, simply build the image using the dockerfile provided as follows:

PS: Make sure to adjust the USER_ID and GROUP_ID arguments in the dockerfile to align with your local machine before building the image.

docker build -t kan-ts-image .

Following the image being built, create your docker container and mount the UCR archive datasets into the /home/myuser/ucr_archive directory and your current working directory to /home/myuser/code directory, as follows:

docker run --gpus all -it --name kan-ts-container -v "$(pwd):/home/myuser/code" -v "/path/to/ucr/archiev/on/your/machine/:/home/myuser/ucr_archive/" --user $(id -u):$(id -g) kan-ts-image bash

Make sure to replace /path/to/ucr/archiev/on/your/machine/ by the directory on your local machine.

Once the containter is created, exit and execute it again in root mode with:

docker start kan-ts-container

and

docker exec -it -u root kan-ts-container bash

Once in root mode, install gcc and pycatch22 with:

$ apg-get install gcc
$ pip install pycatch22

Requirements

torch==2.2.1
numpy==1.24.4
pandas==2.0.3
scikit-learn==1.1.3
matplotlib==3.6.2
aeon==0.8.1
hydra-core --upgrade
omegaconf
black==23.11.0
pykan
setuptools==65.5.0
sympy==1.11.1
tqdm==4.66.2
pycatch22

Code Usage

This code uses hydra for the parameters configuration, so simply edit the config/config_hydra.yaml file and run the following command:

python3 main.py

Results

The code will generate per dataset a directory containing a csv file, with four columns, accuracy mean and std over five runs on both Catch22+KAN classifier and Catch22+softmax classifier.

Examples of some UCR datasets where KAN improves the classification performance:

Dataset Test Accuracy with KAN Test Accuracy with softmax
Chinatown 85.13 % 62.09 %
ItalyPowerDemand 91.29 % 82.41 %
ECG200 78.60 % 75.00 %
ArrowHead 67.99 % 63.42 %
CricketX 51.90 % 35.64 %
CricketY 49.13 % 32.31 %
CricketZ 52.62 % 35.90 %
Beef 44.00 % 36.67 %

Citing this work

If you use this work, please make sure to cite this code repository as follows:

@misc{Ismail-Fawaz2023kan-c22-4-tsc
    author = {Ismail-Fawaz, Ali and Devanne, Maxime and Berretti, Stefano and Weber, Jonathan and Forestier, Germain},
    title = {Feature-Based Time Series Classification with Kolmogorov–Arnold Networks},
    year = {2024},
    publisher = {Github},
    journal = {GitHub repository},
    howpublished = {\url{https://github.com/MSD-IRIMAS/Simple-KAN-4-Time-Series}}
}

References

[1] Liu, Ziming, et al. "KAN: Kolmogorov-Arnold Networks." arXiv preprint arXiv:2404.19756 (2024).
[2] Lubba, Carl H., et al. "catch22: CAnonical Time-series CHaracteristics: Selected through highly comparative time-series analysis." Data Mining and Knowledge Discovery 33.6 (2019): 1821-1852.
[3] Dau, Hoang Anh, et al. "The UCR time series archive." IEEE/CAA Journal of Automatica Sinica 6.6 (2019): 1293-1305.

Acknowledgments

We would like to thank the authors of the Kolmogorov–Arnold Networks paper for their amazing work as well as the authors of the UCR archive for making the Time Series Classification datasets publicly available. We would also like to thank the Aeon and Pycatch22 python packages for their implementation of the Catch22 feature extractor.

simple-kan-4-time-series's People

Contributors

hadifawaz1999 avatar maxwell1503 avatar forestier avatar

Stargazers

123pp avatar LaurineDargaud avatar  avatar  avatar  avatar Peacekie avatar  avatar  avatar ผศ.ดร. เอกรัฐ รัฐกาญจน์ avatar TawongaC avatar Qidi Shu avatar HDU_TK avatar  avatar  avatar Alex Khlivnuik avatar Taibiao Zhao avatar Yvictor avatar 爱可可-爱生活 avatar RAFAEL RODRIGUES avatar  avatar  avatar Wuhx avatar Srikanth Reddy avatar  avatar Wanqi_Zhou avatar  avatar  avatar  avatar  avatar  avatar Angelo Varlotta avatar YunYuLai avatar Thantorn Thammachai avatar  avatar Adrien Petralia avatar Cris@None avatar Liwei Deng avatar Fantasy avatar Michael McCool avatar stakOverflow avatar  avatar Arijeet Chatterjee avatar  avatar SONG avatar Xiaobing Han avatar  avatar  avatar Daniel Lassahn avatar  avatar Michael avatar Tauseef Bashir avatar Xianliang Wu avatar Pie Samliam avatar  avatar  avatar Alexander H.J. avatar Maria Moreno de Castro avatar valeman avatar Happydog avatar LynL avatar Alexis Tabin avatar Sor4chi avatar Le Tuan Thanh avatar Praise avatar Noel Jacob avatar PengqianHan avatar Aviv Nur avatar sfuller14 avatar Warui avatar Thomson avatar shyam_patadia avatar Gabriele Tromboni avatar  avatar Spectral Sequence avatar Bingxi Liu avatar  avatar  avatar yuno avatar Martin Laprise avatar Da Zhang avatar David H. Brown avatar Leonidas Tsaprounis avatar Hassan ISMAIL FAWAZ avatar  avatar

Watchers

 avatar Jonathan Weber avatar  avatar Kostas Georgiou avatar  avatar  avatar

simple-kan-4-time-series's Issues

hydra configuration

I have some problem on the configuration of Hydra (totally new on that). From the default, in which way should I configure to make a run on one UCR dataset that I downloaded? What the width should be? Thank you!

Noob here, learning, excited to be part of KAN.

In your readme, you mention that because KAN is a fully connected network, it will not be able to detect temporal dependencies. Forgive me, as I just had to look up what temporal dependencies meant, but what would it take for such to be possible with KAN? Bravo on the repo, hope to be at your level someday.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.