cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Stokes
Level IV

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

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

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

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.

View solution in original post

6 REPLIES 6

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

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.

Stokes
Level IV

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

Thanks for the reply.

Can you help to modify based on the jsl above?

Not clear how to do it...

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

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.

Stokes
Level IV

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

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.

 

vince_faller
Super User (Alumni)

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

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
vince_faller
Super User (Alumni)

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

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