Git Product home page Git Product logo

cpt's Introduction

CPT

PyPI version Downloads License

What is it ?

This project is a cython open-source implementation of the Compact Prediction Tree algorithm using multithreading.

CPT is a sequence prediction model. It is a highly explainable model specialized in predicting the next element of a sequence over a finite alphabet.

This implementation is based on the following research papers:

Installation

You can simply use pip install cpt.

Simple example

You can test the model with the following code:

from cpt.cpt import Cpt
model = Cpt()

model.fit([['hello', 'world'],
           ['hello', 'this', 'is', 'me'],
           ['hello', 'me']
          ])

model.predict([['hello'], ['hello', 'this']])
# Output: ['me', 'is']

For an example with the compatibility with sklearn, you should check the documentation.

Features

Train

The model can be trained with the fit method.

If needed the model can be retrained with the same method. It adds new sequences to the model and do not remove the old ones.

Multithreading

The predictions are launched by default with multithreading with OpenMP.

The predictions can also be launched in a single thread with the option multithread=False in the predict method.

You can control the number of threads by setting the following environment variable OMP_NUM_THREADS.

Pickling

You can pickle the model to save it, and load it later via pickle library.

from cpt.cpt import Cpt
import pickle


model = Cpt()
model.fit([['hello', 'world']])

dumped = pickle.dumps(model)

unpickled_model = pickle.loads(dumped)

print(model == unpickled_model)

Explainability

The CPT class has several methods to explain the predictions.

You can see which elements are considered as noise (with a low presence in sequences) with model.compute_noisy_items(noise_ratio).

You can retrieve trained sequences with model.retrieve_sequence(id).

You can find similar sequences with find_similar_sequences(sequence).

You can not yet retrieve automatically all similar sequences with the noise reduction technique.

Tuning

CPT has 3 meta parameters that need to be tuned. You can check how to tune them in the documentation. To tune you can use the model_selection module from sklearn, you can find an example here on how to.

Benchmark

The benchmark has been made on the FIFA dataset, the data can be found on the SPMF website.

Using multithreading, CPT was able to perform around 5000 predictions per second.

Without multithreading, CPT predicted around 1650 sequences per second.

Details on the benchmark can be found here.

Further reading

A study has been made on how to reduce dataset size, and so training / testing time using PageRank on the dataset.

The study has been published in IJIKM review here. An overall performance improvement of 10-40% has been observed with this technique on the prediction time without any accuracy loss.

One of the co-author of CPT has also published an algorithm subseq for sequence prediction. An implementation can be found here

Support

If you enjoy the project and wish to support me, a buymeacoffee link is available.

cpt's People

Contributors

bluesheeptoken avatar catchthemonster avatar github-louis-fruleux avatar kimci86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpt's Issues

Predicts same item for every sequence

Hello,

There is either something extremely wrong with the implementation or I havent understood it right. for the follwoing sequences it predicts same item (which is not the case in actual). so on all 24 sequences, at time of testing ( if i provide n-1 items, removing last one

for instance, here is two sequence from 24 training seq data

['SODL', 'TCU', 'IPC', 'TCM', 'IPMB', 'GWM', 'GWM', 'TCM', 'IPC', 'SODL', 'SODR', 'CHCM', 'GWM', 'PSCM', 'TCU', 'ABS', 'ABS', 'IPMA', 'IPMA', 'SODR', 'RCM', 'PSCM', 'IPMA']
['TCM', 'IPC', 'CHCM', 'TCM', 'ABS', 'ABS', 'ABS', 'ABS', 'IPMB', 'PSCM', 'PSCM', 'TCU', 'ABS', 'ABS', 'ABS', 'ABS', 'TCM', 'RCM', 'PSCM', 'IPMA', 'IPMA']

out of 24, it produces

'SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODL,SODR,TCU,TCU'

Which is quite strange as sequences are quite different

Specialize PredictionTree for prediction

Only incoming transitions and parents are needed for prediction.
Children are used only during training.
After training, children can be ignored : not serialized (#22) and not loaded in memory for prediction.

CPT version 1.0.1 issue

from cpt.cpt import Cpt
model = Cpt()

model.fit([['hello', 'world'],
['hello', 'this', 'is', 'me'],
['hello', 'me']
])

model.predict([['hello'], ['hello', 'this']])

ERROR:

ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 from cpt.cpt import Cpt
2 model = Cpt()
3
4 model.fit([['hello', 'world'],
5 ['hello', 'this', 'is', 'me'],

ModuleNotFoundError: No module named 'cpt'

free(): double free detected in tcache 2

HI Louis,

Not sure if this is cpt or Python3 or my implementation, but I am performing prediction using 51200000 random numbers with mbr 5040 split 5 and noise 0.2 predicting for 84530 ints.

Starting mbr 5040 split 5 and noise 0.2
Running collection of 51200000 random numbers
free(): double free detected in tcache 2
I am doing this on ubuntu desktop 21.4, latest kernel, gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0, python 3.9.7 and my app.

basically
model = Cpt(self.conf.split, self.conf.noise, self.conf.mbr)
model.fit(self.trngNums)
predictions = model.predict(self.pastNumbers)

this is going in overarching for loop, with mbr, spli and noise continuously changing ...

So my question to you is is there anything I can do to avoid this most likely a pointer freed issue that leads to corruption.

Regards,

Do a README

Currently README has a lot of "development" information, which might be more appropriate into a "CONTRIBUTE.md". We should keep the README to a brief explanation for a user

Wheel for Linux 64 bits

Hello,

I hope this one will be easier than Mac OS. I'd like to have a wheel for Linux 64bits.

The suffix for the architecture is aarch64, here is an example of the naming : pandas-1.5.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

Thanks a lot.

Cannot Install CPT on macOS Catalina with either pip or setup.py

Clang failing with error code 1

Compiling cpt/alphabet.pyx because it changed.
Compiling cpt/cpt.pyx because it changed.
[1/2] Cythonizing cpt/alphabet.pyx
[2/2] Cythonizing cpt/cpt.pyx
running install
running bdist_egg
running egg_info
creating cpt.egg-info
writing cpt.egg-info/PKG-INFO
writing dependency_links to cpt.egg-info/dependency_links.txt
writing top-level names to cpt.egg-info/top_level.txt
writing manifest file 'cpt.egg-info/SOURCES.txt'
reading manifest file 'cpt.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'cpt.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.14-x86_64/egg
running install_lib
running build_ext
building 'cpt.alphabet' extension
creating build
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/cpt
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c cpt/alphabet.c -o build/temp.macosx-10.14-x86_64-3.7/cpt/alphabet.o -fopenmp -std=c++11
clang: error: unsupported option '-fopenmp'
error: command 'clang' failed with exit status 1

model prediction not according to trained sequences.

After training the model on a set of sequences, it almost always predict same item irrespective on the input sequence. For example:
model.retrieve_sequence(10) output is ['10502162', '10501010', '10500860']

Then when I predict using the first two items from the learned sequence: model.predict(['10502162', '10501010']), the output is
['11012517', '11012517'].
I was expecting to have the third item in the learned sequence as prediction. Secondly, the item '11012517' is almost always predicted, no matter the input sequence.

Can you please check and clarify this behavior?

Error in the implementation

As per the paper, the definition of a subsequent sequence is the the subsequence starting after the last item in common with S.

This sentence is misleading. According to the source code, the subsequent of the sequence ABAC with respect to AB should be AC instead of C.

CPT will not compile on 3.7 and 3.8 + wheel package will not import

Hi,
following directions both ways:
pip3 install cython && python3.7(8) setup.py install throws tons of erroirs:
Error compiling Cython file:

------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
^
------------------------------------------------------------

cpt/cpt.pxd:1:0: 'cpt/prediction_tree.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
^
------------------------------------------------------------

cpt/cpt.pxd:1:0: 'cpt/prediction_tree/PredictionTree.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
....


installing cpt 1.2.1 module by pip3 succeeds but import will not work

rom cpt import CPT
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name 'CPT' from 'cpt' (unknown location)
from cpt import Cpt
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name 'Cpt' from 'cpt' (unknown location)

How do you get this module to properly install...?

cpt.alphabet

Hi Louis,
I successfully installed cpt package under py-3.12.1
on the import however i get:
./python3.12
Python 3.12.1 (main, Dec 25 2023, 10:27:39) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from cpt.cpt import Cpt
Traceback (most recent call last):
File "", line 1, in
File "cpt/cpt.pyx", line 1, in init cpt
ModuleNotFoundError: No module named 'cpt.alphabet'; 'cpt' is not a package

could I help with this?

CPT installation using PIP, CYTHON COMPILATION ERROR

using AWS SAGEMAKER JUPYTOR NOTEBOOK

command: !pip install cpt

ERROR:

Collecting cpt==1.2.0
Using cached cpt-1.2.0.tar.gz (105 kB)
ERROR: Command errored out with exit status 1:
command: /home/ec2-user/anaconda3/envs/python3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-03ie79bc/cpt/setup.py'"'"'; file='"'"'/tmp/pip-install-03ie79bc/cpt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-qzzwr1s_
cwd: /tmp/pip-install-03ie79bc/cpt/
Complete output (1491 lines):

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
^
------------------------------------------------------------

cpt/cpt.pxd:1:0: 'cpt/prediction_tree.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
^
------------------------------------------------------------

cpt/cpt.pxd:1:0: 'cpt/prediction_tree/PredictionTree.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
^
------------------------------------------------------------

cpt/cpt.pxd:2:0: 'cpt/alphabet.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
^
------------------------------------------------------------

cpt/cpt.pxd:2:0: 'cpt/alphabet/Alphabet.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
from cpt.bitset cimport Bitset
^
------------------------------------------------------------

cpt/cpt.pxd:3:0: 'cpt/bitset.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
from cpt.bitset cimport Bitset
^
------------------------------------------------------------

cpt/cpt.pxd:3:0: 'cpt/bitset/Bitset.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
from cpt.bitset cimport Bitset
from cpt.scorer cimport Scorer
^
------------------------------------------------------------

cpt/cpt.pxd:4:0: 'cpt/scorer.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cpt.prediction_tree cimport PredictionTree
from cpt.alphabet cimport Alphabet
from cpt.bitset cimport Bitset
from cpt.scorer cimport Scorer
^
------------------------------------------------------------

cpt/cpt.pxd:4:0: 'cpt/scorer/Scorer.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from libcpp.vector cimport vector


cdef class Cpt:
    cdef:
        PredictionTree tree
       ^
------------------------------------------------------------

cpt/cpt.pxd:10:8: 'PredictionTree' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...


cdef class Cpt:
    cdef:
        PredictionTree tree
        vector[Bitset] inverted_index
                    ^
------------------------------------------------------------

cpt/cpt.pxd:11:21: unknown type in template argument

Error compiling Cython file:
------------------------------------------------------------
...
        vector[Bitset] inverted_index
        vector[size_t] lookup_table

        int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil
        vector[int] c_compute_noisy_items(self, float noise_ratio) nogil
        Bitset c_find_similar_sequences(self, vector[int] sequence) nogil
       ^
------------------------------------------------------------

cpt/cpt.pxd:16:8: 'Bitset' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        vector[size_t] lookup_table

        int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil
        vector[int] c_compute_noisy_items(self, float noise_ratio) nogil
        Bitset c_find_similar_sequences(self, vector[int] sequence) nogil
        int update_score(self, vector[int] suffix, Scorer& score) nogil
                                                  ^
------------------------------------------------------------

cpt/cpt.pxd:17:51: 'Scorer' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        int split_length
        float noise_ratio
        int MBR

    cdef readonly:
        Alphabet alphabet
       ^
------------------------------------------------------------

cpt/cpt.pxd:28:8: 'Alphabet' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        int split_length
        float noise_ratio
        int MBR

    cdef readonly:
        Alphabet alphabet
                ^
------------------------------------------------------------

cpt/cpt.pxd:28:17: C attribute of type '<error>' cannot be accessed from Python

Error compiling Cython file:
------------------------------------------------------------
...
from libcpp.queue cimport queue
from libcpp.iterator cimport back_inserter
from cython.parallel import prange
from cpython.object cimport Py_EQ, Py_NE

from cpt.prediction_tree cimport PredictionTree, Node, ROOT
^
------------------------------------------------------------

cpt/cpt.pyx:9:0: 'cpt/prediction_tree/Node.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from libcpp.queue cimport queue
from libcpp.iterator cimport back_inserter
from cython.parallel import prange
from cpython.object cimport Py_EQ, Py_NE

from cpt.prediction_tree cimport PredictionTree, Node, ROOT
^
------------------------------------------------------------

cpt/cpt.pyx:9:0: 'cpt/prediction_tree/ROOT.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
from cython.parallel import prange
from cpython.object cimport Py_EQ, Py_NE

from cpt.prediction_tree cimport PredictionTree, Node, ROOT
from cpt.alphabet cimport Alphabet
from cpt.alphabet cimport NOT_AN_INDEX
^
------------------------------------------------------------

cpt/cpt.pyx:11:0: 'cpt/alphabet/NOT_AN_INDEX.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                least_frequent_items.push_back(i)

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        ^
------------------------------------------------------------

cpt/cpt.pyx:284:9: 'Bitset' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
                                                   ^
------------------------------------------------------------

cpt/cpt.pyx:297:52: 'Scorer' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        Examples
        --------
        >>> model.fit([['hello', 'world'], ['hello', 'cpt']])
        '''
        cdef size_t number_sequences_to_train = len(sequences)
        cdef Node current
            ^
------------------------------------------------------------

cpt/cpt.pyx:71:13: 'Node' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
           ^
------------------------------------------------------------

cpt/cpt.pyx:248:12: 'Scorer' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
            ^
------------------------------------------------------------

cpt/cpt.pyx:288:13: 'Bitset' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
           ^
------------------------------------------------------------

cpt/cpt.pyx:299:12: 'Bitset' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
            size_t i, similar_sequence_id
            Node end_node
           ^
------------------------------------------------------------

cpt/cpt.pyx:301:12: 'Node' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
                    next_transition = self.tree.getTransition(end_node)

        return update_count

    cdef list retrieve_similar_sequences(self, vector[int] sequence_index):
        cdef Bitset bitset_similar = self.c_find_similar_sequences(sequence_index)
            ^
------------------------------------------------------------

cpt/cpt.pyx:322:13: 'Bitset' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
    def __init__(self, int split_length=0, float noise_ratio=0, int MBR=0):
        if split_length < 0:
            raise ValueError('split_length value should be non-negative, actual value: {}'.format(split_length))
        _check_noise_ratio(noise_ratio)
        _check_MBR(MBR)
        self.tree = PredictionTree()
                   ^
------------------------------------------------------------

cpt/cpt.pyx:41:20: 'PredictionTree' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
        if split_length < 0:
            raise ValueError('split_length value should be non-negative, actual value: {}'.format(split_length))
        _check_noise_ratio(noise_ratio)
        _check_MBR(MBR)
        self.tree = PredictionTree()
        self.inverted_index = vector[Bitset]()
                                    ^
------------------------------------------------------------

cpt/cpt.pyx:42:37: unknown type in template argument

Error compiling Cython file:
------------------------------------------------------------
...
            raise ValueError('split_length value should be non-negative, actual value: {}'.format(split_length))
        _check_noise_ratio(noise_ratio)
        _check_MBR(MBR)
        self.tree = PredictionTree()
        self.inverted_index = vector[Bitset]()
        self.lookup_table = vector[Node]()
                                  ^
------------------------------------------------------------

cpt/cpt.pyx:43:35: unknown type in template argument

Error compiling Cython file:
------------------------------------------------------------
...
        self.inverted_index = vector[Bitset]()
        self.lookup_table = vector[Node]()
        self.split_length = -split_length
        self.noise_ratio = noise_ratio
        self.MBR = MBR
        self.alphabet = Alphabet()
                       ^
------------------------------------------------------------

cpt/cpt.pyx:47:24: 'Alphabet' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
            for i in range(self.inverted_index.size()):
                self.inverted_index[i].resize(self._number_trained_sequences + number_sequences_to_train)

        for i, sequence in enumerate(sequences):
            id_seq = i + self._number_trained_sequences
            current = ROOT
                     ^
------------------------------------------------------------

cpt/cpt.pyx:80:22: 'ROOT' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
                # Adding to the Prediction Tree
                current = self.tree.addChild(current, index)

                # Adding to the Inverted Index
                if not index < self.inverted_index.size():
                    self.inverted_index.push_back(Bitset(self._number_trained_sequences + number_sequences_to_train))
                                                 ^
------------------------------------------------------------

cpt/cpt.pyx:89:50: 'Bitset' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...

        sequence = []
        end_node = self.lookup_table[index]
        next_transition = self.tree.getTransition(end_node)

        while next_transition != NOT_AN_INDEX:
                                ^
------------------------------------------------------------

cpt/cpt.pyx:239:33: 'NOT_AN_INDEX' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                           ^
------------------------------------------------------------

cpt/cpt.pyx:248:28: 'Scorer' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
            queue[vector[int]] suffixes = queue[vector[int]]()
            vector[int] suffix_without_noise, suffix
            size_t i
            int noise, update_count = 0

        target_sequence.erase(remove(target_sequence.begin(), target_sequence.end(), NOT_AN_INDEX), target_sequence.end())
                                                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:254:85: 'NOT_AN_INDEX' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                  ^
------------------------------------------------------------

cpt/cpt.pyx:286:19: 'Bitset' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                     ^
------------------------------------------------------------

cpt/cpt.pyx:291:22: 'Bitset' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                              ^
------------------------------------------------------------

cpt/cpt.pyx:299:47: 'Bitset' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
        split_length, alphabet, lookup_table_state, inverted_index_state, prediction_tree_state, number_trained_sequences = state
        self.split_length = split_length
        self.alphabet = alphabet
        self.lookup_table = lookup_table_state
        for bitset_state in inverted_index_state:
            self.inverted_index.push_back(Bitset(bitset_state[0], bitset_state[1]))
                                         ^
------------------------------------------------------------

cpt/cpt.pyx:362:42: 'Bitset' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...
        self.split_length = split_length
        self.alphabet = alphabet
        self.lookup_table = lookup_table_state
        for bitset_state in inverted_index_state:
            self.inverted_index.push_back(Bitset(bitset_state[0], bitset_state[1]))
        self.tree = PredictionTree(prediction_tree_state[0], prediction_tree_state[1], prediction_tree_state[2], prediction_tree_state[3])
                   ^
------------------------------------------------------------

cpt/cpt.pyx:363:20: 'PredictionTree' is not a constant, variable or function identifier

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                                 ^
------------------------------------------------------------

cpt/cpt.pyx:248:34: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                                 ^
------------------------------------------------------------

cpt/cpt.pyx:248:34: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                           ^
------------------------------------------------------------

cpt/cpt.pyx:248:28: Accessing Python global or builtin not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                                 ^
------------------------------------------------------------

cpt/cpt.pyx:248:34: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return [self.alphabet.get_symbol(index) for index in reversed(sequence)]

    cdef int predict_seq(self, vector[int] target_sequence, vector[int] least_frequent_items) nogil:
        cdef:
            Scorer scorer = Scorer(self.alphabet.length)
                                               ^
------------------------------------------------------------

cpt/cpt.pyx:248:48: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            queue[vector[int]] suffixes = queue[vector[int]]()
            vector[int] suffix_without_noise, suffix
            size_t i
            int noise, update_count = 0

        target_sequence.erase(remove(target_sequence.begin(), target_sequence.end(), NOT_AN_INDEX), target_sequence.end())
                                                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:254:85: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
            queue[vector[int]] suffixes = queue[vector[int]]()
            vector[int] suffix_without_noise, suffix
            size_t i
            int noise, update_count = 0

        target_sequence.erase(remove(target_sequence.begin(), target_sequence.end(), NOT_AN_INDEX), target_sequence.end())
                                                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:254:85: Accessing Python global or builtin not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                    remove_copy(suffix.begin(), suffix.end(), back_inserter(suffix_without_noise), noise)
                    if not suffix_without_noise.empty():
                        suffixes.push(suffix_without_noise)
                        update_count += self.update_score(suffix_without_noise, scorer)

        return scorer.get_best_prediction()
                                        ^
------------------------------------------------------------

cpt/cpt.pyx:271:41: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
                    remove_copy(suffix.begin(), suffix.end(), back_inserter(suffix_without_noise), noise)
                    if not suffix_without_noise.empty():
                        suffixes.push(suffix_without_noise)
                        update_count += self.update_score(suffix_without_noise, scorer)

        return scorer.get_best_prediction()
                                        ^
------------------------------------------------------------

cpt/cpt.pyx:271:41: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                    remove_copy(suffix.begin(), suffix.end(), back_inserter(suffix_without_noise), noise)
                    if not suffix_without_noise.empty():
                        suffixes.push(suffix_without_noise)
                        update_count += self.update_score(suffix_without_noise, scorer)

        return scorer.get_best_prediction()
                    ^
------------------------------------------------------------

cpt/cpt.pyx:271:21: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                    remove_copy(suffix.begin(), suffix.end(), back_inserter(suffix_without_noise), noise)
                    if not suffix_without_noise.empty():
                        suffixes.push(suffix_without_noise)
                        update_count += self.update_score(suffix_without_noise, scorer)

        return scorer.get_best_prediction()
                                        ^
------------------------------------------------------------

cpt/cpt.pyx:271:41: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
    cdef vector[int] c_compute_noisy_items(self, float noise_ratio) nogil:
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
                                   ^
------------------------------------------------------------

cpt/cpt.pyx:278:36: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
    cdef vector[int] c_compute_noisy_items(self, float noise_ratio) nogil:
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
                                   ^
------------------------------------------------------------

cpt/cpt.pyx:278:36: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                                         ^
------------------------------------------------------------

cpt/cpt.pyx:279:58: Truth-testing Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                                         ^
------------------------------------------------------------

cpt/cpt.pyx:279:58: Operation not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                                      ^
------------------------------------------------------------

cpt/cpt.pyx:279:55: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                    ^
------------------------------------------------------------

cpt/cpt.pyx:279:37: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                                      ^
------------------------------------------------------------

cpt/cpt.pyx:279:55: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef:
            int i
            vector[int] least_frequent_items = vector[int]()

        for i in range(self.alphabet.length):
            if self.inverted_index[i].compute_frequency() <= noise_ratio:
                                                            ^
------------------------------------------------------------

cpt/cpt.pyx:279:61: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                        ^
------------------------------------------------------------

cpt/cpt.pyx:286:25: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                        ^
------------------------------------------------------------

cpt/cpt.pyx:286:25: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                  ^
------------------------------------------------------------

cpt/cpt.pyx:286:19: Accessing Python global or builtin not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                        ^
------------------------------------------------------------

cpt/cpt.pyx:286:25: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return least_frequent_items

    cdef Bitset c_find_similar_sequences(self, vector[int] sequence) nogil:
        if sequence.empty():
            return Bitset(self.alphabet.length)
                                      ^
------------------------------------------------------------

cpt/cpt.pyx:286:39: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                           ^
------------------------------------------------------------

cpt/cpt.pyx:291:28: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                           ^
------------------------------------------------------------

cpt/cpt.pyx:291:28: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                     ^
------------------------------------------------------------

cpt/cpt.pyx:291:22: Accessing Python global or builtin not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                           ^
------------------------------------------------------------

cpt/cpt.pyx:291:28: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            return Bitset(self.alphabet.length)

        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
                                               ^
------------------------------------------------------------

cpt/cpt.pyx:291:48: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])
                            ^
------------------------------------------------------------

cpt/cpt.pyx:293:29: Discarding owned Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])
                            ^
------------------------------------------------------------

cpt/cpt.pyx:293:29: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])
                      ^
------------------------------------------------------------

cpt/cpt.pyx:293:23: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])
                            ^
------------------------------------------------------------

cpt/cpt.pyx:293:29: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        cdef Bitset bitset_temp
        cdef size_t i

        bitset_temp = Bitset(self.inverted_index[sequence[0]])
        for i in range(1, sequence.size()):
            bitset_temp.inter(self.inverted_index[sequence[i]])
                                                ^
------------------------------------------------------------

cpt/cpt.pyx:293:49: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:299:53: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:299:53: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                              ^
------------------------------------------------------------

cpt/cpt.pyx:299:47: Accessing Python global or builtin not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                                    ^
------------------------------------------------------------

cpt/cpt.pyx:299:53: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        return bitset_temp

    cdef int update_score(self, vector[int] suffix, Scorer& scorer) nogil:
        cdef:
            Bitset similar_sequences, bitseq = Bitset(self.alphabet.length)
                                                                  ^
------------------------------------------------------------

cpt/cpt.pyx:299:67: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            size_t i, similar_sequence_id
            Node end_node
            int next_transition, update_count = 0

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
                     ^
------------------------------------------------------------

cpt/cpt.pyx:305:22: Discarding owned Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            size_t i, similar_sequence_id
            Node end_node
            int next_transition, update_count = 0

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
                     ^
------------------------------------------------------------

cpt/cpt.pyx:305:22: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            size_t i, similar_sequence_id
            Node end_node
            int next_transition, update_count = 0

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
                 ^
------------------------------------------------------------

cpt/cpt.pyx:305:18: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            size_t i, similar_sequence_id
            Node end_node
            int next_transition, update_count = 0

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
                     ^
------------------------------------------------------------

cpt/cpt.pyx:305:22: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            size_t i, similar_sequence_id
            Node end_node
            int next_transition, update_count = 0

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
                            ^
------------------------------------------------------------

cpt/cpt.pyx:305:29: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
                                                              ^
------------------------------------------------------------

cpt/cpt.pyx:308:63: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
                                                              ^
------------------------------------------------------------

cpt/cpt.pyx:308:63: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
                                                         ^
------------------------------------------------------------

cpt/cpt.pyx:308:58: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...

        for i in range(suffix.size()):
            bitseq.add(suffix[i])
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
                                                              ^
------------------------------------------------------------

cpt/cpt.pyx:308:63: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
            if similar_sequences[similar_sequence_id]:
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                                                        ^
------------------------------------------------------------

cpt/cpt.pyx:311:57: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
            if similar_sequences[similar_sequence_id]:
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                                                        ^
------------------------------------------------------------

cpt/cpt.pyx:311:57: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
            if similar_sequences[similar_sequence_id]:
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                                          ^
------------------------------------------------------------

cpt/cpt.pyx:311:43: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
            if similar_sequences[similar_sequence_id]:
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                                                        ^
------------------------------------------------------------

cpt/cpt.pyx:311:57: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
        similar_sequences = self.c_find_similar_sequences(suffix)

        for similar_sequence_id in range(similar_sequences.size()):
            if similar_sequences[similar_sequence_id]:
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                                                         ^
------------------------------------------------------------

cpt/cpt.pyx:311:58: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                                ^
------------------------------------------------------------

cpt/cpt.pyx:315:33: Discarding owned Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                                ^
------------------------------------------------------------

cpt/cpt.pyx:315:33: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                         ^
------------------------------------------------------------

cpt/cpt.pyx:315:26: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                                ^
------------------------------------------------------------

cpt/cpt.pyx:315:33: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                end_node = self.lookup_table[similar_sequence_id]
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                                 ^
------------------------------------------------------------

cpt/cpt.pyx:315:34: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                                                 ^
------------------------------------------------------------

cpt/cpt.pyx:316:50: Coercion from Python not allowed without the GIL

Error compiling Cython file:
------------------------------------------------------------
...
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                                                 ^
------------------------------------------------------------

cpt/cpt.pyx:316:50: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                                       ^
------------------------------------------------------------

cpt/cpt.pyx:316:40: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                                                 ^
------------------------------------------------------------

cpt/cpt.pyx:316:50: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                next_transition = self.tree.getTransition(end_node)
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                                                  ^
------------------------------------------------------------

cpt/cpt.pyx:316:51: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                    next_transition = self.tree.getTransition(end_node)
                                                            ^
------------------------------------------------------------

cpt/cpt.pyx:317:61: Coercion from Python not allowed without the GIL
cpt/cpt.pyx: cannot find cimported module 'cpt.alphabet'
cpt/cpt.pyx: cannot find cimported module 'cpt.bitset'
cpt/cpt.pyx: cannot find cimported module 'cpt.prediction_tree'
cpt/cpt.pyx: cannot find cimported module 'cpt.scorer'
cpt/cpt.pxd: cannot find cimported module 'cpt.alphabet'
cpt/cpt.pxd: cannot find cimported module 'cpt.bitset'
cpt/cpt.pxd: cannot find cimported module 'cpt.prediction_tree'
cpt/cpt.pxd: cannot find cimported module 'cpt.scorer'
Compiling cpt/alphabet.pyx because it depends on /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/Cython/Includes/cpython/object.pxd.
Compiling cpt/cpt.pyx because it depends on /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/Cython/Includes/libcpp/vector.pxd.
[1/2] Cythonizing cpt/alphabet.pyx
[2/2] Cythonizing cpt/cpt.pyx

Error compiling Cython file:
------------------------------------------------------------
...
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                    next_transition = self.tree.getTransition(end_node)
                                                            ^
------------------------------------------------------------

cpt/cpt.pyx:317:61: Calling gil-requiring function not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                    next_transition = self.tree.getTransition(end_node)
                                              ^
------------------------------------------------------------

cpt/cpt.pyx:317:47: Accessing Python attribute not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                    next_transition = self.tree.getTransition(end_node)
                                                            ^
------------------------------------------------------------

cpt/cpt.pyx:317:61: Constructing Python tuple not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
                update_count += not bitseq[next_transition]

                while not bitseq[next_transition]:
                    scorer.update(next_transition)
                    end_node = self.tree.getParent(end_node)
                    next_transition = self.tree.getTransition(end_node)
                                                             ^
------------------------------------------------------------

cpt/cpt.pyx:317:62: Converting to Python object not allowed without gil
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-03ie79bc/cpt/setup.py", line 41, in <module>
    compiler_directives={'language_level': sys.version_info[0]}),
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1026, in cythonize
    cythonize_one(*args)
  File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1146, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: cpt/cpt.pyx
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

Add inspect methods for debugging

As a user I would like to know which sequences are similar to mine in order to see why my output is wrong.

To do this CPT should have method to generate sequences with noise reduced and find similar sequences form python shell

Scorer.pyx

  • Use vector to store the scores
  • Avoid comparing every letters in the alphabet in heapq.nlargest

py -3.10.3 cpt build error ...

Hi Louis,
Trying to compile cpt via pip on py 3.10.3 and getting errors:

Collecting cpt
Using cached cpt-1.3.0.tar.gz (113 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'

error: subprocess-exited-with-error

ร— python setup.py egg_info did not run successfully.
โ”‚ exit code: 1
โ•ฐโ”€> [1568 lines of output]
Compiling cpt/alphabet.pyx because it depends on /cube/api/py-3.10.3/lib/python3.10/site-packages/Cython/Includes/cpython/type.pxd.
Compiling cpt/cpt.pyx because it depends on /cube/api/py-3.10.3/lib/python3.10/site-packages/Cython/Includes/cpython/type.pxd.
[1/2] Cythonizing cpt/alphabet.pyx
[2/2] Cythonizing cpt/cpt.pyx

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  from cpt.prediction_tree cimport PredictionTree
  ^
  ------------------------------------------------------------
  
  cpt/cpt.pxd:1:0: 'cpt/prediction_tree.pxd' not found
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  from cpt.prediction_tree cimport PredictionTree
  ^
  ------------------------------------------------------------
  
  cpt/cpt.pxd:1:0: 'cpt/prediction_tree/PredictionTree.pxd' not found
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  from cpt.prediction_tree cimport PredictionTree
  from cpt.alphabet cimport Alphabet
  ^
  ------------------------------------------------------------
  
  cpt/cpt.pxd:2:0: 'cpt/alphabet.pxd' not found
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  from cpt.prediction_tree cimport PredictionTree
  from cpt.alphabet cimport Alphabet
  ^
  ------------------------------------------------------------
  
  cpt/cpt.pxd:2:0: 'cpt/alphabet/Alphabet.pxd' not found
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  from cpt.prediction_tree cimport PredictionTree
  from cpt.alphabet cimport Alphabet
  from cpt.bitset cimport Bitset
  ^
  ------------------------------------------------------------
  
  cpt/cpt.pxd:3:0: 'cpt/bitset.pxd' not found
  
  Error compiling Cython file:
  -----------------------------------------------------------

did you try to compile cpt against 3.10.3

regards,

Mac M2 Isssue

I was not able install and run cpt in Mac M2 pro.
Please provide a guide for it

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.