error from numpy when importing sk-kmeans - numpy

i am trying to import :
from sklearn.cluster import KMeans as sk_KMeans
but i get the following error:
AttributeError: module 'numpy' has no attribute 'float'
how do i fix this?

Related

AttributeError: module 'numpy' has no attribute 'warnings'

from sklearn.preprocessing import PowerTransformer
pt = PowerTransformer(method='yeo-johnson',standardize=True)
X_train['feature']=pt.fit_transform(np.array(X_train['feature']).reshape(-1, 1))
#fit the model only on the train set and transform the test set
X_test['feature']=pt.transform(np.array(X_test['feature']).reshape(-1, 1))
getting below error
AttributeError: module 'numpy' has no attribute 'warnings'
working fine with numpy==1.23.4
giving error with numpy==1.24.0

AttributeError: module 'matplotlib.pyplot' has no attribute 'plotfile'

Hello sorry I am very new at Python and I cannot figure out what I am missing. I am trying to use plotfile, my code is
import matplotlib.pyplot as plt
plt.plotfile('somefile.dat',delimiter=' ', cols=(0, 1),
names=('A, 'B'), marker='o')
and gives me the following error
AttributeError: module 'matplotlib.pyplot' has no attribute 'plotfile'

module 'tensorflow.python.util.dispatch' has no attribute 'add_fallback_dispatch_list'

I get the following error with the code import keras:
AttributeError: module 'tensorflow.python.util.dispatch' has no attribute 'add_fallback_dispatch_list'

ModuleNotFoundError for .vision and .utils , download_url, VisionDataset

I am trying to create a custom dataset in google colab, but imports give me errors.
from PIL import Image
from six.moves import zip
import os
from .vision import VisionDataset ------------------------(1)
from .utils import download_url, check_integrity --------------(2)
class datasetName(VisionDataset):
...
(1) error :
ModuleNotFoundError: No module named 'main.vision'; 'main' is
not a package
(2) error :
ModuleNotFoundError: No module named 'main.utils'; 'main' is
not a package
I have tried to add from torchvision import utils but it does not solve the error.
If I change to from torch.utils import download_url, check_integrity
then the error becomes:
ImportError: cannot import name 'download_url'
Please try the following import lines.
from torchvision.datasets.vision import VisionDataset
from torchvision.datasets.utils import download_url, check_integrity
Hope it helps!

Tensorflow: import init_ops and random_ops

I would like to create a custom initializer based on the code of tf.truncated_normal_initializer.
However, when I try to import init_ops and random_ops. I get the error:
AttributeError: 'module' object has no attribute 'ops'
to reproduce:
import tensorflow.python.ops.random_ops as random_ops
Oops, quite trivial. Issue solved with
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import init_ops