自动选择异常值我有 7000 行,由多个批次组成。我正在按批次进行分布,并使用离群值箱形图来查找离群值。但我有 100 多个批次,有没有办法让 JMP 自动选择哪些行是异常值?
回复:自动选择异常值这是你需要的吗?
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 );
回复:自动选择异常值再问一个简单的问题。 我删除了大约 90 列,这可以吗
有 n 列还是总是必须有 3 列?
回复:自动选择异常值似乎有效。谢谢。
回复:自动选择异常值现在看看它是否适合你......
您发送的脚本根本不适合您的数据......
回复:自动选择异常值附件是我尝试使用它的数据示例。理想情况下,它会对每个 Y 执行此操作。
回复:自动选择异常值我的公式对批量大小不敏感。此外,即使批处理列是字符(而不是数字),它也将起作用。
你能发布一个样品吗,即使只有两到三个不同的批次?回复:自动选择异常值当我运行它时,我得到一张表,这是它的快照,这将
工作,因为如果我想选择所有的,我可以选择 Out = 1 的行
异常值。
[图片:image.png]
回复:自动选择异常值如果你运行整个脚本,你能看到你得到了你想要的东西(只是不在你的数据上)?回复:自动选择异常值我复制了 // 现在我们开始工作。 当我运行这个时
我自己的表,它只创建一张表,只包含一批。 我必须说
有一件事是每批的点数不一致。 我愿意
不知道这是否重要。
回复:自动选择异常值这对我有用。
最后你应该有 3 张桌子。包含所有行的原始数据,一行仅包含异常值,最后一行没有异常值。让我知道它是否有效。
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 />
回复:自动选择异常值我不确定你是否收到我刚刚发送的最后一条消息,我收到一条奇怪的消息
自动回复电子邮件。 我修好了第二个,它仍然在做
一样。
回复:自动选择异常值在 for 循环中它不是回复:自动选择异常值我的批处理列是大写的:
[图片:image.png]
回复:自动选择异常值列名区分大小写,使用 :Batch 或 :batch 时保持一致回复:自动选择异常值当我运行这个时,它仅使用第一批创建了一个子集表。 我
改变这个来做我的开放表:
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;回复:自动选择异常值让我再尝试一次
这不是一个圆滑的解决方案,但步骤清晰且易于修改
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;
回复:自动选择异常值尝试按批次拆分表并按唯一值分组(这样您就不会丢失任何行),然后运行我的脚本。
否则你需要一种与我提供的策略不同的策略。
是否有意义?回复:自动选择异常值我无法让它与我的数据一起使用,我更改了列的高度和重量,并删除了打开表格并将其嵌入到我的表格中的两行,但它说评估已完成,但不会执行任何操作。
我还需要为每个批次单独使用 by 和 this 的东西。
回复:自动选择异常值你好,
也许这是一个解决方案:
https://community.jmp.com/t5/Discussions/How-to-extract-month-in-words-from-a-date-value-how-to-change/mp/19362/highlight/true#M17650
罗恩
回复:自动选择异常值我尝试了格鲁布的脚本。这只是显示了异常值,并没有突出显示行,对吧?我需要一些可以突出显示行的东西。
回复:自动选择异常值如果我需要一个变量,那么筛选离群值就不起作用。我想做的是我的 Y 位于一列中。另一列标记为批次。我将批次放入并按批次进行分配数量。假设有 100 个发行版。我想要一个脚本来突出显示所有 100 个分布中的所有异常值。理想情况下,它只会突出显示行,这样我就可以选择自己的颜色,因为我对不同的东西使用颜色。现在更有意义了吗?
回复:自动选择异常值如果您搜索过文件交换的一部分JMP 社区为了 '异常值,'您会发现这两个实用程序脚本:
当然,每个测试的统计基础必须适合您的情况和标准。
回复:自动选择异常值我不确定您到底在寻找什么。如果要选择给定分布的行,则在查看输出时,只需在离群值箱线图中显示的离群值数据点上拖动即可,它将选择离群值数据点。

但是,如果您想从一列转到另一列并选择离群值行,一个简单的脚本就可以做到这一点,但是请记住,行选择会跨越所有列,您最终会得到选择任意列的选定行。 。
您可能真正想要的是一个简单的脚本,为所有异常值的单个单元格着色。如果远高于平均值,则可能为红色;如果低于平均值的异常值,则可能为橙色。
您能准确说明您在寻找什么吗?
请参阅 Dan 的回复以获得更好的答案。
回复:自动选择异常值您可能需要查看“分析”>“筛选”>“探索离群值”。