Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- How to save a prediction formula column with a specific name via JSL?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 9, 2014 4:14 AM
(7182 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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.

6 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

Learn it once, use it forever!