Seleccionar automáticamente valores atípicosTengo 7000 filas, que constan de varios lotes.Estoy haciendo una distribución por lotes y usando el diagrama de caja de valores atípicos para buscar valores atípicos.Pero tengo más de 100 lotes, ¿hay alguna manera de que JMP seleccione automáticamente qué filas son valores atípicos?
Re: Seleccionar automáticamente valores atípicos¿Esto es lo que necesitas?
Names Default To Here( 1 );
// make a sample data table
dt = New Table( "Data",
add rows( 10000 ),
New Column( "it", Numeric, Ordinal, Format( "Best", 8 ), Formula( Row() ) ),
New Column( "Batch", Numeric, Ordinal, Format( "Best", 8 ), formula( Random Integer( 110 ) ) ),
New Column( "y1", Numeric, Continues, Format( "Best", 8 ), formula( Random Lognormal( :Batch / 10, 5 ) ) ),
New Column( "y2", Numeric, Continues, Format( "Best", 8 ), formula( Random Lognormal( :Batch / 10, 5 ) ) ),
New Column( "Out",
Numeric,
Ordinal,
Format( "Best", 8 ),
Set Property( "Value Colors", {0 = -13977687, 1 = -4222943} ),
Color Cell by Value,
formula( 0 )
),
New Column( "Outy1",
Numeric,
Ordinal,
Format( "Best", 8 ),
Set Property( "Value Colors", {0 = -13977687, 1 = -4222943} ),
Color Cell by Value,
formula( 0 )
),
New Column( "Outy2",
Numeric,
Ordinal,
Format( "Best", 8 ),
Set Property( "Value Colors", {0 = -13977687, 1 = -4222943} ),
Color Cell by Value,
formula( 0 )
),
);
dt << run formulas;
Column( dt, "it" ) << delete formula;
Column( dt, "Batch" ) << delete formula;
Column( dt, "y1" ) << delete formula;
Column( dt, "y2" ) << delete formula;
Column( dt, "Out" ) << delete formula;
Column( dt, "Outy1" ) << delete formula;
Column( dt, "Outy2" ) << delete formula;
// now we get to work
// make a list of batches
byvarlist = Associative Array( dt:Batch ) << get keys;
// make a list of columns
cols = dt << get column names( Continuous ); //List all Numeric columns
// loop through the batches
For( i = 1, i <= N Items( byvarlist ), i++,
// select each batch
dt << select where( dt:Batch == byvarlist[i] );
// subset each batch
subdt = dt << Subset( Selected Rows( 1 ) );
// clear selection for smoth workflow
dt << clear select;
// finde outliers in each variable within each batch
For( ii = 1, ii <= N Items( cols ), ii++,
out = Eval(
Parse(
"subdt << get rows where(
subdt:" || Char( cols[ii] ) || " > Col Quantile( subdt:" || Char( cols[ii] ) ||
", 0.75 ) + 1.5 * (Col Quantile( subdt:" || Char( cols[ii] ) || ", 0.75 ) - Col Quantile( subdt:" || Char( cols[ii] ) ||
", 0.25 )) | subdt:" || Char( cols[ii] ) || " <
Col Quantile( subdt:" || Char( cols[ii] ) ||
", 0.25 ) - 1.5 * (Col Quantile( subdt:" || Char( cols[ii] ) || ", 0.75 ) - Col Quantile( subdt:" || Char( cols[ii] ) ||
", 0.25 )));"
)
)`;
Eval( Parse( "column (subdt, \!"Out" || Char( cols[ii] || "\!" )[" || Char( out ) || "] = 1;" ) ) );
// also indicate the global outlier
Column( subdt, "Out" )[out] = 1;
//wait (0.00001);
);
// update original data table with new information for the batch
subdt << delete columns( "Batch" );
subdt << delete columns( cols );
dt << Update( With( subdt ), Match Columns( :it = :it ) );
Close( subdt, No Save );
//Wait( 0.00001 );
);
dt << color by column( :Out );
Re: Seleccionar automáticamente valores atípicosSólo una pregunta rápida más. Eliminé alrededor de 90 columnas, ¿puede esto funcionar?
con n columnas o siempre tiene que ser 3 columnas?
Re: Seleccionar automáticamente valores atípicosParece funcionar.gracias.
Re: Seleccionar automáticamente valores atípicosahora mira si te funciona...
el script que enviaste no se adaptaba en absoluto a tus datos...
Re: Seleccionar automáticamente valores atípicosAdjunto se muestra un ejemplo de mis datos con los que estaba intentando usar esto.Lo ideal sería hacer esto para cada Y.
Re: Seleccionar automáticamente valores atípicosmi fórmula no es sensible al tamaño del lote. además, funcionará incluso si la columna del lote es de caracteres (y no numérica).
¿Puedes publicar una muestra, incluso con solo 2 o tres lotes diferentes?Re: Seleccionar automáticamente valores atípicosCuando lo ejecuto, obtengo una tabla, y aquí hay una instantánea de ella, esto
trabajo ya que puedo seleccionar filas donde Out = 1, si quiero seleccionar todas las
valores atípicos.
[imagen: imagen.png]
Re: Seleccionar automáticamente valores atípicosSi ejecuta el script completo, ¿puede ver que obtiene lo que quería (pero no en sus datos)?Re: Seleccionar automáticamente valores atípicosCopio todo desde //ahora nos ponemos a trabajar hacia abajo. Cuando ejecuto esto en
mi propia tabla, simplemente crea una tabla con un solo lote. debo decir
Una cosa es que el número de puntos por lote no es consistente. sí
No sé si eso importa.
Re: Seleccionar automáticamente valores atípicosesto funcionó para mí.
al final deberías tener 3 mesas. original con todas las filas, una con solo valores atípicos y la última sin valores atípicos. Déjame saber si funciona.
Names Default To Here( 1 );<BR /><BR />// make a sample data table<BR />dt = New Table( "Data",<BR /> add rows( 10000 ),<BR /> New Column( "it", Numeric, Continues, Format( "Best", 8 ), Formula( Row() ) ),<BR /> New Column( "Batch", Numeric, Ordinal, Format( "Best", 8 ), formula( Random Integer( 110 ) ) ),<BR /> New Column( "y", Numeric, Continues, Format( "Best", 8 ), formula( Random Lognormal( :Batch / 10, 5 ) ) ),<BR /> New Column( "Out", Numeric, Ordinal, Format( "Best", 8 ), formula( 0 ) ), <BR /><BR />);<BR /><BR />dt << run formulas;<BR />Column( dt, "it" ) << delete formula;<BR />Column( dt, "Batch" ) << delete formula;<BR />Column( dt, "y" ) << delete formula;<BR />Column( dt, "Out" ) << delete formula;<BR /><BR />// now we get to work<BR />dt = Current Data Table();<BR />byvarlist = Associative Array( dt:Batch ) << get keys;<BR />For( i = 1, i <= N Items( byvarlist ), i++,<BR /> dt << select where( dt:Batch == byvarlist[i] );<BR /> subdt = dt << Subset( Selected Rows( 1 ) );<BR /> dt << clear select;<BR /> subdt:Out << set formula(<BR /> If(<BR /> :y > Col Quantile( :y, 0.75 ) + (Col Quantile( :y, 0.75 ) - Col Quantile( :y, 0.25 )) * 1.5, 1,<BR /> :y < Col Quantile( :y, 0.25 ) - (Col Quantile( :y, 0.75 ) - Col Quantile( :y, 0.25 )) * 1.5, 1,<BR /> 0<BR /> )<BR /> );<BR /> subdt << run formulas;<BR /> Column( subdt, "Out" ) << delete formula;<BR /> keep = {"it", "Out"};<BR /> todelete = subdt << get column names( "string" );<BR /> For( icol = 1, icol <= N Items( keep ), icol++,<BR /> Remove From( todelete, Contains( todelete, Keep[icol] ), 1 )<BR /> );<BR /> subdt << delete columns( todelete );<BR /> dt << Update( With( subdt ), Match Columns( :it = :it ) );<BR /> Close( subdt, No Save );<BR /> Wait( 0.00001 );<BR />);<BR />selected = dt << select where( :Out == 1 );<BR />selected << Markers( 11 );<BR />selected << Marker Size( 8 );<BR />selected << Row Colors( red );<BR />dt << clear select;<BR /><BR />dt << select where( dt:Out == 1 );<BR />Outdt = dt << Subset( Selected Rows( 1 ) );<BR />dt << clear select;<BR /> <BR />Wait( 0.00001 );<BR /> <BR />dt << select where( dt:Out == 0 );<BR />indt = dt << Subset( Selected Rows( 1 ) );<BR />dt << clear select;<BR /><BR />
Re: Seleccionar automáticamente valores atípicosNo estoy seguro de haber recibido el último mensaje que acabo de enviar. Recibí un mensaje extraño.
correo electrónico automatizado. Arreglé el segundo y todavía funciona.
la misma cosa.
Re: Seleccionar automáticamente valores atípicosen el bucle for no lo esRe: Seleccionar automáticamente valores atípicosMi columna de lotes está en mayúsculas:
[imagen: imagen.png]
Re: Seleccionar automáticamente valores atípicosel nombre de la columna distingue entre mayúsculas y minúsculas, sea coherente al utilizar :Batch o :batchRe: Seleccionar automáticamente valores atípicoscuando ejecuté esto, creó una tabla de subconjunto solo con el primer lote. I
Cambié esto para hacer mi tabla abierta:
dt = currentdatatable();
byvarlist = Associative Array( dt:Batch ) << get keys;
For( i = 1, i <= N Items( byvarlist ), i++,
dt << select where( dt:batch == byvarlist[i] );
subdt = dt << Subset( Selected Rows( 1 ) );
dt << clear select;
subdt:Out << set formula(
If(
:y > Col Quantile( :y, 0.75 ) + (Col Quantile( :y, 0.75 )
-Col Quantile( :y, 0.25 )) * 1.5, 1,
:y < Col Quantile( :y, 0.25 ) - (Col Quantile( :y, 0.75 )
-Col Quantile( :y, 0.25 )) * 1.5, 1,
0
)
);
subdt << run formulas;
Column( subdt, "Out" ) << delete formula;
keep = {"it", "Out"};
todelete = subdt << get column names( "string" );
For( icol = 1, icol <= N Items( keep ), icol++,
Remove From( todelete, Contains( todelete, Keep[icol] ), 1 )
);
subdt << delete columns( todelete );
dt << Update( With( subdt ), Match Columns( :it = :it ) );
Close( subdt, No Save );
);
selected = dt << select where( :Out == 1 );
selected << Markers( 11 );
selected << Marker Size( 8 );
selected << Row Colors( red );
dt << clear select;Re: Seleccionar automáticamente valores atípicosDéjame intentar de nuevo
No es una solución elegante, pero los pasos son claros y fáciles de modificar.
Names Default To Here( 1 );
// make a sample data table
dt = New Table( "Data",
add rows( 10000 ),
New Column( "it", Numeric, Continues, Format( "Best", 8 ), Formula( Row() ) ),
New Column( "Batch" ,Numeric, Ordinal, Format( "Best", 8 ), formula( random integer (110) )),
New Column( "y" ,Numeric, Continues, Format( "Best", 8 ), formula( random log normal (:Batch / 10, 5) )),
New Column( "Out" ,Numeric, Ordinal, Format( "Best", 8 ), formula (0)),
);
dt << run formulas;
column (dt, "it") << delete formula;
column (dt, "Batch") << delete formula;
column (dt, "y") << delete formula;
column (dt, "Out") << delete formula;
// now we get to work
// extract the list of the by variable levels
byvarlist = Associative Array( dt:Batch ) << get keys;
// run across each group and locate the outliers
For( i = 1, i <= N Items( byvarlist ), i++,
// produce a subset data table for each group using selection method
dt << select where (dt:batch == byvarlist[i]);
subdt = dt << Subset(
Selected Rows( 1 ),
);
dt << clear select;
// indicate outliers within the group
subdt:Out << set formula(
If(
:y > Col Quantile( :y, 0.75 ) + (Col Quantile( :y, 0.75 ) -
Col Quantile( :y, 0.25 )) * 1.5, 1,
:y < Col Quantile( :y, 0.25 ) - (Col Quantile( :y, 0.75 ) -
Col Quantile( :y, 0.25 )) * 1.5, 1,
0
)
);
subdt << run formulas;
// prepare table for updating original by removing formulas and columns that are not needed
column (subdt, "Out") << delete formula;
keep = {"it", "Out"};
todelete = subdt << get column names( "string" );
For( icol = 1, icol <= N Items( keep ), icol++,
Remove From( todelete, Contains( todelete, Keep[icol] ), 1 )
);
subdt << delete columns( todelete );
// update
dt << Update(
With( subdt ),
Match Columns( :it = :it )
);
Close( subdt, No Save );
);
// now the original data has all the outliers indicated in a column
selected = dt << select where (:Out == 1);
selected << Markers( 11 );
selected << Marker size ( 8 );// not working???
selected << Row Colors( red );// not working???
dt << clear select;
Re: Seleccionar automáticamente valores atípicosIntente dividir la tabla por lotes y agruparla por valor único (para no perder ninguna fila) y luego ejecute mi script.
De lo contrario, necesitarás una estrategia diferente a la que te ofrezco.
¿tiene sentido?Re: Seleccionar automáticamente valores atípicosNo puedo hacer que esto funcione con mis datos, cambié la altura y el peso de mis columnas y eliminé las dos líneas donde abría la tabla y las incrusté en mi tabla, pero dice que las evaluaciones están hechas pero no haré nada.
También necesito algo que use by y this para cada lote individualmente.
Re: Seleccionar automáticamente valores atípicosHola,
quizás aquí haya una solución:
https://community.jmp.com/t5/Discussions/How-to-extract-month-in-words-from-a-date-value-how-to-change/mp/19362/highlight/true#M17650
ron
Re: Seleccionar automáticamente valores atípicosProbé el guión de Grubb.Esto solo muestra los valores atípicos y no resalta las filas, ¿verdad?Necesito algo que resalte las filas.
Re: Seleccionar automáticamente valores atípicosLa detección de valores atípicos no funciona si necesito una variable en by.Lo que quiero hacer es que mi Y esté en una columna.Otra columna está etiquetada como lote.Pongo lotes por lotes y hago el número de distribuciones a medida que hago lotes.Entonces digamos 100 distribuciones.Quiero un guión para resaltar todos los valores atípicos en las 100 distribuciones.Idealmente, solo resaltará las filas para que pueda elegir mi propio color, ya que uso colores para cosas diferentes.¿Tiene más sentido ahora?
Re: Seleccionar automáticamente valores atípicosSi hubieras buscado en Intercambio de archivos porción de la Comunidad JMP para ' parte aislada ,' habrías encontrado estos dos scripts de utilidad:
Por supuesto, la base estadística de cada una de estas pruebas debe adaptarse a su situación y criterio.
Re: Seleccionar automáticamente valores atípicosNo estoy seguro de exactamente lo que estás buscando.Si desea seleccionar las filas para una distribución determinada, al ver el resultado, simplemente puede arrastrar los puntos de datos atípicos mostrados en el diagrama de caja de valores atípicos y seleccionará los puntos de datos atípicos.

Pero si desea ir de una columna a otra y seleccionar filas atípicas, un script simple podría hacerlo; sin embargo, recuerde que la selección de filas abarca todas las columnas, y lo que terminará serán filas seleccionadas en las que se selecciona cualquiera de las columnas. .
Lo que realmente puede desear es un script simple que coloree todas las celdas individuales que son valores atípicos.Quizás rojo si están muy por encima de la media y naranja si son valores atípicos por debajo de la media.
¿Puedes aclarar exactamente lo que estás buscando?
Consulte la respuesta de Dan para obtener una mejor respuesta.
Re: Seleccionar automáticamente valores atípicosEs posible que desee buscar en Analizar > Detección > Explorar valores atípicos.