I got this error while trying to import sklearn.metric after pip installing sickitlearn on python 3.10.0. Does anybody know how to fix this? Here is my importing code block
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow import keras
import tensorflow_hub as hub
import tensorflow_text as text
import pandas as pd
from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint
from focal_loss import BinaryFocalLoss
from sklearn.metrics import classification_report, confusion_matrix, f1_score
Full error message
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[7], line 10
8 from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint
9 from focal_loss import BinaryFocalLoss
---> 10 from sklearn.metrics import classification_report, confusion_matrix, f1_score
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn__init__.py:73
62 # `_distributor_init` allows distributors to run custom init code.
63 # For instance, for the Windows wheel, this is used to pre-load the
64 # vcomp shared library runtime for OpenMP embedded in the sklearn/.libs
(...)
67 # later is linked to the OpenMP runtime to make it possible to introspect
68 # it and importing it first would fail if the OpenMP dll cannot be found.
69 from . import ( # noqa: F401 E402
70 __check_build,
71 _distributor_init,
72 )
---> 73 from .base import clone # noqa: E402
74 from .utils._show_versions import show_versions # noqa: E402
76 _submodules = [
77 "calibration",
78 "cluster",
(...)
114 "compose",
115 ]
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\base.py:20
18 from .exceptions import InconsistentVersionWarning
19 from .utils._metadata_requests import _MetadataRequester, _routing_enabled
---> 20 from .utils._missing import is_scalar_nan
21 from .utils._param_validation import validate_parameter_constraints
22 from .utils._repr_html.base import ReprHTMLMixin, _HTMLDocumentationLinkMixin
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils__init__.py:9
7 from . import metadata_routing
8 from ._bunch import Bunch
----> 9 from ._chunking import gen_batches, gen_even_slices
11 # Make _safe_indexing importable from here for backward compat as this particular
12 # helper is considered semi-private and typically very useful for third-party
13 # libraries that want to comply with scikit-learn's estimator API. In particular,
14 # _safe_indexing was included in our public API documentation despite the leading
15 # `_` in its name.
16 from ._indexing import (
17 _safe_indexing, # noqa: F401
18 resample,
19 shuffle,
20 )
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils_chunking.py:11
8 import numpy as np
10 from .._config import get_config
---> 11 from ._param_validation import Interval, validate_params
14 def chunk_generator(gen, chunksize):
15 """Chunk generator, ``gen`` into lists of length ``chunksize``. The last
16 chunk may have a length less than ``chunksize``."""
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\utils_param_validation.py:14
11 from numbers import Integral, Real
13 import numpy as np
---> 14 from scipy.sparse import csr_matrix, issparse
16 from .._config import config_context, get_config
17 from .validation import _is_arraylike_not_scalar
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\sparse__init__.py:300
294 # Original code by Travis Oliphant.
295 # Modified and extended by Ed Schofield, Robert Cimrman,
296 # Nathan Bell, and Jake Vanderplas.
298 import warnings as _warnings
--> 300 from ._base import *
301 from ._csr import *
302 from ._csc import *
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\sparse_base.py:5
1 """Base class for sparse matrices"""
3 import numpy as np
----> 5 from ._sputils import (asmatrix, check_reshape_kwargs, check_shape,
6 get_sum_dtype, isdense, isscalarlike,
7 matrix, validateaxis, getdtype)
9 from ._matrix import spmatrix
11 __all__ = ['isspmatrix', 'issparse', 'sparray',
12 'SparseWarning', 'SparseEfficiencyWarning']
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\sparse_sputils.py:10
8 from math import prod
9 import scipy.sparse as sp
---> 10 from scipy._lib._util import np_long, np_ulong
13 __all__ = ['upcast', 'getdtype', 'getdata', 'isscalarlike', 'isintlike',
14 'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype',
15 'broadcast_shapes']
17 supported_dtypes = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc,
18 np.uintc, np_long, np_ulong, np.longlong, np.ulonglong,
19 np.float32, np.float64, np.longdouble,
20 np.complex64, np.complex128, np.clongdouble]
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy_lib_util.py:13
10 from typing import TypeAlias, TypeVar
12 import numpy as np
---> 13 from scipy._lib._array_api import array_namespace, is_numpy, xp_size
14 from scipy._lib._docscrape import FunctionDoc, Parameter
17 AxisError: type[Exception]
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy_lib_array_api.py:15
12 from typing import Any, Literal, TypeAlias
14 import numpy as np
---> 15 import numpy.typing as npt
17 from scipy._lib import array_api_compat
18 from scipy._lib.array_api_compat import (
19 is_array_api_obj,
20 size as xp_size,
(...)
27 is_array_api_strict_namespace as is_array_api_strict
28 )
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\typing__init__.py:158
1 """
2 ============================
3 Typing (:mod:`numpy.typing`)
(...)
153
154 """
155 # NOTE: The API section will be appended with additional entries
156 # further down in this file
--> 158 from numpy._typing import (
159 ArrayLike,
160 DTypeLike,
161 NBitBase,
162 NDArray,
163 )
165 __all__ = ["ArrayLike", "DTypeLike", "NBitBase", "NDArray"]
167 if __doc__ is not None:
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy_typing__init__.py:102
86 from ._scalars import (
87 _CharLike_co as _CharLike_co,
88 _BoolLike_co as _BoolLike_co,
(...)
96 _VoidLike_co as _VoidLike_co,
97 )
98 from ._shape import (
99 _Shape as _Shape,
100 _ShapeLike as _ShapeLike,
101 )
--> 102 from ._dtype_like import (
103 DTypeLike as DTypeLike,
104 _DTypeLike as _DTypeLike,
105 _SupportsDType as _SupportsDType,
106 _VoidDTypeLike as _VoidDTypeLike,
107 _DTypeLikeBool as _DTypeLikeBool,
108 _DTypeLikeUInt as _DTypeLikeUInt,
109 _DTypeLikeInt as _DTypeLikeInt,
110 _DTypeLikeFloat as _DTypeLikeFloat,
111 _DTypeLikeComplex as _DTypeLikeComplex,
112 _DTypeLikeTD64 as _DTypeLikeTD64,
113 _DTypeLikeDT64 as _DTypeLikeDT64,
114 _DTypeLikeObject as _DTypeLikeObject,
115 _DTypeLikeVoid as _DTypeLikeVoid,
116 _DTypeLikeStr as _DTypeLikeStr,
117 _DTypeLikeBytes as _DTypeLikeBytes,
118 _DTypeLikeComplex_co as _DTypeLikeComplex_co,
119 )
120 from ._array_like import (
121 NDArray as NDArray,
122 ArrayLike as ArrayLike,
(...)
145 _UnknownType as _UnknownType,
146 )
148 from ._ufunc import (
149 _UFunc_Nin1_Nout1 as _UFunc_Nin1_Nout1,
150 _UFunc_Nin2_Nout1 as _UFunc_Nin2_Nout1,
(...)
153 _GUFunc_Nin2_Nout1 as _GUFunc_Nin2_Nout1,
154 )
File c:\Users\DELL\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy_typing_dtype_like.py:194
162 _DTypeLikeInt: TypeAlias = (
163 type[int]
164 | type[np.signedinteger[Any]]
(...)
177 | _IntCodes
178 )
179 _DTypeLikeFloat: TypeAlias = (
180 type[float]
181 | type[np.floating[Any]]
(...)
190 | _LongDoubleCodes
191 )
192 _DTypeLikeComplex: TypeAlias = (
193 type[complex]
--> 194 | type[np.complexfloating[Any]]
195 | np.dtype[np.complexfloating[Any]]
196 | _SupportsDType[np.dtype[np.complexfloating[Any]]]
197 | _Complex64Codes
198 | _Complex128Codes
199 | _CSingleCodes
200 | _CDoubleCodes
201 | _CLongDoubleCodes
202 )
203 _DTypeLikeDT64: TypeAlias = (
204 type[np.timedelta64]
205 | np.dtype[np.timedelta64]
206 | _SupportsDType[np.dtype[np.timedelta64]]
207 | _TD64Codes
208 )
209 _DTypeLikeTD64: TypeAlias = (
210 type[np.datetime64]
211 | np.dtype[np.datetime64]
212 | _SupportsDType[np.dtype[np.datetime64]]
213 | _DT64Codes
214 )
TypeError: Too few arguments for numpy.complexfloating
Interesting for some reason, sickitlearn uninstall numpy 1.23 despite for sickitlean 1.7.2 only need NumPy (>= 1.22.0) to install 2.2.6 which mess up every other packages' installation. How do I fix this?