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

BUG: scipy.stats.logistic.fit cannot fitting any parameters #16204

Closed
HZT3434 opened this issue May 18, 2022 · 17 comments
Closed

BUG: scipy.stats.logistic.fit cannot fitting any parameters #16204

HZT3434 opened this issue May 18, 2022 · 17 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.stats

Comments

@HZT3434
Copy link

HZT3434 commented May 18, 2022

Describe your issue.

When I call for logistic.fit(), it returns error say that there is a type error, during the optimzation it occurs None type value.

Reproducing Code Example

ss.logistic.fit(x)

Error message

Traceback (most recent call last):
  File "E:\Python\Python3_10\lib\site-packages\numpy\core\getlimits.py", line 459, in __new__
    dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "E:\Python\Python3_10\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-33-05b96b2f6f8c>", line 1, in <cell line: 1>
    ss.logistic.fit(x)
  File "E:\Python\Python3_10\lib\site-packages\scipy\stats\_continuous_distns.py", line 63, in wrapper
    return fun(self, *args, **kwds)
  File "E:\Python\Python3_10\lib\site-packages\scipy\stats\_continuous_distns.py", line 5242, in fit
    return tuple(optimize.root(func, (loc, scale), args=(data,)).x)
  File "E:\Python\Python3_10\lib\site-packages\scipy\optimize\_root.py", line 234, in root
    sol = _root_hybr(fun, x0, args=args, jac=jac, **options)
  File "E:\Python\Python3_10\lib\site-packages\scipy\optimize\_minpack_py.py", line 228, in _root_hybr
    epsfcn = finfo(dtype).eps
  File "E:\Python\Python3_10\lib\site-packages\numpy\core\getlimits.py", line 462, in __new__
    dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable

SciPy/NumPy/Python version information

1.8.0 1.22.3 sys.version_info(major=3, minor=10, micro=3, releaselevel='final', serial=0)

@HZT3434 HZT3434 added the defect A clear bug or issue that prevents SciPy from being installed or used as expected label May 18, 2022
@tupui
Copy link
Member

tupui commented May 18, 2022

Hi @HZT3434, thank you for reporting. Can you list a complete reproducible example? What is x?

@HZT3434
Copy link
Author

HZT3434 commented May 18, 2022 via email

@tupui
Copy link
Member

tupui commented May 18, 2022

I cannot reproduce the issue on Python 3.10 with the latest released version nor the development version.

import scipy.stats as stats
x = stats.logistic.rvs(size=10)
stats.logistic.fit(x)
# (0.6128791075218377, 0.7050674549310291)

@tupui
Copy link
Member

tupui commented May 18, 2022

Can you give more details about x? The dtype, shape, range, etc. could help.

@HZT3434
Copy link
Author

HZT3434 commented May 19, 2022 via email

@rkern
Copy link
Member

rkern commented May 19, 2022

This looks like the problem with all-but-the-latest Cython, Python 3.10, and some kind of debugger or tracer being used (c.f. numpy/numpy#21519)

@rkern
Copy link
Member

rkern commented May 19, 2022

Nothing to do but wait for the release cycles of numpy (1.22.4 should have the fix) and scipy (don't see anything about it in the 1.8.1 release notes) to churn through with the latest Cython being used. In the meantime, avoid using a debugger.

@HZT3434
Copy link
Author

HZT3434 commented May 19, 2022 via email

@HZT3434
Copy link
Author

HZT3434 commented May 19, 2022 via email

@mdhaber
Copy link
Contributor

mdhaber commented May 19, 2022

Does that mean we can close this?
@HZT3434 is your problem resolved when you are not using a debugger?

@HZT3434
Copy link
Author

HZT3434 commented May 19, 2022 via email

@mdhaber mdhaber closed this as completed May 19, 2022
@cartisan
Copy link

The new Cython version has been released, and a new numpy version has been compiled based on that. What's the scipy status in this regard?
Because despite using the newest numpy version the debugging problem described above still persists for me, and I suspect its either scipy or pandas causing it.

@tupui
Copy link
Member

tupui commented Jun 20, 2022

@cartisan we have several jobs in CI using latest Cython and latest (even main branch) NumPy. See https://github.com/scipy/scipy/blob/main/.github/workflows/linux.yml for instance. Can you give more details?

@cartisan
Copy link

@tupui I have been able to zero in the error to the latest pandas version, which apparently is not yet built using the new Cyton. Sorry for stirring up the old thread!

@tupui
Copy link
Member

tupui commented Jun 20, 2022

@cartisan no worries. Thank you for the precisions, all "good" then.

@jabowery
Copy link

jabowery commented Jun 30, 2022

By disabling debugging, this has stopped development here. Optimization of runtimes while debugging is a far lower priority than is debugging itself. Why is it so difficult to disable cython's optimization of debugging runtimes so we can get on with debugging hence development?

PS: PYDEVD_USE_CYTHON=NO is set but doesn't re-enable debugging.

@tupui
Copy link
Member

tupui commented Jun 30, 2022

@jabowery I don't think I follow what you are trying to say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.stats
Projects
None yet
Development

No branches or pull requests

6 participants