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 );

Help created on 7/12/2018