On Jun 10, 2020, at 2:52 AM, Jenna <william108@gmail.com> wrote:

Hi. Is there a way to see the model that is generated in the form

Curve fitting?

Not sure how you would accomplish that with Weka. But with Apache commons math 3 maybe something like the below.
It converts Weka instances to double arrays and then uses commons math.
This was code I didn’t end up using and didn’t finish.
I instead did a data transform taking the natural log of both x and y and then doing a linear regression.
This assumes the relationship is a power law like…

Y = aX^b

And you can figure out ‘a’ and ‘b’ with linear regression of the logs..
I’ve been tinkering with that for a while and still am. Might post something to my site or GitHub if I finish.

I’m not that familiar with how to work the polynomial kernels in Weka. I would be interested if it provides an answer to your question.

Possibly of interest…

import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoints;
WeightedObservedPoints obs = new WeightedObservedPoints();

System.out.println(yName + "  by " + xName);
double[] xA = data.attributeToDoubleArray(data.attribute(xName).index());
double[] yA = data.attributeToDoubleArray(data.attribute(yName).index());
double[] lnXA = new double[xA.length];
double[] lnYA = new double[yA.length];
for (int i = 0; i < lnXA.length; i++) {
lnXA[i] = Math.log(xA[i]);
lnYA[i] = Math.log(yA[i]);
for (int i = 0; i < xA.length; i++) {
for (int degree = 1; degree < 4; degree++) {
PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
double[] coeff = fitter.fit(obs.toList());
System.out.println("Degree: " + degree + " SSE: " + sse(xA,yA,coeff));
for (int i = 0; i < coeff.length; i++) {
private static void sse(double[] xA, double[] yA, double[] coeff) {
double sum = 0;
int max = coeff.length;
for (i = 0; i < yA.length; i++) {