I tried all possible solution, but still getting this error, already installed all dependent libraries.
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from tqdm import tqdm
import xgboost as xgb
d_train = xgb.DMatrix(X_train, label=y_train)
AttributeError: 'module' object has no attribute 'DMatrix'
You can force upgrade of XGBoost with:
python -m pip install xgboost --user --upgrade pip
This fixed it for me.
Related
I'm trying "from sklearn.linear_model import SGDOneClassSVM"
but it doesn't work and raises an import error "ImportError: cannot import name 'SGDOneClassSVM' from 'sklearn.linear_model"
Upgrade sklearn package using the command:
pip install --upgrade scikit-learn
I'm trying to import these libraries:
from math import sqrt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from sklearn.metrics import mean_absolute_error, mean_squared_error
from pyramid.arima import auto_arima
from statsmodels.tsa.stattools import adfuller
But this error is coming again and again
ModuleNotFoundError: No module named 'pyramid'
I have tried pip install pyramid-arima but it's also throwing me so many errors in cmd.
Can anyone suggest to me what I can do to resolve this problem?
try
pip install pmdarima
pmdarima is the official new name for pyramid.arima.
Try to install pmdarima by using pip:
pip install pmdarima
I also needed to modify my python script to use:
from pmdarima.arima import auto_arima
My code works fine in the local system and then I will decide to shift the code into the server. I just create an anaconda environment and install everything but now it gives no module error. Everything is the same even the python version and the file is also present in the folder. I tested on my local system and it is working without any error.
Tracback
Traceback (most recent call last):
File "Ensemble-Face-Recognition.py", line 21, in <module>
from deepface import DeepFace
ModuleNotFoundError: No module named 'deepface'
Code in python file
from pandas.core.frame import DataFrame
import lightgbm as lgb
import more_itertools
import pandas as pd
import numpy as np
import itertools
from os import cpu_count
from sklearn.metrics import confusion_matrix, accuracy_score, roc_curve, auc
import matplotlib.pyplot as plt
import json
import os
import gc
from tqdm import tqdm
from deepface import DeepFace
from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
You have to activate your environment first and then install the required deepface package. You have to run the program above when that virtual environment activated.
C:\Users\YOUR_USER\Desktop> conda activate YOUR_ENV
(YOUR_ENV) C:\Users\YOUR_USER\Desktop> pip install deepface
(YOUR_ENV) C:\Users\YOUR_USER\Desktop> pip freeze
(YOUR_ENV) C:\Users\YOUR_USER\Desktop> python Ensemble-Face-Recognition.py
Once you activated your environment, then you should see the deepface when you called pip freeze.
I am currently using anaconda 4.8.3 and want to display a figure of decision tree and i have install graphviz and pydotplus library in anaconda instead of this i am getting error 'ModuleNotFoundError: No module named 'sklearn.externals.six' .this is my code:
from sklearn.tree import DecisionTreeClassifier
from IPython.display import Image
from sklearn.externals.six import StringIO
from sklearn.tree import export_graphviz
import pydot
features = list(df.columns[1:])
features
This is my error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-0b3416ce7fda> in <module>
1 from IPython.display import Image
---> 2 from sklearn.externals.six import StringIO
3 from sklearn.tree import export_graphviz
4 import pydot
5 ModuleNotFoundError: No module named 'sklearn.externals.six'
You can import StringIO from module six directly, no need to downgrade scikit.
from six import StringIO
Module sklearn.externals.six was removed in the scikit-learn version 0.23. To use it you have to downgrade to version 0.22. For that, you can do -
In jupyter notebook try :!pip install --upgrade scikit-learn==0.22
In terminal: pip install --upgrade scikit-learn==0.22
from sklearn import svm
ImportError: cannot import name __check_build
I've been able to install scikit-learn on a fresh virtualenv here but it seems you need to do some extra job to get it up-and-running:
By doing just pip install scikit-learn and then from sklearn import svm you'll get import errors, it seems the library requires numpy and scipy. So you need to do:
pip install numpy scipy
After that it should work fine.