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
jumper
Level I

How to save a prediction formula column with a specific name via JSL?

Dear all,

 

I am running some generalised linear model via a JSL script.

How can I save the prediction formula to a column with a specific name?

 

All I managed to find (Automate saving of prediction formula using JMP script?) was something like:

GLM = Fit Model (......);

GLM << prediction formula;

 

However:

 

1) can I choose the name of the column which will store the prediction formula? JMP will automatically save it to: "Pred Formula 'Target Variable'"

2) Is this functionality documented anywhere? I found it on the forum above, but not in JMP's documentation

3) Does the same syntax work for other platforms (e.g. partition)?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
sseligman
Staff

Re: JSL scripting: how to save prediction formulae?

Ian's reply answers concerns #1 and #3, while user ms answers question #2 about documentation surrounding the JMP Scripting Language (JSL).

 

@ian_jmp:

 

Generally 'Save Prediction Formula' is consistent across platforms. The name(s) of the saved columns are indeed fixed, but you can rename them using things like: 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
cols = dt << GetColumnNames("String");
For(c=1, c<=NItems(cols), c++,
  Column(dt, cols[c]) << SetName("New "||cols[c]);
);

On rare occasions it can be helpful to use 'Get Column Names' before and after the columns are created, comparing the two lists to infer the names of the new columns.

 

@ms:

 

Regarding documentation for JSL, I think that the Scripting Index (Help menu) is a great resource, packed with ready-to-use examples. And yes, << Prediction Formula is there.

 

View solution in original post

6 REPLIES 6
ian_jmp
Level X

Re: JSL scripting: how to save prediction formulae?

Generally 'Save Prediction Formula' is consistent across platforms. The name(s) of the saved columns are indeed fixed, but you can rename them using things like: 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
cols = dt << GetColumnNames("String");
For(c=1, c<=NItems(cols), c++,
  Column(dt, cols[c]) << SetName("New "||cols[c]);
);

On rare occasions it can be helpful to use 'Get Column Names' before and after the columns are created, comparing the two lists to infer the names of the new columns.

 

jumper
Level I

Re: JSL scripting: how to save prediction formulae?

Mmm, it sounds very convoluted. What I have found is that if my target variable is called "My Target", the column will be called "Pred Formula My Target", so I use:


GLM = Fit Model (......);


GLM << prediction formula;


Column("Pred Formula My Target") << Set Name("New Column Name");


How about documentation? Is this properly documented anywhere in the JSL documentation? I haven't managed to find it. I am new to JMP scripting, but first impressions are that it is a powerful language with a convoluted syntax and poor documentation, a bit like R in a way - but I would expect better documentation from a commercial software!

Finally, I create another column which multiplies the prediction by something else:


New Column("My new calculation", Numeric, Formula( :"My saved Prediction" * :another_field ));


where "My saved prediction" has spaces in the name, another_field does not. The formula is calculated correctly, but if I right click on the heading and go to formula, I see an empty box multiplied by another_field. Is this a bug in JMP? Should I have specified the formula differently?

Thank you.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL scripting: how to save prediction formulae?

The empty box may indicate that the column :My saved Prediction (should not be within double quotes) does not exist in the current data table. Check spelling.

Regarding documentation for JSL, I think that the Scripting Index (Help menu) is a great resource, packed with ready-to-use examples. And yes, << Prediction Formula is there.

jumper
Level I

Re: JSL scripting: how to save prediction formulae?

I removed the double quotes from :My Saved prediction and now it all works fine.

Thank you for pointing me to the Scripting Index - very useful!

sseligman
Staff

Re: JSL scripting: how to save prediction formulae?

Ian's reply answers concerns #1 and #3, while user ms answers question #2 about documentation surrounding the JMP Scripting Language (JSL).

 

@ian_jmp:

 

Generally 'Save Prediction Formula' is consistent across platforms. The name(s) of the saved columns are indeed fixed, but you can rename them using things like: 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
cols = dt << GetColumnNames("String");
For(c=1, c<=NItems(cols), c++,
  Column(dt, cols[c]) << SetName("New "||cols[c]);
);

On rare occasions it can be helpful to use 'Get Column Names' before and after the columns are created, comparing the two lists to infer the names of the new columns.

 

@ms:

 

Regarding documentation for JSL, I think that the Scripting Index (Help menu) is a great resource, packed with ready-to-use examples. And yes, << Prediction Formula is there.

 

Re: How to save a prediction formula column with a specific name via JSL?

Continuing your example:

GLM = Fit Model (......);
pf = GLM << prediction formula;
pf << Set Name( "my name" );

Yes, this approach should work with any of the modeling platforms.