Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Improve JSL efficiency: How to close the plot window after each run, to make the...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Feb 18, 2020 1:08 PM
| Last Modified: Feb 19, 2020 4:32 AM
(1507 views)

I am currently have a big table to run a polynomial fit.

1. The goal: generate polynomial fit parameters and export it as a table.

2. The problem: using below JSL, it takes too long time to run the whole table. so I can only subset the table into small groups to run to avoid PC crush.

3. The reason: Below table need to fit the polynominal curve first, then generate the summary table, finally export all classes into 1 table.

Assuming there are 100k classes, it will take a long time to fit the polynominal curve, then export to table.

4. Help needed: Can someone help me to modify the JSL? Make it to fit for each class with polynomial curve, then export to table, then close the polynominal curve window. This will save the DDR SDRAM to keep running all 100k classes adding up only exporting a table of 100k classes, without generating a plots window of 100k.

Thanks for the help.

```
dt = Current Data Table();
biv = Bivariate( Y( :weight ), X( :age ), Fit Polynomial( 2, {Line Color( {47, 193, 29} )} ), By( :class ) );
rbiv = biv << report;
Summarize( groups = by( class ) ); // A list of all by-groups
n = N Items( groups );
//Create output table and fill with estimates
dtOut = New Table( "Polynominal parameters",
New Column( "class", Character ),
New Column( "T", numeric ),
New Column( "T2", numeric ),
addrows( n )
);
For( j = 1, j <= n, j++,
Estimates = rbiv[j]["Polynomial Fit Degree=2"]["Parameter Estimates"][1][3] << get as matrix;
:class[j] = groups[j];
:T[j] = Estimates[2];
:T2[j] = Estimates[3];
);
```

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Feb 19, 2020 2:42 AM
| Last Modified: Feb 19, 2020 2:46 AM
(1462 views)
| Posted in reply to message from Stokes 02-18-2020

Try this code to start with:

```
dt1 = Current Data Table();
// launch Bivariate with more than one By group, save list of analysis layer references
biv = dt1 << Bivariate( Y( :weight ), X( :age ), By( :sex ), Fit Polynomial( 2 ) );
// obtain first report layer reference and save
rbiv = biv[1] << Report;
// use first reference to send table box message
dt2 = rbiv["Parameter Estimates"][TableBox(1)] << Make Combined Data Table;
// process results as a data table
```

Then add code to modify the data table to suit your needs.

Learn it once, use it forever!

6 REPLIES 6

Highlighted
##
Re: Improve JSL efficiency: How to close the plot window after each run, to make the JSL run faster without crush PC.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

You do not need to iterate over every class. Send the << Make Combined Data Table to the Table Box in the first Parameter Estimates outline.

Learn it once, use it forever!

Highlighted
##
Re: Improve JSL efficiency: How to close the plot window after each run, to make the JSL run faster without crush PC.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Thanks for the reply.

Can you help to modify based on the jsl above?

Not clear how to do it...

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Feb 19, 2020 2:42 AM
| Last Modified: Feb 19, 2020 2:46 AM
(1463 views)
| Posted in reply to message from Stokes 02-18-2020

Try this code to start with:

```
dt1 = Current Data Table();
// launch Bivariate with more than one By group, save list of analysis layer references
biv = dt1 << Bivariate( Y( :weight ), X( :age ), By( :sex ), Fit Polynomial( 2 ) );
// obtain first report layer reference and save
rbiv = biv[1] << Report;
// use first reference to send table box message
dt2 = rbiv["Parameter Estimates"][TableBox(1)] << Make Combined Data Table;
// process results as a data table
```

Then add code to modify the data table to suit your needs.

Learn it once, use it forever!

Highlighted
##
Re: Improve JSL efficiency: How to close the plot window after each run, to make the JSL run faster without crush PC.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Thanks a lot, this is a better solution than my original one.

I add a For loop to subset the large table into small one and use your script to solve my problem.

Highlighted
##
Re: Improve JSL efficiency: How to close the plot window after each run, to make the JSL run faster without crush PC.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

A couple of other methods if you don't care about the actual plots. I sometimes see slow downs just to render a large amount of plots.

1. Calculate it without the platform.

```
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age));
dtOut = New Table( "Polynominal parameters",
New Column( "class", Character ),
New Column( "T", numeric ),
New Column( "T2", numeric ),
addrows(nitems(ages))
);
for(i=1, i<=nitems(ages), i++,
rows = dt << Get Rows Where(:age == Num(ages[i]));
y = dt:height[rows];
x = dt:weight[rows];
x2 = x||(x-ColMean(dt:weight))^2;
{b, vb} = Least Squares Solve(y, x2);
dtOut:class[i] = ages[i];
dtOut:T[i] = b[2];
dtOut:T2[i] = b[3];
);
```

2. instead of plotting a bunch of charts with a by variable you could plot one chart with a group by variable (I've had this help sometimes).

```
biv = dt << Bivariate(
Y( :height ),
X( :weight ),
Group By(:age),
Fit Polynomial( 2 ),
invisible
);
report(biv)["Parameter Estimates"][TableBox(1)] << Make Combined Data Table
```

And <<Invisible on platforms almost always helps.

Vince Faller - Predictum

Highlighted
##
Re: Improve JSL efficiency: How to close the plot window after each run, to make the JSL run faster without crush PC.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

And here's my attempt at Parallel Assign. I'm still learning how it works.

```
Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
summarize(dt, ages = By(:age));
::results = J(nitems(ages), 3, -1);
driver = ::results[0, 1];
age_rows = {};
for(i=1, i<=nitems(ages), i++,
insert into(age_rows, dt << Get Rows Where(:age == Num(ages[i])));
);
y = dt:height << Get Values();
x = dt:weight << Get Values();
m = mean(x);
Parallel Assign({a = ages, ar = age_rows, y = y, x = x, m = m},
driver[i] = (
rows = ar[i];
ys = y[rows];
xs = x[rows];
xs2 = xs||(xs-m)^2;
print(i, ys, xs2);
batch interactive(1);
Try({b, vb} = Least Squares Solve(ys, xs2));
batch interactive(0);
::results[i, 0] = b`
);
);
show(::results);
```

Vince Faller - Predictum

Article Labels

There are no labels assigned to this post.