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);
case_name = "fitLS_prediction";
dest_dir = "c:\";
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" );
fd << Generate Python Code();
Wait( 1 );
cw = Window( "Python Code Output" );
ed = cw[Script Box( 1 )];
code = ed << Get Text;
Save Text File( dest_dir || case_name || ".py", code );
cw << Close Window( No Save );
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 );