Gradient Boosting classifier issue - xgboost

I am getting crazy trying to fix the issue of "name 'XGBClassifier' is not defined".
Any clue please?
My environment is Win 64, Python 3.7

This can be very open ended issue. I would suggest you to check if Xgboost is imported or not , if not imported than is there any installation issue or not-
try:
import xgboost
except ImportError:
pass
except:
print("xgboost is installed...but failed to load!")
pass
Other points to be consider,
Try to work in virtual environment which can exempt the other packages conflict with xgboost version.
Check the Input shape - there are times when this is the root cause of issue.

Related

Error in Power BI while importing pandas library in python scrip

Below are the mentioned error while importing pandas library in Power BI in python script.
Details: "ADO.NET: Python script error.
C:\USERS\YADAVP\ANACONDA3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\USERS\YADAVP\ANACONDA3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\USERS\YADAVP\ANACONDA3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
What is the resolution to sort this kind of error in Power BI?
Forget Anaconda and use WinPython.
I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere.
Then I tried WinPython, and it worked immediately. Of course, you will need to change the PowerBI options accordingly.
To install WinPython: https://github.com/winpython/winpython
To change the detected Python home directory: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts#enable-python-scripting
If you consider my answer, you won't need to downgrade Python, PBI, or anything else.
I had the same error. Unfortunately, PowerBI wont work with Jupyter Notebook Python.
So you have to install a "normal" Python: https://www.python.org/downloads/
And configure the Python you want to use in PowerBI and install your needed Python libraries via pip
Edit: Please use Python 3.8 because 3.9 doesnt support NumPy for now

DLL load failed _multiarray_unmath when importing numpy

I installed Numpy v. 1.18.4 and Python 3.8. These are the latest as of 5/2020 I think. I get the error:
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\Users\SScott1\.conda\envs\cartoenv7_3_8\python.exe"
* The NumPy version is: "1.18.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
Is there a place I can report this? How do I resolve this error.
This happens when you launch VS Code outside of Anaconda Navigator.
This question already has a few answers here and here. Adding this to the environment path worked for me:
C:\Users\ <username> \Anaconda3\Library\bin

Tensorflow set_seed error when running autoencoder

I am trying to run the code from here,
https://medium.com/#abien.agarap/implementing-an-autoencoder-in-tensorflow-2-0-5e86126e9f7
but am getting this error,
File
"C:/Users/rupert/Versioning/PCTSoftware/Libraries/python/tensorflow/autoencoders/autoencoder-full.py",
line 12, in
tf.random.set_seed(1)
AttributeError: module 'tensorflow._api.v1.random' has no attribute
'set_seed'
Any ideas on how to resolve?
Tensorflow 1.13
Windows 7
Try this:
tf.random.set_random_seed(1)
As you can see, the post is focusing on the version 2.0.0 of tensorflow. You should run their code with their version.

NameError: name 'python' is not defined when importing part of tensorflow's deeplab module

Thanks to this github issue, I realise that I shouldn't try to reload tensorflow, because I get this error:
del python
NameError: name 'python' is not defined
when I do
import tensorflow
from deeplab import common
In case it's relevant, import deeplab works fine.
I saw elsewhere that it's probably the IPython session in spyder that is keeping a tensorflow session open. So I closed spyder - but launching python in the shell gave me the same issue. ps -ef | grep -E 'py|tensorflow|tensorboard|tf' came up empty. What could still be hanging around and causing tensorflow to try a reload, rather than a fresh load?
I understand that the issue around reloading tensorflow will not be resolved. How do I make sure that I have cleared everything from my previous runs so that it will be a fresh load rather than a reload?
Edit: even after restarting the computer I get the same error. Even if the first thing I do is open a python console and type from deeplab import common. That means the original title to my question is probably wrong, so I have changed it.

OpenAI Gym error running demo from intro page

I installed OpenAI Gym and attempted to run the getting-started cart-pole demo (https://gym.openai.com/docs/). (I'm running in a Colab notebook.)
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
This doesn't learn, but it should display the cart and pole.
When I run it I get a warning and an error.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
The error is triggered by env.render(). At the bottom of the Traceback is
Error occured while running `from pyglet.gl import *`
The original exception was:
ImportError: Library "GL" not found.
I had installed pyOpenGL with the following.
!pip install PyOpenGL PyOpenGL_accelerate
I'd appreciate help with both the warning and the error. Is there another GL library I should install?
Thanks.
Google Colab is run in the cloud. It can't send the graphic display back to your monitor.
You can try running it with local runtime.
https://research.google.com/colaboratory/local-runtimes.html
Do you get this window?
If yes then try to add this import:
import time
and this line of Code within the for-loop:
time.sleep(0.3)
Thing is that the pole runs out of view rather quick, so it seems like
the Environment did not run at all.