How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Missing formula with data with missing value trained by Partition model, how to convert JSL into a form that can be used in JMP formula.
ab>=-14&P1>=174.1&EVk<34341 or Missing&xyz<214.98 or Missing&EVk<154 or Missing&P1>=1741
into
:ab >= -14 & :P1 >= 1741 & (:EVk < 154 | Is Missing( :EVk )) & (:xyz < 214.98 | Is Missing( :xyz ))
Thanks!
ScriptingRe: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Here "AB", "P1" and "EVk" are Partition multiple times.How do can keep only valid parameters?
And how do automatically turn
"EVk<154 or Missing"
into
":EVk<154 | is Missing(:EVk)"?
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?So if you save the fitted partition model, it IS a column formula.
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Just save the prediction formula as a column formula after selecting the partition model.
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Thank markbailey!
But I have tried to copy the leaf label formula and calculate it as a normal formula, which is wrong.
For example:
dt<<NEW column="">=-14&:P1>=1741&:xyz<214.98 or Missing&:EVk<154 or Missing));dt<<RUN formulas=""></RUN></NEW>
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Yes, that code is wrong. That code is not what is saved as a formula for the leaf labels. You incorrectly copied what you want from the formula and pasted the wrong code into your script.
Here is an example that copied the saved formula for the leaf labels verbatim and pasted it as the argument to the Formula() argument for the new column:
Names Default To Here( 1 );
// open an example
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// create a new column for character data and populate it with formula based on a
// previously saved formula for leaf labels.
dt << New Column( "Text",
Character,
Formula(
If( !Is Missing( :height ) & :height >= 63,
If( !Is Missing( :height ) & :height >= 67,
"height>=63&height>=67",
"height>=63&height<67"
),
"height<63"
)
)
);Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?yes.I also know that can use the "prediction formula" directly.But this prediction formula is so global, so large, and so complex that it is inconvenient to use it in other files.
The "leaf label formula" is accurate, but the leaf label formula produced automatically by the "Partition" model cannot be used directly.
So I transferred these leaf label formulas to Excel using VBA to automatically convert them into a form that can be used in JMP formulas.
But this operation will use the whole process of operation can not be fully automated.
Thank markbailey!
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?So I want to know how to use JSL to convert these leaf label formulas into the usable form of JMP formula() formu.Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?I think we're confused because the Leaf Label Formula column already has a formula behind it. You don't need to convert anything. Can you explain more clearly exactly the steps you want to do?

Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Of course, the text of the leaf label formula column cannot be calculated directly in this way.

Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Thank Jeff!
Since I got these leaf label formulas that were not used in the original file.
So I simply removed the formula from the leaf label formula column, got only the text, and lumped the text of the different leaf label formulas into a file.
These textual leaf label formulas are then used to calculate other data using JSL.So I have this problem of conversion.
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Are you saying that someone already did an analysis and can no longer reproduce the original model, and now you are trying re-create the formula from data that was exported to excel? If at all possible it would be much easier to build the same model again in JMP and then export the formula column directly. Going forward, for any new models created I would always export that leaf column so you don't have to deal with this again. If you really need to recreate the formula and you cannot just 'brute force' type it out while referring to your excel file (I am guessing that would be fastest for someone unfamiliar with scripting unless you have 100s of terms), then you could use the substitute (simple) or regex (complex) formulas to turn your raw text into a formula. That sounds like a pain and I think everyone is saying to avoid it if you can.
OR, are you trying to create a set of columns for each possible leaf with true/false values indicating whether that row in each leaf? In this case I would still save the leaf formula and then create new columns with a formula checking if the leaf label matches a text string.
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?
Yes, I still haven't found these leaf label formulas which are obtained by using JSL to automatically divide different files into one file and save them in the form of formulas.If delete the X factor, It delete the formula.
Thanks!
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Now I am confused. Can you tell us what you are trying to achieve, including what columns you expect in your resulting tables(s), and the steps you think would take to get there?
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Press the following JSL to get a non-repeating leaf label formula file T1.
How to extract the specific contents of each leaf label formula of T1 line by line into the formula "Formula1" of T1 file?
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt[30 :: 35, "height"] = "";
p = Partition( Y( :weight ), X( :age, :sex, :height ), Validation Portion( 0.3 ), Informative Missing( 1 ), split Best( 2 ) );
p << save leaf label formula;
p << Close Window;
Wait( 0 );
dt << Sort( By( 6 ), Order( Descending ), replacetable( 1 ) );
dt << Select Where( :Leaf Label Formula != Lag( :Leaf Label Formula, -1 ) );
d3 = dt << Subset( Output Table( "T1" ), Selected Rows( 1 ), selected columns( 0 ) );
Wait( 0 );

Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Just take the text of the "Leaf Label Formula" column in the "T1" table and get the corresponding Formula form.
don't need a global formula.
Thanks!
Re: How to use JSL to convert the Decision Tree Partition Leaf Label Formula into a form that can be used in JMP formula?Could one of these options work? I think they accomplish what you are looking for:
//For each row (leaf of partition) create a new formula column
//indicating whether that row is in that leaf
for(r=1, r<= n row(d3), r++,
Eval(Eval Expr(
d3 << New Column("Is Leaf " || d3:Leaf Label Formula[r], Numeric, "Continuous", Format("Best", 12), Formula(:Leaf Label Formula == Expr(d3:Leaf Label Formula[r])));
));
);
//Or if you want it all in one column (slower if multiple columns):
for(r=1, r<= n row(d3), r++,
Eval(Eval Expr(
d3 << New Column("Alt Is Leaf " || d3:Leaf Label Formula[r], Numeric, "Continuous", Format("Best", 12), Formula(Expr(dt:Leaf Label Formula << Get Formula) == Expr(d3:Leaf Label Formula[r])));
));
);