回覆: 決策樹模型的「葉標籤公式」中如何不提取重複的列名?
如何從決策樹模型的「葉標籤公式」中取得不重複的列名?例如,使用下列 JSL 取得葉標籤公式。從前 10 行的公式中擷取列名稱。
謝謝!
d0 = Open( "$SAMPLE_DATA/Equity.jmp" );
p=Partition(
Y( :BAD ),
X(
:LOAN, :MORTDUE, :VALUE, :REASON, :JOB, :YOJ, :DEROG, :DELINQ, :CLAGE, :NINQ,
:CLNO, :DEBTINC
),
Validation Portion( 0.3 )
);
p<<GO></GO>
自動化和腳本編寫回覆: 決策樹模型的「葉標籤公式」中如何不提取重複的列名?Current Data Table( d0 );
txt = "";
For( i = 1, i <= 10, i++,
If( i == 1,
a = "",
a = "aaa"
);
nn = d0[i, "Leaf Label Formula"];
txt = txt || a || nn;
);
tx = "ccc\!n" || Substitute( txt, "&", "\!n", "aaa", "\!n", " or Missing", "", " not Missing", "", " Is Missing", "" );
tx = Substitute( tx, ">", "\!t>", "<", "\!t<", "(", "\!t(" );
d1 = Open( Char To Blob( tx ), "text" );
d2 = d1 << Summary( Group( ccc ), Freq( 0 ), Weight( 0 ), Link to original data table( 0 ) );Re: 如何從決策樹模型的「葉標籤公式」中取得不重複的列名?您可以循環遍歷所有可能的列名稱,如果找到匹配項,請將其新增至關聯數組(如果需要,可以從列列表中刪除)
Names Default To Here(1);
input_cols = {"LOAN", "MORTDUE", "VALUE", "REASON", "JOB", "YOJ", "DEROG", "DELINQ", "CLAGE", "NINQ", "CLNO", "DEBTINC"};
dt = Open("$SAMPLE_DATA/Equity.jmp");
part = dt << Partition(
Y(:BAD),
X(Eval(input_cols)),
Validation Portion(0.3)
);
part << go;
part << save leaf label formula;
part << close window;
aa_cols = Associative Array();
For Each({row_val}, dt[1::10, "Leaf Label Formula"],
input_cols_temp = input_cols;
For Each({input_col, idx}, input_cols,
If(Contains(row_val, input_col),
aa_cols[input_col] = 1;
Remove From(input_cols_temp, idx);
);
);
input_cols = input_cols_temp;
);