cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
shampton82
Level VII

Setting desirability in a neural net loop

Hello everyone,

I have a script where I loop through different Neural net settings and as part of the looping I'd like to set the profile to maximize the desirability for a min goal and save the settings then do the same for a max goal as well.  I haven't been able to get this work work though.  Here is the script I am working with and I've been testing on the diabetes sample data set:

names default to here(1);

dt=current datatable();


selCols = dt << Get column names( String );



obj2=new window("Reponse Variable",
			<<Modal,
			<<Return Result,
			LineupBox( NCol( 1 ), Spacing( 5 ),
				v list box(textbox("select response"),choseny = ColListBox( dt, all, <<Set Data Type( "Numeric" ) ,grouped ),
				 v list box(textbox("select validation"),chosenv = ColListBox( dt, all, <<Set Data Type( "Numeric" ) ,grouped ))
				)	
				),
			v list box(textbox("select predictors"),chosenx = ColListBox(dt,<<append(eval(selcols)),grouped ),),
			H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
);

If( obj2["button"] == -1,
Throw();
);

y=eval(obj2[1]);
v=eval(obj2[2]);
x=eval(obj2[3]);

objy=eval(y)[1];




obj1=New Window( char(dt),V List Box(
	for(i=1, i <= 1, i++,
			if(i==1,
				t1=0;
				t2=0;
				l1=3;
				l2=3;
				b=0;,				
			i==2,	
				t1=0;
				t2=0;
				l1=10;
				l2=0;
				b=50;,
			i==3,
				t1=2;
				t2=1;
				l1=2;
				l2=3;
				b=0;,
			i==4,
				t1=1;
				t2=1;
				l1=4;
				l2=6;
				b=0;,
			i==5,
				t1=1;
				t2=0;
				l1=2;
				l2=3;
				b=0;,
			i==6,
				t1=10;
				t2=0;
				l1=0;
				l2=0;
				b=50;,
			i==7,
				t1=10;
				t2=0;
				l1=10;
				l2=0;
				b=50;
				
			);
			fit=Neural(
				Y( eval(y)),
				X(eval(x)),
				Validation( as column(dt, v[1]) ),
				Informative Missing( 0 ),
				Fit(
					NTanH( t1 ),
					NTanH2( t2 ),
					NLinear( l1 ),
					NLinear2( l2 ),
					Transform Covariates( 1 ),
					Robust Fit( 1 ),
					Number of Tours( 1 ),
					N Boost( B ),
					Learning Rate( 0.5 ),
					pf=Profiler(
						1,
						Confidence Intervals( 1 ),
						Desirability Functions( 1 ),
						Independent Uniform Inputs( 1 ),
					),
					Plot Actual by Predicted( 0 ),
					Plot Residual by Predicted( 0 ),
				)
			);
			
			//set profiler to maximize here then
			//pf << Maximize Desirability;
			//pf<<Remember Settings ;
			
			//set profiler to minimzie here then
			//pf << Maximize Desirability;
			//pf<<Remember Settings ;
			
			
			//this is what i tried but is not working
			column(dt, y) << Set Property( "Response Limits", {Goal( Minimize ), Importance( 1 ), Show Limits( 0 )});
			pf = report(fit)["Prediction Profiler"] << get scriptable object;
			pf << Maximize Desirability;
			pf<<Remember Settings ;
			
			column(dt, y) << Set Property( "Response Limits", {Goal( Maximize ), Importance( 1 ), Show Limits( 0 )});
			pf = report(fit)["Prediction Profiler"] << get scriptable object;
			pf << Maximize Desirability;
			pf<<Remember Settings ;
			

		)
	
	)
	
);

The script will produce two separate saved settings but it is at the same state.

 

Thanks for any ideas!

 

Steve

1 ACCEPTED SOLUTION

Accepted Solutions
shampton82
Level VII

Re: Setting desirability in a neural net loop

I reached out to JMP support for help and this is what they came up with which works great:

 

"There were a few things going on… the response limits message must point to the column name and must be in a list that itself is a message to the Profiler.  Also, it appears you have to reshow the report to get the desirability functions to actually update."

pf = Report( fit )["Prediction Profiler"] << get scriptable object;
 
Eval( Eval Expr( pf << {Expr( Column( dt, y )) << Response Limits( {Goal( "Minimize" ), Importance( 1 )} )} ) );
Report( fit ) << reshow();
  
pf << Maximize Desirability;
pf << Remember Settings("Min");
                          
Eval( Eval Expr( pf << {Expr( Column( dt, y )) << Response Limits( {Goal( "Maximize" ), Importance( 1 )} )} ) );
Report( fit ) << reshow();
 
pf << Maximize Desirability;
pf << Remember Settings("Max");

View solution in original post

2 REPLIES 2
SDF1
Super User

Re: Setting desirability in a neural net loop

Hi @shampton82 ,

 

  Nice bit of code, and I like the idea of what you're intending to do with it.

 

  After trying out the code with the Diabetes data table, here's some feedback to help get you in the right direction, hopefully.

 

1. delete the pf= in the call for the NN platform. You can then define the pf = report(fit) later on as you want to maximize desirability.

2. if you send the command Set Desirabilities to pf, then a window comes up where you can manually enter maximize or minimize, but I don't see yet how to set it automatically with JSL.

 

  The below code works, but you have to manually edit the window. I'd like to know how to do it through JSL, though.

names default to here(1);

dt=current datatable();


selCols = dt << Get column names( String );



obj2=new window("Reponse Variable",
			<<Modal,
			<<Return Result,
			LineupBox( NCol( 1 ), Spacing( 5 ),
				v list box(textbox("select response"),choseny = ColListBox( dt, all, <<Set Data Type( "Numeric" ) ,grouped ),
				 v list box(textbox("select validation"),chosenv = ColListBox( dt, all, <<Set Data Type( "Numeric" ) ,grouped ))
				)	
				),
			v list box(textbox("select predictors"),chosenx = ColListBox(dt,<<append(eval(selcols)),grouped ),),
			H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
);

If( obj2["button"] == -1,
Throw();
);

y=eval(obj2[1]);
v=eval(obj2[2]);
x=eval(obj2[3]);

objy=eval(y)[1];




obj1=New Window( char(dt),V List Box(
	for(i=1, i <= 1, i++,
			if(i==1,
				t1=0;
				t2=0;
				l1=3;
				l2=3;
				b=0;,				
			i==2,	
				t1=0;
				t2=0;
				l1=10;
				l2=0;
				b=50;,
			i==3,
				t1=2;
				t2=1;
				l1=2;
				l2=3;
				b=0;,
			i==4,
				t1=1;
				t2=1;
				l1=4;
				l2=6;
				b=0;,
			i==5,
				t1=1;
				t2=0;
				l1=2;
				l2=3;
				b=0;,
			i==6,
				t1=10;
				t2=0;
				l1=0;
				l2=0;
				b=50;,
			i==7,
				t1=10;
				t2=0;
				l1=10;
				l2=0;
				b=50;
				
			);
			
			fit=Neural(
				Y( eval(y)),
				X(eval(x)),
				Validation( as column(dt, v[1]) ),
				Informative Missing( 0 ),
				Fit(
					NTanH( t1 ),
					NTanH2( t2 ),
					NLinear( l1 ),
					NLinear2( l2 ),
					Transform Covariates( 1 ),
					Robust Fit( 1 ),
					Number of Tours( 1 ),
					N Boost( B ),
					Learning Rate( 0.5 ),
					Profiler(
						1,
						Confidence Intervals( 1 ),
						Desirability Functions( 1 ),
						Independent Uniform Inputs( 1 ),
					),
					Plot Actual by Predicted( 0 ),
					Plot Residual by Predicted( 0 ),
				)
			);
			
			//set profiler to maximize here then
			//pf << Maximize Desirability;
			//pf<<Remember Settings ;
			
			//set profiler to minimzie here then
			//pf << Maximize Desirability;
			//pf<<Remember Settings ;
			
			
			//this is what i tried but is not working
			//column(dt, y) << Set Property( "Response Limits", {Goal( Minimize ), Importance( 1 ), Show Limits( 0 )});
			pf = report(fit)["Prediction Profiler"] << get scriptable object;
			pf << Set Desirabilities;
			pf << Maximize Desirability;
			pf<<Remember Settings ;
			
			
			//column(dt, y) << Set Property( "Response Limits", {Goal( Maximize ), Importance( 1 ), Show Limits( 0 )});
			pf = report(fit)["Prediction Profiler"] << get scriptable object;
			pf << Set Desirabilities;
			pf << Maximize Desirability;
			pf<<Remember Settings ;
			

		)
	
	)
	
);

Hope this at least gets you going in the right direction!,

DS

shampton82
Level VII

Re: Setting desirability in a neural net loop

I reached out to JMP support for help and this is what they came up with which works great:

 

"There were a few things going on… the response limits message must point to the column name and must be in a list that itself is a message to the Profiler.  Also, it appears you have to reshow the report to get the desirability functions to actually update."

pf = Report( fit )["Prediction Profiler"] << get scriptable object;
 
Eval( Eval Expr( pf << {Expr( Column( dt, y )) << Response Limits( {Goal( "Minimize" ), Importance( 1 )} )} ) );
Report( fit ) << reshow();
  
pf << Maximize Desirability;
pf << Remember Settings("Min");
                          
Eval( Eval Expr( pf << {Expr( Column( dt, y )) << Response Limits( {Goal( "Maximize" ), Importance( 1 )} )} ) );
Report( fit ) << reshow();
 
pf << Maximize Desirability;
pf << Remember Settings("Max");