Jump to content

How to get R2 of regression (r2) via Iron Python?


Dmitrii Nagaev

Recommended Posts

Posted (edited)

I also found: https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/tib_sfire-analyst_api/html/M_Spotfire_Dxp_Application_Visuals_FittingModels_FittingModel_GetCurve.htm

fitting_model.GetCurve('r2')

But i got error and can't solve it 😅:

Traceback (most recent call last):
  File "<string>", line 398, in <module>
  File "<string>", line 320, in run
  File "<string>", line 198, in set_chart_settings
TypeError: cannot access protected member GetCurve without a python subclass of FittingModel

IronPython.Runtime.Exceptions.TypeErrorException: cannot access protected member GetCurve without a python subclass of FittingModel

Edited by Dmitrii Nagaev
Link to comment
Share on other sites

Hi Dmitrii,

Thank you for the dxp file. One of my colleagues created an iron python script, that solves the enigma of capturing the R2 value. In the attached file, you'll see a second iron python script and the R2 value being displayed in the text area.

The solution itself, uses a second data table to store the data from the R2 in, so that it can be pushed to a document property. On such a short notice, this is the best option we can think of for now. But at the same time, we're also looking into making it more user friendly.

We will update you if we have found a better way.

Kind regards,

David

demo-regression-scatter-plot.dxp

Link to comment
Share on other sites

Hi Dmitrii,

There is no data function in this approach. This second table is created as part of the iron python script. That is why you will see the fx symbol in the data source box.

The r2 column holds the output of the r2 value from the line regression, which is better 'readable' in the Fit Results data table. And that should correspond with the r2 value in your scatterplot.

Kind regards,

David

Link to comment
Share on other sites

Hi Dmitrii,

That would have been me :-). But I can't see the mix up of the two scripts when I open  the dashboard. So that is weird...

I have adapted the dashboard (v2) in such a way that only the new script is available. It should be fine now.

I also would like to inform you, that there is a way to keep the whole process in one script. We have not yet build it, but as soon as it has been fixed, we will update you.

Kind regards,

David

demo-regression-scatter-plot v2.dxp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...