距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですかウェーハ上の 2 セットの測定について、2 つのデータ テーブルがあります。各テーブルには 4 つの列があり、X、Y は測定場所を表し、各テーブルには測定データの 2 つの列があります。測定値は、ウェーハの正確に同じ位置 (X、Y) から収集されたわけではありません。測定場所の近さに基づいて、いずれかのテーブルを更新 (他のテーブルの列を追加) したいと思います。より明確にするために、X1、Y1 と X2、Y2 上の最も近いポイントとのマッチングに基づく結合テーブル (合計 8 列) が必要です。アップロードした画像を参照してください。距離関数を使用して、特定の X、Y からのすべての距離のマトリックスを作成できることはわかっていますが、更新されたテーブルを計算するための jsl コードの記述方法がわかりません。
自動化とスクリプトデータのブレンドとクリーンアップウィンドウズRe: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?距離に加えて次の機能もチェックしてください
次に、行ベースのインデックスを「メイン」テーブルに追加し、そのうちの 1 つを使用して最も近いインデックス (基本的には行) を見つけ、それを 2 番目のテーブルに追加し、最後に更新/結合を使用してテーブルを結合します。
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?@jthiのリンクに基づいて、これがあなたが望むことを実現すると信じています
dt1=New Table( "Table 1",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
dt2=New Table( "Table 2",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Display Width( 120 )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Selected,
Set Display Width( 118 )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
M1 = dt1 << GetAsMatrix();
MD1=vptree(M1);
M2 = dt2 << GetAsMatrix();
MD2=kdtable(M2);
//returns the nearest point of Table 1 to a point in table 2
//to reverse the look up, make MD1-> MD2 and M2->M1
{rows, dist} = MD1 << K nearest rows( 1, M2);
dt1<<NEW column=""></NEW>Steve
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?こんにちは、スティーブとジャルモ。
ご提案ありがとうございます。スクリプトも役に立ちました。ただし、実行しても、最も近い距離が見つからないようです。たとえば、表 1 の最初の行は表 2 の行 8 (距離は約 1.37) と一致しますが、行番号 1 (距離は 0.69) など、はるかに近い点が多数あります (距離を sqrt[(x-x0)^2+(y-y0)^2] とします)

Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?スクリプトの最後のデータ テーブルを混同したようです。次を試してください。
dt1=New Table( "Table 1",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
wait(0.0);
dt1:x << suppress eval( true );
dt1:y << suppress eval( true );
dt2=New Table( "Table 2",
Add Rows( 20 ),
New Column( "x",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Display Width( 120 )
),
New Column( "y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Random Normal() ),
Set Selected,
Set Display Width( 118 )
),
Set Row States( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] )
);
wait(0.0);
dt2:x << suppress eval( true );
dt2:y << suppress eval( true );
M1 = dt1 << GetAsMatrix();
MD1=vptree(M1);
M2 = dt2 << GetAsMatrix();
MD2=kdtable(M2);
//returns the nearest point of Table 1 to a point in table 2
//to reverse the look up, make MD1-> MD2 and M2->M1
{rows, dist} = MD1 << K nearest rows( 1, M2);
dt2<<NEW column=""></NEW>I virtual linked them and did some visual checks so I believe we are good now
<SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><span class="lia-inline-image-display-wrapper" image-alt="shampton82_0-1724013813741.png" style="width: 400px;"><img src="https://us.v-cdn.net/6038925/uploads/images/67225i8663690D9A1ED800/shampton82_0-1724013813741.png" role="button" title="shampton82_0-1724013813741.png" alt="shampton82_0-1724013813741.png" /></span></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN>
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?I still see it is not picking up the closest points: <BR />Names Default To Here( 1 );
Close All(data tables);
Clear Log();
Clear Symbols();
dt1= Open(
"C:\Users\Table 1.jmp");
wait(0.0);
dt1:X1 << suppress eval( true );
dt1:Y1 << suppress eval( true );
dt2= Open(
"C:\Users\Table 2.jmp");
wait(0.0);
dt2:X2 << suppress eval( true );
dt2:Y2 << suppress eval( true );
M1 = dt1 << GetAsMatrix();
MD1=vptree(M1);
M2 = dt2 << GetAsMatrix();
MD2=kdtable(M2);
//returns the nearest point of Table 1 to a point in table 2
//to reverse the look up, make MD1-> MD2 and M2->M1
{rows, dist} = MD1 << K nearest rows( 1, M2);
dt1<<NEW column=""></NEW>Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?dt1=New Table( "Table 1",
Add Rows( 20 ),
New Column( "x",
Formula( Random Uniform(0,10) )
),
New Column( "y",
Formula( Random Uniform(0,10) )
)
);
dt2=New Table( "Table 2",
Add Rows( 64 ),
New Column( "x2",
Formula( floor(row()/8)+1 )
),
New Column( "y2",
Formula( mod(row(),8)+1 )
)
);
// M2 = dt2 << GetAsMatrix();
// better - see below
M2 = dt2[0, {"x2", "y2"}];
MD2=kdtable(M2);
dt1 << New Column( "row_orig",Nominal, Formula( Row() ));
dt2 << New Column( "row_2",Nominal,Formula( Row() ));
dt1 << New Column( "table",Nominal, set each value(1));
dt2 << New Column( "table",Nominal, set each value(2));
wait(0);
// step by step, for each row in dt1, use MD2 to find the closest position in dt2
dt1 << new column("row_2",Nominal, set each value(
pos = Matrix({:x, :y});
(MD2 << K nearest rows( 1, pos))[1][1]));
// concatenate the tables to generate a combined plot
dt2:x2 << set name("x");
dt2:y2 << set name("y");
check = dt1 << Concatenate(dt2);
check << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :x ), Y( :y ), Overlay( :row_2 ), Color( :table ) ),
Elements(
Line( X, Y, Row order( 1 ) ),
Points( X, Y, Overlay( 0 ), Legend( 2 ) )
),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model(
2,
Properties( 0, {Marker( "FilledSquare" )}, Item ID( "1", 1 ) ),
Properties( 1, {Marker( "Circle" )}, Item ID( "2", 1 ) )
)}
)
)
);

Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?@hogiさん、これを整理してくれてありがとう!
質問ですが、このコード行が何をしているのか説明していただけますか?
dt1 << new column("row_2",Nominal, set each value(pos = Matrix({:x, :y});(MD2 << K nearest rows( 1, pos))[1][1]));
感謝!
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?ホギさん、ありがとう
これは非常にうまく動作しますが、私はスティーブとまったく同じ疑問を抱いていました。
このセリフを説明していただけますか
dt1 << new column("row_2",Nominal, set each value(pos = Matrix({:x, :y});(MD2 << K nearest rows( 1, pos))[1][1]));さらに、私のバージョンを実行すると(テーブル 1 の 4 つの列(x、y、データ 1、データ 2)と(x2、y2、データ 3、データ 4)のテーブルを読み取り)、以下のアラートが表示されます。テーブル 1 とテーブル 2 に、マトリックスに含まれていない 2 つ以上の列(x、y)があるため、問題が発生していると思います。ただし、行を説明していただければ、残りの部分は理解できると思います。ご協力ありがとうございます。

Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?こんにちは@spinup
問題は、私のコードがテーブルに x 値と Y 値のみがあると想定していることだと思います。余分な数値列があるテーブルから始めると、k 近傍法は X、Y、A、B と X、Y、C、D の最も近いポイントを見つけようとします。
@hogiコードが X と Y だけを見ている場合に非常にうまく機能するのはそのためだと思います。
X/Y 以外の列を文字にして 2 番目のコードを実行すると機能しますが、結合したら数値に戻す必要があります。
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?いつもこんな感じになります
Names Default To Here(1);
dt1 = New Table("Table 1",
Add Rows(20),
New Column("x", Numeric, "Continuous", Formula(Random Normal())),
New Column("y", Numeric, "Continuous", Formula(Random Normal()))
);
dt2 = New Table("Table 2",
Add Rows(20),
New Column("x", Numeric, "Continuous", Formula(Random Normal())),
New Column("y", Numeric, "Continuous", Formula(Random Normal())),
New Column("Val", Numeric, Continuous, Formula(Random Normal(2, 100)))
);
m1 = dt1[0, {"x", "y"}];
m2 = dt2[0, {"x", "y"}];
tree = VPTree(m2);
{rows, distances} = tree << K Nearest Rows(1, m1);
dt1 << New Column("Nearest", Numeric, Ordinal, Values(rows));
dt1 << New Column("Distance", Numeric, Ordinal, Values(distances));
dt2 << New Column("Row", Numeric, Ordinal, Values(1::N Rows(dt2)));
/* Depending on the wanted result, using Update might be better */
dt_result = dt1 << Join(
With(dt2),
By Matching Columns(:Nearest = :Row),
Drop multiples(0, 0),
Include Nonmatches(0, 0),
Preserve main table order(1),
Output Table("Result")
);
/*
Close(dt1, no save);
Close(dt2, no save);
*/
結果を確認しなかったため、Join/K Nearest Rows が間違った方向に実行された可能性があります。
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?座標を含む行列を取得するには、Jarmo の例のように、データ テーブルの添え字を使用できます。
row = 0 -> すべての行
列: x と y
coordinates as matrix = dt1[0, {"x", "y"}];Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?VPTreeのドキュメントを最適化できます。
KD テーブル:

KDTable << K 最も近い行には2 つのモードがあります。
- デフォルト: 入力位置を開始点として取得します。
-> 私たちには適していません。
- オプション: 開始点として単一の位置を使用します。
-> はい!
私はこの点を各行ごとにpos = Matrix ({:x,:y})として計算し、それをKの最も近い行の2番目の引数として指定します。
戻り値は行と距離のベクトルです。 [1][1]を使用すると、最初に行を取得し、次に最初の(そして唯一の)エントリを取得できます。
残念ながら、入力として開始点のセットを提供するモードはありません。
VPツリー:
K 近傍行については、Scripting INdex に実際のドキュメントはありませんが、VPTree の定義に例があります。

オンラインヘルプにはいくつかのドキュメントがあります:


KDTable と同じ 2 つのオプションのようです。
@jthiの例から、VPTree では位置のセットがマトリックスとして提供される 3 番目のモードが許可されていることがわかります。
これはちょっと意外ですが、とても便利です:)
tree = VPTree(m2);
{rows, distances} = tree << K Nearest Rows(1, m1);
dt1 << New Column("Nearest", Numeric, Ordinal, Values(rows));
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?VPtree << K Nearest Rows(1, matrix of coordinates);
ニース : ):)
Re: 距離に基づいて、あるテーブルから別のテーブルにデータを追加するにはどうすればいいですか?その他のアイデア:
- 1D に関する要望: 完全一致のない列によるファジー結合 / asof マージ / 結合の追加
高次元を考慮するためのコメントを追加しました。
- 実際のアプリケーション ケースでは、ロット、ウェーハ、バリアントなどの追加の公称座標があります。ユーザーはそれに応じてデータを分割し、各「バリアント」に対して個別の VPTree を設定する必要があります。groupByを使用した VPTree は、論理的な次のステップになります。
- 一方、ユーザーは、隣接する値を使用するのではなく、入力データを補間して、より意味のある値を取得することを好む場合があります。 グループ化 - 非常に便利です!!! 補間はどうでしょうか?