Re: リストの文字列を新しい列の数式の本体に変換するスクリプト。この例では、すべての「数式」の列名が「(」の後に始まるため、「(:」に置き換えてから Parse を使用できます。
Names Default To Here(1);
dtinit = Open("$SAMPLE_DATA/Bands Data.jmp");
dtfeat = New Table("features",
Add Rows(14),
New Column("Term",
Character,
"Nominal",
Set Property("ID Column", 1),
Set Values(
{"press speed", "(roller durometer-34.5151)*(anode space ratio-102.914)", "(proof cut-44.9671)*(blade pressure-30.8904)",
"(anode space ratio-102.914)*(chrome content-99.6164)", "(humidity-78.6849)*(press speed-1851.21)", "roller durometer",
"(roller durometer-34.5151)*(current density-39.0164)", "(humidity-78.6849)*(wax-2.4037)",
"(wax-2.4037)*(chrome content-99.6164)", "(viscosity-50.7836)*(press speed-1851.21)", "(wax-2.4037)*(hardener-0.96014)",
"(roughness-0.71969)*(current density-39.0164)", "(humidity-78.6849)*(ink pct-55.6473)",
"(blade pressure-30.8904)*(press speed-1851.21)"}
)
),
Set Label Columns(:Term)
);
dtfeat << New Column("interaction", Character, "Nominal", Formula(If(Starts With(:term, "("), :term, ""))) <<
Move Selected Columns({:interaction}, after(:term));
value = dtfeat:interaction << get values();
uniqueinteraction = Associative Array(value) << get keys;
For Each({uniq}, uniqueinteraction,
f_str = Substitute(uniq, "(", "(:");
If(IsMissing(f_str),
continue();
);
Eval(EvalExpr(
dtinit << New Column(uniq, Numeric, "Continuous",
Formula(Expr(Parse(f_str)))
)));
);
Eval Insert、Eval Expr、Parse、および Substitute を使用して、式を別の式に挿入します。
Re: リストの文字列を新しい列の数式の本体に変換するスクリプト。並外れた。 トリックをしました。 どうもありがとう。
リストの文字列を新しい列の数式の本体に変換するスクリプト。Fit プラットフォームを使用した後、相互作用する列を特定し、相互作用 (階乗など) を探すプロセスに従います。 相互作用から得られた項 (cA*0.1+cB*0.3 など) を開始点として使用し、これらの項から列の式を自動的に作成したいと考えています。 「cA*0.1+cB*0.3」などの文字列の内容を使用する方法を見つけるのに苦労しています。cA と cB は、テーブルに存在する 2 つの列の名前を表し、新しい数式を構築します。
スクリプトの最後の部分では式を作成しますが、文字列の内容を評価するのではなく、文字列の内容を表すだけです。
ご提案をいただければ幸いです。
セバスチャン
names default to here(1);
clear log();
dtinit=Open( "$SAMPLE_DATA/Bands Data.jmp" );
// Make TableBox into a Data Table
// → Data Table( "Untitled 3" )
//terms tables resulting from a generalized regression taking into consideration term interaction.
dtfeat = New Table( "features",
Add Rows( 14 ),
New Column( "Term",
Character,
"Nominal",
Set Property( "ID Column", 1 ),
Set Values(
{"press speed", "(roller durometer-34.5151)*(anode space ratio-102.914)", "(proof cut-44.9671)*(blade pressure-30.8904)",
"(anode space ratio-102.914)*(chrome content-99.6164)", "(humidity-78.6849)*(press speed-1851.21)", "roller durometer",
"(roller durometer-34.5151)*(current density-39.0164)", "(humidity-78.6849)*(wax-2.4037)", "(wax-2.4037)*(chrome content-99.6164)",
"(viscosity-50.7836)*(press speed-1851.21)", "(wax-2.4037)*(hardener-0.96014)", "(roughness-0.71969)*(current density-39.0164)",
"(humidity-78.6849)*(ink pct-55.6473)", "(blade pressure-30.8904)*(press speed-1851.21)"}
)
),
Set Label Columns( :Term )
);
//Identifies interacting terms
// New column: interaction
dtfeat << New Column( "interaction", Character, "Nominal", Formula( If( Starts With( :term, "(" ), :term, "" ) ) ) <<
Move Selected Columns( {:interaction}, after( :term ) );
value = dtfeat:interaction << get values();
uniqueinteraction = Associative Array( value ) << get keys;
nvinteract = N Items( uniqueinteraction );
//Will create a column named after the interacting terms
//Should apply a formula based on the interacting terms
//However, not sure how to extract the string from the list 'uniqueinteraction' so that is it not seen as a string but rather as 'formula instruction' where some portion of the term is recognized as a column namealready present in the original table
For( i = 1, i <= nvinteract, i++,
dtinit << New Column( uniqueinteraction[i], Numeric, "Continuous", Format( "Best", 12 ), Formula( Eval( uniqueinteraction[i] ) )
消費者および市場調査