AttributeError: module 'sklearn.metrics._dist_metrics' has no attribute 'DatasetsPair' - python

I'm trying to balanced my data on jupyter-notebook, using SMOTE:
from imblearn import over_sampling
from imblearn.over_sampling import SMOTE
balanced = SMOTE()
x_balanced , y_balanced = balanced.fit_resample(X_train,y_train)
but I'm getting the following error on the first line -
AttributeError: module 'sklearn.metrics._dist_metrics' has no attribute 'DatasetsPair'
Why am I getting this error?
thanks.

Reinstall scikit learn to version 1.1.0. That should solve the problem

Had the same error while importing modules from skforecast package
from skforecast.model_selection import grid_search_forecaster
from skforecast.model_selection import backtesting_forecaster
Reinstalling scikit-learn to version 1.1.0 or 1.0.0 worked with additionally restarting the jupyter server.

Related

BERT error - module 'tensorflow_core.keras.activations' has no attribute 'swish'

I am trying to execute the transformer model but ended up with error.
Python version == 3.7
Tensorflow == 2.0
Transformers == 4.15.0
Source : https://huggingface.co/cross-encoder/nli-deberta-base?candidateLabels=supply+chain%2C+scientific+discovery%2C+microbiology%2C+robots%2C+archeology&multiClass=false&text=shipment+will+arrive+on+next+week.+our+company+will+transport
my code:
import tensorflow
from transformers import pipeline, AutoModelForTokenClassification,BertTokenizer
pipeline("zero-shot-classification",model="cross-encoder/nli-deberta-v3-small")
Error : module 'tensorflow_core.keras.activations' has no attribute 'swish'
I tried installing Tensorflow==2.3 and restarted the machine. Now the error gone....

ModuleNotFoundError: No module named 'mxnet.contrib.amp' When importing gluonnlp

I have the following versions of mxnet==1.4.0 and gluonnlp==0.9.1 installed using pip.
However when I run the following codeimport gluonnlp as nlp it yields the following error
ModuleNotFoundError: No module named 'mxnet.contrib.amp'
So I try to manually import the missing module using
from mxnet.contrib import amp
import gluonnlp as nlp
which also yields an error
ImportError: cannot import name 'amp' from 'mxnet.contrib' (/usr/local/lib/python3.7/dist-packages/mxnet/contrib/__init__.py)
I've been running the code on Colab. Is there a possible workaround for this issue?
Please Advise.
I have not used these libraries but in this github issue they say:
AMP was introduced in MXNet 1.5. Could you try that version (or newer)?
So I think that the problem is there.
Cheers!

ModuleNotFoundError: No module named 'allennlp.data.iterators'

In Google colab I am to trying import BucketIterator using:
from allennlp.data.iterators import BucketIterator
But it is raising the same error again and again-
ModuleNotFoundError: No module named 'allennlp.data.iterators
After installing allennlp with the imports:
from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
from allennlp.data.tokenizers.character_tokenizer import CharacterTokenizer
from allennlp.data.vocabulary import Vocabulary
from allennlp.modules.seq2vec_encoders import PytorchSeq2VecWrapper
are working fine. Is there a way to solve this issue?
I was facing the same issue.
It won't work, since Iterators are removed from allennlp.
Install a legacy version of allennlp. allennlp is depended upon the PyTorch(torchtext) library. And since torchtext removed iterators form their newer versions allennlp did it too.
You can directly use torchtext.data.BucketIterator(). Use:
pip install torchtext==0.5.0 --user

attribute errors: module has no attribute in tensorflow

I am trying to run a sample script where I use
import tensorflow as tf
def main():
if __name__ = '__main__':
tf.app.run(main = main)
that throws an error:
AttributeError: module 'tensorflow' has no attribute 'app'
but when i run it as:
from tensorflow.python.platform import app
it runs well.. the python version I am using is 3.6.1 and tensorflow version: 0.1.8
actuall even
print(tf.__version__)
is showing an attribute error..
AttributeError: module 'tensorflow' has no attribute '__version__'
As Mitiku pointed out.. there was a problem with the installation so i reinstalled it.. and it works now..
print( dir(tf)) -- this should show the list of packages under tensorflow..
My problem was running Tensorflow 1 script for version 2.
tf.app is moved to tf.compat.v1.app in version 2. There is a tool that helps to upgrade to version 2 automatically.
tf_upgrade_v2 --intree my_project/ --outtree my_project_v2/ --reportfile report.txt
I put it here in case somebody had same issue.

Tensorflow: AttributeError: module 'tensorflow.python' has no attribute 'control_flow_ops'

I'm using keras ver 1.0.8 and tensorflow ver 0.12.0.
I ran python image_zooms_training.py -n 0
then it throws
`AttributeError: module 'tensorflow.python' has no attribute 'control_flow_ops'
please tell me how to solve . thank you for your help.
Following import works. You need to update that line
from tensorflow.python.ops import control_flow_ops
Official TensorFlow Support discourages use of tf.python.* as it is private and intended for development purposes only. While it may work in some cases, it will "break unannounced" in many others.
Instead, try importing tensorflow with the .python portion removed, e.g.:
from tensorflow.keras.models import Sequential

Categories

Resources