{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"クラスタリング","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"クラスタリング","__idx":0},"children":["クラスタリング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オーディエンススタジオでは、マーケターは属性ベースのルールを使用してセグメントを手動で作成し、どの顧客がどのセグメントに属するかを決定できます。これは、マーケターが特定のターゲットキャンペーン向けにペアレントセグメントを異なるグループに分割する方法を正確に把握している場合に有用です。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["場合によっては、マーケターはセグメントの自動作成から恩恵を受けることがあります。このクラスタリングノートブックは、k-meansクラスタリングを使用して、顧客の属性に基づいて顧客をグループ化し、顧客セグメントを形成します。このノートブックは、最小クラスタ数と最大クラスタ数の間で複数回クラスタリングを試行し、平均",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://en.wikipedia.org/wiki/Silhouette_(clustering)"},"children":["シルエット係数"]},"を最大化する理想的なクラスタ数を見つけます。または、自動計算を上書きするために特定のセグメント数を指定することもできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このソリューションノートブックは主に顧客セグメンテーションを目的としていますが、一般的なk-meansクラスタリングを実行し、顧客セグメンテーションからアイテムセグメンテーションまで、あらゆる種類のセグメンテーションに適用できます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"予想される入力","__idx":1},"children":["予想される入力"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このノートブックは、k-meansクラスタリングを使用して ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["input_table"]}," に基づいて自動的にセグメント化します。",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["cluster_id"]}," が ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["input_table"]}," の各行に割り当てられ、拡張されたテーブルは ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["output_table"]}," オプションを使用してTreasure Dataテーブルにエクスポートできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最適なクラスタ数は、",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["min_clusters"]}," と ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["max_clusters"]}," の間でシステムによって自動的に導出され、デフォルト値は上書きできます。希望するクラスタ数が事前にわかっている場合は、",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["num_clusters"]}," オプションでクラスタ数を明示的に設定できます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["input_table"]}," にはあらゆる種類のテーブルを使用できますが、より良いクラスタリングのために、",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["ignore_columns"]}," オプションでrowidやuseridなどの意味のない列を除外することが一般的に推奨されます（このノートブックは単一の値を持つ列を自動的に無視します）。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"予想される出力","__idx":2},"children":["予想される出力"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このノートブックは、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm#giniimp"},"children":["feature GINI重要度"]},"とShapley値を使用して、ランダムフォレスト分類器によるクラスタリングラベルに対する基本的なEDA（探索的データ分析）とXAI（説明可能なAI）を実行します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次のプロットグラフは、各クラスタの上位3つの特徴を示しています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/249715334-b2669297-7f08-4aa5-8828-21f649a255c9.ddcd1d696d4a4d09a09484c7b256386b91e60e918a6396daa85d6156db27511e.3cb60505.png","alt":"Screen Shot 2023-04-06 at 15 15 54"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次のプロットは、各クラスタの平均SHAP値を示しています。このグラフは、どの属性がクラスタ割り当てに最も寄与しているかを示しています。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/249715316-dbc3d057-72d6-4510-9aba-8c3126da55d0.abed2825acb2d45817866d0b58bfa8ed0940415da69ca2a015be24cff107a263.3cb60505.png","alt":"Screen Shot 2023-05-23 at 13 35 34"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ワークフローの例","__idx":3},"children":["ワークフローの例"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/treasure-boxes/blob/automl/machine-learning-box/automl/clustering.dig"},"children":["Treasure Boxes"]},"でサンプルワークフローをご覧いただけます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"+clustering_gluon:\n  ipynb>:\n    notebook: clustering\n    input_table: ml_datasets.gluon_train\n    output_table: ml_test.gluon_train_clustered_${session_id}\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"パラメータ","__idx":4},"children":["パラメータ"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"パラメータ名"},"children":["パラメータ名"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"コンソール上のパラメータ"},"children":["コンソール上のパラメータ"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"説明"},"children":["説明"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"必須"},"children":["必須"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"デフォルト値"},"children":["デフォルト値"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"値の例"},"children":["値の例"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["input_table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["dbname.table_name形式でクラスタリングに使用するTDテーブルを指定"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["はい"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 (dbname.table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_dataset.gluon_train"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["output_table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["dbname.table_name形式でクラスタリング結果をエクスポートするTDテーブルを指定"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 (dbname.table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_output.cluster"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["model_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["オプションで保存するモデル名を指定します。通常は設定する必要はありません。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["gluon_model"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["force_refit"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["既存の学習済みモデルがある場合でも強制的に適合します。force_refitをfalseに設定することは ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["実験的"]}," なオプションであることに注意してください。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ブール値"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["true"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["true"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["output_mode"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["output_tableをエクスポートするための出力モード。通常、指定する必要はありません。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 (overwrite/replace または append)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["overwrite"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["overwrite"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["min_clusters"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["最小クラスタ数を指定"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["整数"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["max_clusters"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["最大クラスタ数を指定"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["整数"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["9"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["25"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["num_clusters"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["固定クラスタ数を指定"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["整数"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ignore_columns"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["予測モデル構築時に無視する列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 (カンマ区切り)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["time"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["time, rowid"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["dimension_reduction_threshold"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["次元削減に使用される閾値。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["整数"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["50"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["30"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["export_feature_importance"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["指定した場合、特徴量重要度をTDテーブルとしてエクスポートします。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 ([dbname.]table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_test.feature_importance"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["export_shap_values"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["各クラスタのSHAP値をTDテーブルとしてエクスポート"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列 ([dbname.]table_name)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ml_test.shap_values"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["hide_table_contents"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["テーブルの内容の表示を抑制"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ブール値"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["false"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["false"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["audience_name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["属性テーブルをマージするオーディエンス名"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["my_master_segment_name"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["foreign_key"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["オーディエンス統合に使用されるマスターセグメントの外部キー列名。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["td_canonical_id"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["rowid_column"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["input_table内のrowid（主キー）列。オーディエンス統合のための属性テーブル結合キーとして必要であり、使用されます。"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["いいえ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["文字列"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["None"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["userid"]}]}]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["オーディエンス統合"]}," ","CDPマスターセグメントに属性テーブルを追加するには、3つのオプションすべてを設定してください：",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["audience_name"]}]},"、",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["foreign_key"]}]},"、および ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rowid_column"]}]},"。",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["rowid_column"]}," は、オーディエンスマスターテーブル内で結合される ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["output_table"]}]}," の結合キーです。これらのオプションが設定されると、CDPセグメントは各クラスタに対して自動的に生成されます。マーケターは、オーディエンススタジオのルールビルダーでクラスタルールをさらに変更できます。たとえば、他の属性を使用して、生成されたセグメントを追加のルールと組み合わせることができます。"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["パラメータ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["force_refit"]}," を ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," に設定し、事前に計算されたモデル（k-meansセントロイド）を使用することは実験的な機能であり、デフォルトの ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}," オプションから変更することは推奨されません。"]}]}]},"headings":[{"value":"クラスタリング","id":"クラスタリング","depth":1},{"value":"予想される入力","id":"予想される入力","depth":2},{"value":"予想される出力","id":"予想される出力","depth":2},{"value":"ワークフローの例","id":"ワークフローの例","depth":3},{"value":"パラメータ","id":"パラメータ","depth":3}],"frontmatter":{"seo":{"title":"クラスタリング"}},"lastModified":"2026-03-09T05:24:00.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/products/customer-data-platform/machine-learning/automl/notebook-solutions/clustering","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}