wolterlw / CPT

native Python implementation of CPT(compact Prediction Tree)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPT (Compact Prediction Tree)

This is the Python Implementation of CPT algorithm for Sequence Prediction. The library has been written from scratch in Python and as far as I believe is the first Python implementation of the algorithm.

The repository is also an exercise on my part to code a research paper. The library is not perfect. I have intentionally left out some optimisations such as CFS(compression of frequenct sequences) etc. These features will be later added to the library as an ongoing effort.

The library is created using the below two research papers.

  1. Compact Prediction Tree: A Losless Model for Accurate Sequence Prediction

  2. CPT+: Decreasing the time/space complexity of the Compact Prediction Tree

  • How to use the library?

There is no requirement of compiling anything but make sure you have Pandas and tqdm installed in your environment specific versions of which are mentioned in the file requirements.txt.

  • Sample code for training and getting predictions.

model = CPT()

data, target = model.load_files("train.csv","test.csv")

model.train(data)

predictions = model.predict(data,target, k, n)

About

native Python implementation of CPT(compact Prediction Tree)

License:MIT License


Languages

Language:Python 100.0%