For the latest version of JMP Help, visit JMP.com/help.

Publication date: 09/28/2021

Formula Depot

Sending commands via JSL to a Formula Depot platform report requires that you first create an empty Formula Depot. Once you have a reference to the Formula Depot report, you can send commands to it. The following script opens a formula depot report and adds a model to the depot.

dt = Open( "$SAMPLE_DATA/Liver Cancer.jmp" );
fd = Formula Depot(); // open a new Formula Depot
obj1 = dt << Run Script( "Lasso Poisson, Validation Column" );
model = obj1 << (Fit[1] << Publish Prediction Formula );
 

/* Publish a model to the Formula Depot. The

following script opens a formula depot report, adds a model to

the depot, generates scoring code for the formula, saves the code to a file,

and closes all windows.*/

case_name = "fitLS_prediction";
dest_dir = "c:\"; //CHANGE ME to a better location
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Print( "Running " || case_name );
fm_ls = Fit Model(
	Y( :weight ),
	Effects( :age, :sex, :height ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Minimal Report" ),
	Run
);
fd = fm_ls << Publish Prediction Formula;
Try(
	Print( "Generate Python Code" );
	code = fd << Generate Python Code( No Editor );
	Save Text File( dest_dir || case_name || ".py", code );
	Print( "Done." );
,
	Print( "Code generation failed for " || case_name || ", reason: " );
	Show( exception_msg );
);
fdw = Window( "Report: Formula Depot" );
fdw << Close Window( No Save );
Close( dt, No Save );
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).