Python Forum

Full Version: ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import numpy as np
import keras
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0,1))
import pytse_client as tse
import tensorflow as tf
import seaborn as sns
from timeit import default_timer as timer
from keras.layers import LSTM, Dense, Dropout,Convolution1D, Activation, MaxPooling1D, Flatten,Input
from keras.models import Model, Sequential, load_model
from matplotlib.pylab import rcParams
from keras.utils import to_categorical
from tensorflow.keras import optimizers
from tensorflow.keras.callbacks import EarlyStopping
from sklearn.metrics import mean_squared_error,accuracy_score,mean_absolute_error
from math import sqrt
import math
from tensorflow.keras import layers
from keras.callbacks import TensorBoard
from time import time
from tqdm.keras import TqdmCallback
Error:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) Cell In[9], line 5 3 import matplotlib.pyplot as plt 4 import pandas as pd ----> 5 from sklearn.preprocessing import MinMaxScaler 6 scaler = MinMaxScaler(feature_range=(0,1)) 7 import pytse_client as tse File E:\Softwares\Python\Lib\site-packages\sklearn\__init__.py:84 70 # We are not importing the rest of scikit-learn during the build 71 # process, as it may not be compiled yet 72 else: (...) 78 # later is linked to the OpenMP runtime to make it possible to introspect 79 # it and importing it first would fail if the OpenMP dll cannot be found. 80 from . import ( 81 __check_build, # noqa: F401 82 _distributor_init, # noqa: F401 83 ) ---> 84 from .base import clone 85 from .utils._show_versions import show_versions 87 __all__ = [ 88 "calibration", 89 "cluster", (...) 130 "show_versions", 131 ] File E:\Softwares\Python\Lib\site-packages\sklearn\base.py:19 17 from ._config import config_context, get_config 18 from .exceptions import InconsistentVersionWarning ---> 19 from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr 20 from .utils._metadata_requests import _MetadataRequester, _routing_enabled 21 from .utils._param_validation import validate_parameter_constraints File E:\Softwares\Python\Lib\site-packages\sklearn\utils\__init__.py:11 9 from . import _joblib, metadata_routing 10 from ._bunch import Bunch ---> 11 from ._chunking import gen_batches, gen_even_slices 12 from ._estimator_html_repr import estimator_html_repr 14 # Make _safe_indexing importable from here for backward compat as this particular 15 # helper is considered semi-private and typically very useful for third-party 16 # libraries that want to comply with scikit-learn's estimator API. In particular, 17 # _safe_indexing was included in our public API documentation despite the leading 18 # `_` in its name. File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_chunking.py:8 5 import numpy as np 7 from .._config import get_config ----> 8 from ._param_validation import Interval, validate_params 11 def chunk_generator(gen, chunksize): 12 """Chunk generator, ``gen`` into lists of length ``chunksize``. The last 13 chunk may have a length less than ``chunksize``.""" File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_param_validation.py:14 11 from scipy.sparse import csr_matrix, issparse 13 from .._config import config_context, get_config ---> 14 from .validation import _is_arraylike_not_scalar 17 class InvalidParameterError(ValueError, TypeError): 18 """Custom exception to be raised when the parameter of a class/method/function 19 does not have a valid type or value. 20 """ File E:\Softwares\Python\Lib\site-packages\sklearn\utils\validation.py:26 24 from .. import get_config as _get_config 25 from ..exceptions import DataConversionWarning, NotFittedError, PositiveSpectrumWarning ---> 26 from ..utils._array_api import _asarray_with_order, _is_numpy_namespace, get_namespace 27 from ..utils.fixes import ComplexWarning, _preserve_dia_indices_dtype 28 from ._isfinite import FiniteStatus, cy_isfinite File E:\Softwares\Python\Lib\site-packages\sklearn\utils\_array_api.py:8 5 from functools import wraps 7 import numpy ----> 8 import scipy.special as special 10 from .._config import get_config 11 from .fixes import parse_version File E:\Softwares\Python\Lib\site-packages\scipy\special\__init__.py:811 808 from ._ufuncs import * 810 # Replace some function definitions from _ufuncs to add Array API support --> 811 from ._support_alternative_backends import ( 812 log_ndtr, ndtr, ndtri, erf, erfc, i0, i0e, i1, i1e, gammaln, 813 gammainc, gammaincc, logit, expit, entr, rel_entr, xlogy, chdtrc) 815 from . import _basic 816 from ._basic import * File E:\Softwares\Python\Lib\site-packages\scipy\special\_support_alternative_backends.py:7 5 import numpy as np 6 import scipy ----> 7 from scipy._lib._array_api import ( 8 array_namespace, scipy_namespace_for, is_numpy, is_torch 9 ) 10 from . import _ufuncs 11 # These don't really need to be imported, but otherwise IDEs might not realize 12 # that these are defined in this file / report an error in __init__.py ImportError: cannot import name 'scipy_namespace_for' from 'scipy._lib._array_api' (E:\Softwares\Python\Lib\site-packages\scipy\_lib\_array_api.py)