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
Marco1
Level IV

Can JMP show the probability of 1 result or range through a graph?

Hello everyone!!!, a question:
What graph in JMP can answer the probabilities of obtaining a value or range of response, for example like the following graph.

Marco1_0-1699317866245.png

Greetings,

Marco

 

57 REPLIES 57
hogi
Level XII

Re: Can JMP show the probability of 1 result or range through a graph?

Then what you need is just a Local Data Filter - and a Filter Change Handler that updates the results in the probabilities panel.
The advantage: With the Data Filter it doesn't matter how many questions you will ask - just add as many selections as you want and the corresponding probabilities will show up automatically:

 

hogi_1-1699775586720.png

 

 

 

View more...
/*""" https://community.jmp.com/t5/Discussions/Can-JMP-show-the-probability-of-1-result-or-range-through-a/m-p/697164/highlight/true#M88257

Author: hogi
Date: 2023-11-12

NB: back again at simple Data Filter

*/

Names Default To Here( 1 );

convertToList = Function( {myExpr},
	myHead = Head( Name Expr( myExpr ) );
	Substitute( Name Expr( myExpr ), Name Expr( myHead ), Expr( List() ) );
);

findArgs = Function( {myList, myHead},
	{NArgs, myArg},
	matches = {};
	NArgs = N Arg( myList );
	For Each( {i}, 1 :: NArgs,
		myArg = Arg( Name Expr( myList ), i );
		If( Head( Name Expr( myArg ) ) == Name Expr( myHead ),
			Insert Into( matches, convertToList( Name Expr( myArg ) ) )
		);
	);
	matches;
);


all Cols = Current Data Table() << get column references();
New Window( "probabilites",
	H List Box( Current Data Table() << data filter( Local,Title("Selection"), 	Show Controls( 0 ),
	Show Modes( 0 ),
	Show Counts( 0 ), Conditional( 0 ), columns( Name Expr( all Cols ) ) ), hlb = H List Box() )
);

ldf = ((Current Report()["Selection"]) << get scriptable object);


update = Function( {a},
	{ldflist,filterExpr,myCols,myFilters,lookupTable,myValue},
	ldf = ((Current Report()["Selection"]) << get scriptable object);
	ldflist = Convert To list( ldf << get script );
	filterExpr = findArgs( ldflist, Expr( AddFilter() ) );
	myCols = Transform Each({x},findArgs( Name Expr( filterExpr ), Expr( columns() )),x << get name) ;
	myFilters = findArgs( Name Expr( filterExpr ), Expr( Where() ) );

	lookupTable = Associative Array( Transform Each( {x, i}, myFilters, Eval List( {If(Head(x)==Expr(And()),Arg( Arg(x,1), 1 )<< get name,  Arg(x,1)<< get name) , i} ) ) );
	

	myBox = Outline Box( "probabilities" );
	For Each( {x}, myCols, 
		Try( myPos = Eval(substitute(Expr(lookupTable[_x_]),Expr(_x_),Name Expr(x)));
		Eval(
			Substitute(
					Expr(
						sel_rows = Current Data Table() << get rows where( _match_ );
						myValue = Char( Round( N Items(sel_rows)  / N rows(current data table()) * 100, 2 ) ) || "%";
		
					),
				Expr( _match_ ), Name Expr( myFilters[myPos] ),
			)
		),
		myValue = "100%");

		Insert Into( myBox, Panel Box( x, Text Box( myValue ) ) );
	);

	Try(result << delete);
		hlb << append( result = myBox );
);


rs = ldf << make filter change handler( update );
(Current Report() << xpath("//FrameBox")) << Frame Size( 500, 50 );

 

 

hogi
Level XII

Re: Can JMP show the probability of 1 result or range through a graph?

Here is an alternative implementation which also allows "combined" filter conditions (A and B and C ...).

For this case it makes sense to enable the Conditional(1) setting - then additional filters will only show values that are within the range of the first filters.

 

In addition, one can create several filter "groups". Click on OR and a filter group N+1 is generated with the corresponding probability value. 

drawbacks:

  • with the current version of Jmp, Conditional(1) and filter groups via OR are not compatible
    So, if you want to compare different selection groups, you have to do this without the Conditional(1) feature.
    here is a wish to fix this problem: data filters: more flexible use of the conditional flag 
  • The possibilities to adjust the graph are more restricted than in GraphBuilder:
    - selected values are indicated via the semitransparent blue region, which looks nice.
    On the other hand, it's not possible to switch "different colors for selected/unselected" 
    - the default number of bins in a data filter is 10, just giving a rough idea of the actual distribution.
    Number of Bins  can be adjusted via the red triangle menu:
    hogi_1-1699857190223.png

     

 

View more...
/*""" https://community.jmp.com/t5/Discussions/Can-JMP-show-the-probability-of-1-result-or-range-through-a/m-p/697074/highlight/true#M88231

Topic: direct access to data filter selections via ldf << get where clause
Author: hogi
Date: 2023-11-12
*/

Names Default To Here( 1 );

convertToList = Function( {myExpr},{Nargs,myList},
	Nargs= N Arg(Name Expr(myExpr));
	myList={};
	For(i=1, i<=NArgs, i++,
	Insert Into(myList,Arg(Name Expr(myExpr),i))
	);
	return(Name Expr(myList))
);



New Window( "probabilites",
H list Box (
Current Data Table() << 
		data filter(
			Local,
			Title( "Selection" ),
			Show Controls( 1 ),
			Show Modes( 0 ),
			Conditional( 1 ),
			add Filter (columns(Column(1),Column(2)),Display( Column(1), NBins( 100 ) ),Display( Column(2), NBins( 100 ) ))
	),
	H List Box( Name Expr( myExpr ), hlb = H List Box() ));
);


update = Function( {a}, {myExpr,myselection},
// collect Selections from Local Data Filter - every OR is a group - kind of ...

	ldf = Current Report()["Selection"] << get scriptable Object;
	myExpr = Parse( ldf << get where clause );
	myExpr=Arg( myExpr, 1 );
	mySelections = If( (Head( myExpr ) == Expr( Or() ) & Head( Arg(myExpr,1) ) != Expr( Equal() )),
		convertToList(Name Expr(myExpr)  ), // several filter groups
		Eval List({Name Expr(myExpr)}) // one filter group
		
	);

// calculate the new values
	myBox = Outline Box( "probabilities" );
	For Each( {x, i}, mySelections,
		Eval(
			Substitute(
					Expr(
						sel_rows = Current Data Table() << get rows where( _match_ );
						myValue = Char( Round( N Items( sel_rows ) / N Rows( Current Data Table() ) * 100, 2 ) ) || "%";
					),
				Expr( _match_ ), Name Expr( x )
			)
		);
		Insert Into( myBox, Panel Box( "selection group # " || Char( i ), Text Box( myValue ) ) );
	);
// update the results
	Try( result << delete );
	hlb << append( result = myBox );
);

ldf = ((Current Report()["Selection"]) << get scriptable object);
rs = ldf << make filter change handler( update );
(Current Report() << xpath( "//FrameBox" )) << Frame Size( 500, 50 ) << Fill Selection Mode( "Selected Same Color" );

 

Marco1
Level IV

Re: Can JMP show the probability of 1 result or range through a graph?

Hello Hogi,

This alternative (combination of certainty) exceeded what I was looking for, thank you for sharing your neural agility materialized in this alternative "combination of certainty", a consultation...will the calculation of certainty be OK?

Greetings,

Marco

hogi
Level XII

Re: Can JMP show the probability of 1 result or range through a graph?

 

 

if certainty ~ probabilty,  the calculated values should be OK *)
community feedback appreciated

The probabilities are calculated with the formula - line 55:

N Items( sel_rows ) / N Rows( Current Data Table() ) * 100

*) one restriction:

excluded rows are not handled separately. So, if you have such rows, delete them. Or adjust the equation.

https://community.jmp.com/t5/JMP-Wish-List/Formula-Editor-meaningful-results-with-excluded-rows/idi-... 

 

Marco1
Level IV

Re: Can JMP show the probability of 1 result or range through a graph?

Hello Hogi,

A question, will it be possible for profiler to find all the best combinations of factors with uncertainty when performing the simulation that maximize the total utility and minimize the total cost? For example:

 

Marco1_0-1700400363449.png

Marco1_1-1700401510514.png

 

hogi
Level XII

Re: Can JMP show the probability of 1 result or range through a graph?


@jthi wrote:

with (global) data filter 


Right, I reset it in the script. 
I don't like to use global data filters in reports - but here it's necessary to get the selected() to work.

 

Note to self:

changes to scripts need to be tested before updating.

really strange where direct replies show up

dale_lehman
Level VII

Re: Can JMP show the probability of 1 result or range through a graph?

Very nice.  But I think there is one error and one thing missing.  The error I believe is in the Graph Builder section of your script where you list the Variables - I think the :one should be :percent.  Then what I am missing is how to get the top display to show the percent in the black rectangle.  My attempt shows the percent on the Y axis but doesn't display the number across the top like yours does.

Marco1
Level IV

Re: Can JMP show the probability of 1 result or range through a graph?

Hi Jeff,

It's a pleasure to greet you, of course it would be great if the simulation in JMP could show the certainty of obtaining a value or range, thank you for your response!

Greetings,

Marco