名稱未解析:當我將其指定為列表中的值時,列名稱將無法解析我正在嘗試計算數據表中每一列的 AUC。 我將所有列名稱收集到清單「colNamesList」中,並透過增加清單下標來檢索 For 迴圈內的 Fit Model 中的每個列名稱。 但是,對數組的呼叫並未在「擬合模型」呼叫內解析。如果我在單獨的行上包含 show(colNamesList[i]) ,它可以很好地解析,只是不在 Fit Model 呼叫中。 我正在使用本論壇上一篇文章中的腳本,我懷疑我的舊版 JMP(版本 9.0.0)只需要稍微不同的語法。 任何想法,將不勝感激。
Names Default To Here( 1 );
// Open and example data table
dt = Open( "sample.jmp" );
// Get the columns to be analyzed
colNamesList = dt << get column names( string );
// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "var_name", character ), New Column( "AUC", character ) );
// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++,
// Add a new row to the output data table
dtOutput << Add Rows( 1 );
// Add the active variable name to the current row in the data table
dtOutput:var_name[i] = colNamesList[i];
// Run the Logistic Regression
theLog = dt << Fit Model(invisible, Y( :case ),Effects( column (colNameList[i]) ),Personality( Nominal Logistic ),Run(Positive Level( "1" ),Likelihood Ratio Tests( 1 ),ROC Curve( 1 ),));
// Add the AUC to the data table by grabbing it from the display report output
dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][numberbox(1)] << get text);
// Close the report window
Report( theLog ) << close window;
);
日誌中的錯誤如下:
Name Unresolved: colNameList{1}
in access or evaluation of 'colNameList' , colNameList
Exception in platform launch{1}
in access or evaluation of 'Fit Model' , Fit Model(
invisible,
Y( :case ),
Effects( Column( colNameList[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
)
In the following script, error marked by /*###*/
Fit Model(
invisible,
Y( :case ),
Effects( Column( colNameList/*###*/[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
)
Cannot subscript Display Box{1}
in access or evaluation of 'Subscript' , Report( theLog )["Receiver Operating Characteristic"]
In the following script, error marked by /*###*/
Names Default To Here( 1 );
dt = Open( "sample.jmp" );
colNamesList = dt << get column names( string );
dtOutput = New Table( "Results",
New Column( "var_name", character ),
New Column( "AUC", character )
);
For( i = 1, i <= N Items( colNamesList ), i++,
dtOutput << Add Rows( 1 );
dtOutput:var_name[i] = colNamesList[i];
theLog = dt << Fit Model(/*###*/invisible,
Y( :case ),
Effects( Column( colNameList[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
);
dtOutput:AUC = Report( theLog )[/*###*/"Receiver Operating Characteristic"][
numberbox( 1 )] << get text;
Report( theLog ) << close window;
);自動化和腳本編寫視窗回覆:名稱未解析:當我將其指定為清單中的值時,列名稱將無法解析- 名稱未解析的原因是您呼叫了清單 colNamesList,並將其引用為 colNameLise。
- AUC值需要放置在定義的行,因此需要將下標加到dtOutput:AUC
Names Default To Here( 1 );
// Open and example data table
dt = Open( "sample.jmp" );
// Get the columns to be analyzed
colNamesList = dt << get column names( string );
// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "var_name", character ), New Column( "AUC", character ) );
// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++,
// Add a new row to the output data table
dtOutput << Add Rows( 1 );
// Add the active variable name to the current row in the data table
dtOutput:var_name[i] = colNamesList[i];
// Run the Logistic Regression
theLog = dt << Fit Model(
invisible,
Y( :case ),
Effects( Column( colNamesList[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
);
// Add the AUC to the data table by grabbing it from the display report output
dtOutput:AUC[i] = (Report( theLog )["Receiver Operating Characteristic"][numberbox( 1 )] << get text);
// Close the report window
Report( theLog ) << close window;
);
回覆:名稱未解析:當我將其指定為清單中的值時,列名稱將無法解析是的,這是一個錯字,修復它是解決方案的一部分,所以感謝您看到這一點。 我仍然收到「無法找到列{1}」錯誤,並透過在指定列時引用資料表來解決該問題:Column(dt, colNamesList[i]) 而不是 Column(colNamesList[i])。 然後我收到錯誤“回應也不應該是一個因素,^1case”,因此我添加了一個 IF 語句來忽略回應列。無論我是否將下標添加到 AUC,都會運行。
這是我的第一個 jsl 腳本。 真是一次學習經驗。 感謝 txnelson 的幫助!
Names Default To Here( 1 );
// Open and example data table
dt = Open( "sample.jmp" );
// Get the columns to be analyzed
colNamesList = dt << get column names( string );
// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "var_name", character ), New Column( "AUC", character ) );
// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++,
// Add a new row to the output data table
dtOutput << Add Rows( 1 );
// Add the active variable name to the current row in the data table
dtOutput:var_name[i] = colNamesList[i];
//Get the next column name
colName = colNamesList[i];
// If the column is "case", leave AUC blank, otherwise run the Logistic Regression
if(colName=="case", AUC=.,
theLog = dt << Fit Model(
invisible,
Y(:case),
Effects(column(dt,colName)),
Personality( Nominal Logistic ),
Run(
Positive Level( "1" ),
Likelihood Ratio Tests( 1 ),
ROC Curve( 1 ),
)
);
// Add the AUC to the data table by grabbing it from the display report output
dtOutput:AUC[i] = (Report( theLog )["Receiver Operating Characteristic"][numberbox(1)] << get text);
);
// Close the report window
Report( theLog ) << close window;
);回覆:名稱未解析:當我將其指定為清單中的值時,列名稱將無法解析做得好!
您可以透過將該行更改為來避免錯誤回應
try(Report( theLog ) << close window);
您也可以透過刪除單一語句的重複賦值來縮短 JSL 並使 JSL 運行更有效率
colName = dtOutput:var_name[i] = colNamesList[i];