Overview of available functions

Hi

I am trying out the newly added library Apache Math.
However, I am struggling a bit with getting an overview of what functions really exists.

I have found the documentation of Apache Math here:
http://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html

I have tried to import the machine learning module but I am getting an error that “No module named ml”. So apparently it does not exist?

Does a documentation exist for ignition that outlines what functions are actually available?

You have to import the specific classes you will use, not entire packages. Jython can’t do that with Java libraries. Nor can it use a wildcard import with them. You’ll probably also have to import many of the interfaces for data types you wish to use, so you can define python classes that implement them.

Okay, but isn’t this what Kathy Applebaun is doing here?:

The image is taken from here: Ignition v7.9.8: Better Algorithm Access, Quicker Named Queries & More | Inductive Automation

Hmm. Yes. I’m surprised that works.

But that is the thing. It’s not:

try it with this instead:

from org.apache.commons.math3.fitting import WeightObservedPoints, PolynomialCurveFitter

That did the trick!

So wildcards ain’t working. You were right. Thanks

1 Like

Just out of interest, I got this working but had to change a few things:

  • WeightedObservedPoint class name is without the ‘s’ at the end
  • WeightedObservedPoint has no empty constructor and contains a single pair of values, not a list of pairs
from org.apache.commons.math3.fitting import *

obs = []
x = [1552920192.0, 1552938624.0, 1552961664.0]
y = [12.85043621, 12.4644804, 11.92448521]

for i in [0,1,2]:
	obs.append(WeightedObservedPoint(1.0, x[i], y[i])) # WeightedObservedPoint not WeightedObservedPoint**s**

fitter = PolynomialCurveFitter.create(4)
coeff = fitter.fit(obs)
print coeff
2 Likes