名前が解決されない: 列名をリストの値として指定しても解決されません。データテーブルの各列のAUCを計算しようとしています。 すべての列名をリスト「colNamesList」に収集し、リストの添字をインクリメントすることで For ループ内の Fit Model の各列名を取得しています。 ただし、配列への呼び出しは 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;
);自動化とスクリプト作成ウィンドウズRe: 名前が解決されない: 列名をリストの値として指定しても解決されません- 名前が未解決になった理由は、リストを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;
);
Re: 名前が解決されない: 列名をリストの値として指定しても解決されませんはい、それはタイプミスでした。それを修正することが解決策の一部でした。ご覧いただきありがとうございます。 まだ「列{1}が見つかりませんでした」というエラーが発生していましたが、列を指定するときにデータテーブルを参照することで解決しました: Column(colNamesList[i]) の代わりに Column(dt,colNamesList[i]) 。 次に、「Response should not be a factor, ^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;
);Re: 名前が解決されない: 列名をリストの値として指定しても解決されませんよくやった!
この行を次のように変更することで、エラー応答を回避できます。
try(Report( theLog ) << close window);
単一のステートメントへの重複した代入を削除することで、JSL を短縮してより効率的に実行することもできます。
colName = dtOutput:var_name[i] = colNamesList[i];