Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IncrementalKSTest fail #297

Closed
Tiffany-TW opened this issue Jan 25, 2024 · 6 comments
Closed

IncrementalKSTest fail #297

Tiffany-TW opened this issue Jan 25, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Tiffany-TW
Copy link

Describe the bug

Hi there,
Thank you so much for developing this facinating package for detecting drifts. It not only contains various kinds of algorithms but also easy to be integrated into the machine learning workflow. Unfortunately, the IKS test does not work even when I run the example code provided by frouros. The error shows the following message:

**TypeError: Invalid call to pythranized function `_compute_outer_prob_inside_method(int, int, int32, int)'
Candidates are:

- _compute_outer_prob_inside_method(int64, int64, int64, int64)**

It seems that there is a problem with the data type of the inputs of the function compute_outer_prob_inside_method.
I have modified the script by using np.int64(var_int32). And it works. However, I am not sure whether the modification will lead to incorrect results.
I am looking forward to your quick response. Thank you!

Steps/Code to Reproduce

the example code provided by frouros

from frouros.detectors.data_drift import IncrementalKSTest
import numpy as np
np.random.seed(seed=31)
X = np.random.normal(loc=0, scale=1, size=100)
Y = np.random.normal(loc=1, scale=1, size=100)
detector = IncrementalKSTest(window_size=10)
_ = detector.fit(X=X)
for sample in Y:
test, _ = detector.update(value=sample)
if test is not None:
print(test.statistic, test.p_value)

Expected Results

No error is thrown

Actual Results

TypeError: Invalid call to pythranized function `_compute_outer_prob_inside_method(int, int, int32, int)'
Candidates are:

- _compute_outer_prob_inside_method(int64, int64, int64, int64)

Versions

0.6.1
@Tiffany-TW Tiffany-TW added bug Something isn't working needs triage Issue requires triage labels Jan 25, 2024
@jaime-cespedes-sisniega
Copy link
Contributor

Hi @Tiffany-TW,

Thank you for being interested in using Frouros library!

I've attempted to reproduce the issue using all Python versions compatible with version 0.6.1 (Python 3.{8, 9, 10, 11}), and in each case, there was no error when executing the code.

I suspect that the issue may be related to the compatibility of your numpy or scipy version with the ones specified in 0.6.1 version.

Please provide the Python version you are using and the versions of all packages in your environment. You can obtain this information using the pip freeze command.

Thank you!

@jaime-cespedes-sisniega jaime-cespedes-sisniega removed the needs triage Issue requires triage label Jan 25, 2024
@Tiffany-TW
Copy link
Author

Hi @jaime-cespedes-sisniega,
Thank you so much for your quick response. The following are the information of the versions of Python and packages that I am using.
Python: 3.9
scipy: 1.10.1
numpy: 1.24.3
And they all satisfy the package dependencies for 0.6.1 version. Thank you!

@jaime-cespedes-sisniega
Copy link
Contributor

Hi @Tiffany-TW,

I have attempted to replicate the reported error with Python 3.9, numpy==1.24.3, and scipy==1.10.1, but everything appears to be functioning correctly on my end.

Could you please perform the following steps to help me further investigate the issue?

  • Create a virtualenv with Python 3.9.
    python3.9 -m venv .venv_test
    source .venv_test/bin/activate

  • Install frouros 0.6.1 (which installs numpy==1.25.2 and scipy==1.10.1).
    pip install frouros==0.6.1

  • Execute the IncrementalKSTest example and print the array dtypes. Provide the output or any error encountered.

import numpy as np
np.random.seed(seed=31)
X = np.random.normal(loc=0, scale=1, size=100)
print(X.dtype)
Y = np.random.normal(loc=1, scale=1, size=100)
print(Y.dtype)
detector = IncrementalKSTest(window_size=10)
_ = detector.fit(X=X)
for sample in Y:
    test, _ = detector.update(value=sample)
    if test is not None:
        print(test.statistic, test.p_value)
  • If you prefer to use numpy==1.24.3.
    pip install numpy==1.24.3

  • Execute the IncrementalKSTest example again and provide the output or error encountered.

Thank you!

@Tiffany-TW
Copy link
Author

Hi @jaime-cespedes-sisniega,
Thank you so much for your quick response! I will follow the steps and execute the example again once I am back to my lab.
Thank you!

@Tiffany-TW
Copy link
Author

Tiffany-TW commented Jan 29, 2024

Hi @jaime-cespedes-sisniega,
I have followed the steps that you provided and it works fine! The output is shown as follows:

float64
float64
0.48999999999999994 0.017076114165644283
0.48999999999999994 0.017076114165644283
0.59 0.0017749611644061964
0.48999999999999994 0.017076114165644283
0.59 0.0017749611644061964
0.59 0.0017749611644061964
0.59 0.0017749611644061964
0.59 0.0017749611644061964
0.56 0.0037084103033684338
0.53 0.00736946177546339
0.53 0.00736946177546339
0.53 0.00736946177546339
0.53 0.00736946177546339
0.63 0.000609529321726692
0.63 0.000609529321726692
0.63 0.000609529321726692
0.63 0.000609529321726692
0.63 0.000609529321726692
0.73 2.5523707124036954e-05
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.66 0.000254991605480713
0.66 0.000254991605480713
0.66 0.000254991605480713
0.66 0.000254991605480713
0.56 0.0037084103033684338
0.56 0.0037084103033684338
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5800000000000001 0.00228234123327373
0.5800000000000001 0.00228234123327373
0.68 0.00013764243681949634
0.67 0.0001880475819434029
0.67 0.0001880475819434029
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.5700000000000001 0.002917542391038835
0.47000000000000003 0.025215606785466544
0.5 0.013949893831440276
0.4 0.08512095214731386
0.41 0.0725557449692047
0.51 0.011337601504381846
0.51 0.011337601504381846
0.41 0.0725557449692047
0.42999999999999994 0.051985241573246806
0.38 0.11567743352683023
0.27999999999999997 0.4150062844980919
0.32999999999999996 0.23149506155626867
0.27999999999999997 0.4150062844980919
0.38 0.11567743352683023
0.42999999999999994 0.051985241573246806
0.42999999999999994 0.051985241573246806
0.42999999999999994 0.051985241573246806
0.53 0.00736946177546339
0.53 0.00736946177546339
0.5900000000000001 0.0017749611644061964
0.63 0.000609529321726692
0.63 0.000609529321726692
0.72 3.6388781074041604e-05
0.72 3.6388781074041604e-05
0.62 0.0008040820202593602
0.62 0.0008040820202593602
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.6 0.0013719548736726567
0.7 7.199511188743968e-05
0.7 7.199511188743968e-05
0.75 1.220852122230883e-05
0.75 1.220852122230883e-05
0.75 1.220852122230883e-05
0.75 1.220852122230883e-05
0.75 1.220852122230883e-05
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06
0.76 8.318506604670009e-06

Since the IKS test works fine in the virtual environment, I am really curious about the reason that leads to the initial problem. Do you have any idea? Thank you^^

@jaime-cespedes-sisniega
Copy link
Contributor

Hi @Tiffany-TW,

I'm glad it works for you using a virtual environment!

I'm not sure about the real reason for the problem. But it seems that it is not related to frouros, maybe there are some conflicts with other versions of other packages that you have in the original environment, but this is all speculation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants