如何自動排除包含“探索異常值”功能所識別的異常值的行?你好呀,
我希望復制我在 JSL 腳本中手動執行的操作。
我知道如何在 JSL 中運行“探索異常值”功能,但我仍然必須手動選擇具有“探索異常值”標識的異常值的行,然後按“選擇行”,然後按“排除”。
我正在嘗試構建一個腳本,我可以運行該腳本並自動排除已識別的異常值,而無需執行任何其他操作(理想情況下甚至不打開“探索異常值”窗口。
有人有什麼想法嗎?
謝謝!
腳本回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?你犯了一個很常見的錯誤。第一次跑步
el = Explore Outliers(
它指向“dt”數據表。 然而,當您第二次運行時,您已經創建了一個新的數據表“dtQuant”,這並不是 JMP 所知道的當前數據表。當然,它不會發現異常值。要解決此問題,您需要做的就是強制 JMP 確保它指向正確的數據表。
el = dt << Explore Outliers(
在另一個主題上,使用“j”作為變量名有時會遇到問題。JMP 有一個名為 j 的函數。即使您可以有一個名為 j 的變量,它也會使代碼的閱讀變得混亂。
回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?我在嘗試調試時分解了代碼。 似乎問題是在第二個循環中它無法保存分位數範圍異常值限制。
在日誌中它說“
數據表“Quantile Outlier Limits”的 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 );回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?謝謝@txnelson為解決方案。
我試圖修改它,以便我可以通過列中的變量列表循環整個代碼,以便我使用帶有附加“where”函數的分位數範圍異常值。
循環似乎崩潰,無法保存分位數異常值限制,表示對像不可編寫腳本。 有任何想法嗎?回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?此外@txnelson的回复,你可能會發現一些東西這個線程.
回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?是的,你是對的,對我的疏忽感到抱歉。回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?@SDF1該請求用於探索異常值,而不是探索缺失值
@JC7
這是我編寫的一個示例,它使用 Water Treatment 樣本數據表並隱藏和排除為所有列找到的所有行,這些行被發現為離群值。
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
回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?我正在使用分位數範圍異常值方法 - 抱歉忘記在原帖中說了!回复:如何自動排除包含“探索異常值”功能所識別的異常值的行?當您運行 Explore Outliers 時,您選擇哪種異常值方法? 看來不同的方法可能需要不同的解決方案。