Azure / Azure-TDSP-Utilities

Utilities and scripts developed as part of Microsoft's Team Data Science Process for productive data science
Creative Commons Attribution 4.0 International
373 stars 275 forks source link

Error in IDEAR.ipynb ('int' object has no attribute 'children') #26

Closed ArunNairID closed 6 years ago

ArunNairID commented 7 years ago

Platform: Windows 10 Environment : Anaconda Python3.6 (also checked with Python 3.5 and Python2.7)

Error in IDEAR.ipynb in Cell : Explore the target variable and onwards

Error: `--------------------------------------------------------------------------- ValueError Traceback (most recent call last)

in () ----> 1 i = interactive(TargetAnalytics.custom_barplot, df=fixed(df), filename=fixed(filename), col1=w1, Export=w_export) C:\Anaconda3\envs\python36\lib\site-packages\ipywidgets\widgets\interaction.py in __init__(self, _interactive__interact_f, _interactive__options, **kwargs) 160 getcallargs(f, **{n:v for n,v,_ in new_kwargs}) 161 # Now build the widgets from the abbreviations. --> 162 self.kwargs_widgets = self.widgets_from_abbreviations(new_kwargs) 163 164 # This has to be done as an assignment, not using self.children.append, C:\Anaconda3\envs\python36\lib\site-packages\ipywidgets\widgets\interaction.py in widgets_from_abbreviations(self, seq) 258 if not (isinstance(widget, ValueWidget) or isinstance(widget, fixed)): 259 if widget is None: --> 260 raise ValueError("{!r} cannot be transformed to a widget".format(abbrev)) 261 else: 262 raise TypeError("{!r} is not a ValueWidget".format(widget)) ValueError: cannot be transformed to a widget --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () 21 get_ipython().magic('reset_report') 22 get_ipython().magic('add_interaction_code_to_report i = interactive(TargetAnalytics.custom_barplot, df=fixed(df), filename=fixed(filename), col1=w1, Export=w_export)') ---> 23 hbox = widgets.HBox(i.children) 24 25 display(hbox) AttributeError: 'int' object has no attribute 'children'`
BrendaXimena commented 7 years ago

The same error here. Did you solve it? :(

ArunNairID commented 7 years ago

Yes downgrade your ipywidgets to 4.

wguo123 commented 7 years ago

Hi @ArunNairID , did you use the latest version of IDEAR-Python-AzureNotebooks? I cloned the latest version from GitHub and tested in my machine, it works well. The script should be "i = interactive(TargetAnalytics.custom_barplot, df=fixed(df), col1=w1)" which looks different from your error code. For ipywidgets, try 6.0 or later, see if it works.

mathewnik90 commented 7 years ago

The error is in the the IDEAR notebook when run using Anaconda https://github.com/Azure/Azure-TDSP-Utilities/blob/master/DataScienceUtilities/DataReport-Utils/Python/IDEAR.ipynb

hangyao commented 7 years ago

I encountered the same issue when running with Anaconda Python3.6

And downgrading ipywidgets from 6.0 or 7.0 to 5.2.2 solved the issue.

However ipywidgets 5.2.2 or earlier has an issue that it can't detect Widget Javascript and therefore can't show widgets in noteebook. Running jupyter nbextension enable --py --sys-prefix widgetsnbextension doesn't solve the issue.

mathewnik90 commented 7 years ago

Hi @hangyao, The other notebook seems to be providing all the functionalities. I eventually resorted to using it. It works perfectly fine in Anaconda with latest version of packages. https://github.com/Azure/Azure-TDSP-Utilities/blob/master/DataScienceUtilities/DataReport-Utils/Python/IDEAR-Python-AzureNotebooks.ipynb

Regarding,

Running jupyter nbextension enable --py --sys-prefix widgetsnbextension doesn't solve the issue.

You need to restart the Jupyter Console once you run the above code in Anaconda prompt. I haven't tried it with version 5.2.2 though. Hope this helps :)

hangyao commented 7 years ago

Hi @mathewnik90 , yes, you are absolutely right! Thank you! As long as I don't need to generate and combine reports, IDEAR-Python-AzureNotebooks.ipynb should be good to use. Have you tried if it can handle report generation and combination yet?

Thank you very much! It helps a lot!

mathewnik90 commented 7 years ago

@hangyao: No, IDEAR-Python-AzureNotebooks.ipynb doesn't support report generation and combination. I was able to get IDEAR.ipynb working with the export button. However, the report generated was buggy. In few cases 80% code was generated, however in few others less than that. I have not got a chance to get back to it. You might want to look at the toggle code button at the bottom of the report. I am using that button along with adding inference below the charts, seems to be doing the trick for me :)

AlphaGit commented 6 years ago

@wguo123 I'd like to mention that your different script indeed fixes the issue. However, the latest notebook still has the code mentioned by @ArunNairID.

You can see it here: https://github.com/Azure/Azure-TDSP-Utilities/blob/master/DataScienceUtilities/DataReport-Utils/Python/IDEAR.ipynb, in the cell right under "Explore the Target Variable".

I might be sending a PR with a few small modifications I needed to make to get the notebook running, including this little change. If I don't get to it, I wanted to mention that the old script seems to still be there.

Thanks!

woodmicha commented 6 years ago

@mathewnik90 sorry for the newbie question but I'm trying to get this suite of utilities running on a docker image w/o Azure. I was able to get further by downgrading the images version of ipywidgets to 5.2.2 but I continue to get the following warning:

Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"

I've executed the following command:

jupyter nbextension enable --py --sys-prefix widgetsnbextension

which reports the following:

`Enabling notebook extension jupyter-js-widgets/extension...

I've committed that change to my docker image and restarted jupyter notebook but continue to get the javascript (JS) warnings. It does produce the outputs but not 100% certain since the JS warnings persist.

Is there a different way to persist the enabling of the extension?

mathewnik90 commented 6 years ago

@woodmicha : I haven't tried iPyWidgets in docker. This thread throws some light on the issue. Hope this helps.

ngminhtrung commented 6 years ago

I have encountered the same issue as ArunNairID.

My environment: Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]

Confirm that downgrading ipywidgets from version 7 to version 5.2.2 solved the issue.