如何自动排除包含“探索异常值”功能所识别的异常值的行?你好呀,
我希望复制我在 JSL 脚本中手动执行的操作。
我知道如何在 JSL 中运行“探索离群值”功能,但我仍然必须手动选择具有由“探索离群值”标识的离群值的行,然后按“选择行”,然后按“排除”。
我正在尝试构建一个脚本,运行该脚本并自动排除已识别的异常值,而无需执行任何其他操作(理想情况下甚至不打开“探索异常值”窗口。
有人有什么想法吗?
谢谢!
自动化和脚本编写数据混合和清理回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?你犯了一个非常常见的错误。第一次跑步时
el = Explore Outliers(
它指向“dt”数据表。 然而,当您第二次运行时,您已经创建了一个新的数据表“dtQuant”,据 JMP 所知,它不是当前的数据表。当然,它不会发现异常值。要解决此问题,您所需要做的就是强制 JMP 确保它指向正确的数据表。
el = dt << Explore Outliers(
在另一个主题上,使用“j”作为变量名有时会遇到问题。JMP 有一个名为 j 的函数。即使您可以有一个名为 j 的变量,它也会使代码阅读变得混乱。
回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?我在尝试调试时已经分解了代码。 问题似乎在于,在第二个循环中,它无法保存分位数范围异常值限制。
日志中写着“
数据表“分位数离群值限制”的Where 子句导致没有行:dt:Grade == Grades[j]"
然而,我知道该列表中的每个年级都有局限性并且存在。 我通过从 J 的不同值开始检查它,它总是在第一个循环上工作,然后在第二个循环上崩溃。 我认为这与我在 el 变量中存储数据的方式有关?
Names Default to here(1);
dt = current data table();
// Determine grades to loop through
dt1 = dt << summary(Group(:Grade));
dt1 << select where ( :Grade == "");
dt1 << delete rows;
dt1 << select where ( :Grade == "Check input");
dt1 << delete rows;
grades = dt1:Grade << get values;
Close (dt1, nosave);
For (j = 3, j<= N items ( grades ), J++,
show(grades[j]);
el = Explore Outliers(
Y( dt:Hardness, dt:UTS, dt:M100, dt:Elongation, dt:LCR, dt:Prof, dt:SG ),
Tail Quantile( 0.25 ),
Show only columns with outliers( 1 ),
Quantile Range Outliers,
Where( dt:Grade == grades[j]);
);
show (el);
dtQuant = el << Save Quantile Outlier Limits;
Report(el)<< close window;
);
回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?没有看到你的代码,我只能猜测问题是什么。听起来,您已经在数据表中添加了一列,其中包含您想要作为异常值分析基础的列。如果我猜对了,下面是对我之前的脚本的修改,它在数据表中添加了一个新列,其中包含要分析的列。该脚本从列中读取要分析的列,然后使用这些列名称来限制要评估的列
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Water Treatment.jmp" );
// Create a new column with the names of the columns to be used
// in the analysis
dt << New Column( "theColumns",
character,
set values(
{"Q-E", "ZN-E", "PH-E", "DBO-E", "DQO-E", "SS-E", "SSV-E", "SED-E", "COND-E", "PH-P", "DBO-P", "SS-P",
"SSV-P", "SED-P", "COND-P", "PH-D", "DBO-D", "DQO-D", "SS-D", "SSV-D", "SED-D", "COND-D", "PH-S"}
)
);
// Get the list of columns from the column that contains
// the columns to be analyzed
colNames = dt:theColumns << get values;
// Get rid of entries that have blank/null values
For( i = N Items( colNames ), i >= 1, i--,
If( colNames[i] == "",
Remove From( colNames, i, 1 )
)
);
// Run the analysis using the list of column extracted from the
// "theColumns" column
el = Explore Outliers(
Y( Eval( colNames ) ),
Quantile Range Outliers,
);
dtQuant = el << Save Quantile Outlier Limits;
dtQuant << show window( 0 );
Report( el ) << close window;
// Get rid of non involved columns
dtQuant << select where( :Number of Outliers == 0 );
dtQuant << delete rows;
// Loop through the remaining rows and set the affected rows in the dt table to selected
dt << clear row states;
For( i = 1, i <= N Rows( dtQuant ), i++,
dt << select where(
As Column( dt, dtQuant:Column[i] ) <= dtQuant:Low Threshold[i] | As Column( dt, dtQuant:Column[i] )
>= dtQuant:High Threshold[i],
current selection( "extend" )
)
);
// Hide and exclude the rows
dt << hide and exclude;
// Close the no longer needed data table
Close( dtQuant, nosave );回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?谢谢@tx尼尔森的解决方案。
我尝试对其进行修改,以便可以通过列中的变量列表循环整个代码,以便将分位数范围离群值与附加的“where”函数一起使用。
该循环似乎崩溃了,无法保存分位数异常值限制,表示对象不可编写脚本。 有任何想法吗?回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?此外@tx尼尔森的回复,你可能会发现一些东西这个线程。
回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?是的,你是对的,对于我的疏忽感到抱歉。回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?@SDF1该请求是为了探索异常值,而不是探索缺失值
@JC7
这是我编写的一个示例,它使用水处理示例数据表,并隐藏和排除所有已发现为异常值的列的所有行。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Water Treatment.jmp" );
el = Explore Outliers(
Y(
:Name( "Q-E" ),
:Name( "ZN-E" ),
:Name( "PH-E" ),
:Name( "DBO-E" ),
:Name( "DQO-E" ),
:Name( "SS-E" ),
:Name( "SSV-E" ),
:Name( "SED-E" ),
:Name( "COND-E" ),
:Name( "PH-P" ),
:Name( "DBO-P" ),
:Name( "SS-P" ),
:Name( "SSV-P" ),
:Name( "SED-P" ),
:Name( "COND-P" ),
:Name( "PH-D" ),
:Name( "DBO-D" ),
:Name( "DQO-D" ),
:Name( "SS-D" ),
:Name( "SSV-D" ),
:Name( "SED-D" ),
:Name( "COND-D" ),
:Name( "PH-S" ),
:Name( "DBO-S" ),
:Name( "DQO-S" ),
:Name( "SS-S" ),
:Name( "SSV-S" ),
:Name( "SED-S" ),
:Name( "COND-S" ),
:Name( "RD-DBO-P" ),
:Name( "RD-SS-P" ),
:Name( "RD-SED-P" ),
:Name( "RD-DBO-S" ),
:Name( "RD-DQO-S" ),
:Name( "RD-DBO-G" ),
:Name( "RD-DQO-G" ),
:Name( "RD-SS-G" ),
:Name( "RD-SED-G" )
),
Quantile Range Outliers,
);
dtQuant = el << Save Quantile Outlier Limits;
dtQuant << show window( 0 );
Report( el ) << close window;
// Get rid of non involved columns
dtQuant << select where( :Number of Outliers == 0 );
dtQuant << delete rows;
// Loop through the remaining rows and set the affected rows in the dt table to selected
dt << clear row states;
For( i = 1, i <= N Rows( dtQuant ), i++,
dt << select where(
As Column( dt, dtQuant:Column[i] ) <= dtQuant:Low Threshold[i] | As Column( dt, dtQuant:Column[i] )
>= dtQuant:High Threshold[i],
current selection( "extend" )
)
);
// Hide and exclude the rows
dt << hide and exclude;
// Close the no longer needed data table
Close( dtQuant, nosave );
回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?你好@JC7 ,
遵循这样的事情应该很容易:
Names Default To Here( 1 );
dt = Current Data Table();
colnames = dt << Get column Names();
obj = dt << Explore Missing Values( Y( Eval( colnames ) ) );
obj << select rows( Eval( colnames ) );
DS
回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?我正在使用分位数范围离群值方法 - 抱歉忘记在原始帖子中说!回复:如何自动排除包含“探索异常值”功能所识别的异常值的行?运行“探索离群值”时,您选择哪种离群值方法? 看来不同的方法可能需要不同的解决方案。