Machinelearning: Jupyter + ML.NET | Plotly

Created on 26 Sep 2019  路  7Comments  路  Source: dotnet/machinelearning

This may not be the correct forum for this question, and if not, I'm happy to close it.

Plotly created very large graphs, greatly slowing down the browser, especially compared to it's Python counterparts. I created a simple Scatter plot based on a dataset of 30 Mb, and Google Chrome almost completely came to a halt. I've created similar plots in Python equivalents for 500+ Mb of data with the browser running smoothly.

This means that XPlot.Plotly will not be a feasible option for any real-life datasets. Are there any other alternatives for the .NET community that we can recommend? Or should I reach out to Plotly to see if this is just a bug?

Most helpful comment

@colombod let me in on the secret: WebGL.

See https://plot.ly/python/webgl-vs-svg/

Implement WebGL for increased speed, improved interactivity, and the ability to plot even more data!

In XPlot, certain charts have a gl suffix overload that will use WebGL instead of SVG.

I have updated the example notebook in dotnet/try to use Scattergl and the performance is now much better - https://github.com/dotnet/try/pull/496.

All 7 comments

It'd be great if you can reach Plotly in parallel.
But this is great feedback. We should consider multiple options for plotting. 馃憤

Will do, I'll add an issue in the Plotly Github repo. Would you know if there are any C# API docs for Plotly? So far I've only found them for F#

@eerhardt @jonsequitur Any observation on this issue related to lack of performance of XPlot using Plotly when plotting a significant data? - Comparable data could be plotted without issues with Python counterparts.

I have also observed that plotting large scatter plots slows my browser down.

One option to fix this is to allow the chart to be saved into an image, and then display that image as the output in the notebook. This is what IfSharp's implementation of XPlot does:

https://github.com/fsprojects/IfSharp/blob/634b95e472cf21c4cc30fde52e68c62f2f723f2f/src/IfSharpNetCore/XPlot.Plotly.fsx#L30-L84

It uses Plotly.JS's toImage function: https://plot.ly/javascript/plotlyjs-function-reference/#plotlytoimage

I have also seen python notebooks doing this same thing. For example, see the Setup cell in https://github.com/ageron/handson-ml2/blob/master/02_end_to_end_machine_learning_project.ipynb.

Obviously, once you do this the chart is no longer interactive. But it is better to be able to display the chart non-interactively than not being able to display it at all.

@jonsequitur @colombod - perhaps this is an option we could add to our plotly + Juypter extension? Potentially we could add this capability into XPlot itself?

@colombod let me in on the secret: WebGL.

See https://plot.ly/python/webgl-vs-svg/

Implement WebGL for increased speed, improved interactivity, and the ability to plot even more data!

In XPlot, certain charts have a gl suffix overload that will use WebGL instead of SVG.

I have updated the example notebook in dotnet/try to use Scattergl and the performance is now much better - https://github.com/dotnet/try/pull/496.

Thanks for looking in to this @eerhardt!

No problem. I hope this helps unblock you.

Feel free to open issues like this directly in the XPlot repo (https://github.com/fslaborg/XPlot). Or if it is an issue with the C#/F# Jupyter kernel - .NET Try repo (https://github.com/dotnet/try).

ML.NET can't really do anything for issues like this.

Closing as this question was answered.

Was this page helpful?
0 / 5 - 0 ratings