---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MLSolution - グローバル

# MLSolution - グローバル {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：14分

MLSolution API は、予測インテリジェンス予測を処理し、すべての機能 (類似性、分類、クラスタリング) のソリューション オブジェクトを取得するためのメソッドを提供します。  
この API は、すべてのソリューション機能で共通して使用されるメソッドと、分類およびクラスタリングソリューションに固有のメソッドを提供します。

* すべてのソリューションオブジェクトに使用される共通メソッド：
  * getCapability()
  * getVersion()
  * isActive()
  * predict()
  {#MLSolutionAPI__ul_uyg_bjy_xjb}
* 分類および回帰ソリューションにのみ使用されるメソッド：
  * applyPrediction()
  {#MLSolutionAPI__ul_wls_bjy_xjb}
* クラスタリングソリューションにのみ使用されるメソッド：
  * getClusterAssignments()
  * getClusterForRecord()
  * getClusterInfo()
  {#MLSolutionAPI__ul_j35_bjy_xjb}
{#MLSolutionAPI__ul_cd1_1jy_xjb}

MLSolution API には 予測インテリジェンス プラグイン (com.glide.platform_ml) が必要です。この API は `sn_ml` 名前空間内で提供されます。

このオブジェクトのメソッドは、 [MLSolutionFactory](https://servicenow-prod.fluidtopics.net/cIPr9KPGjna7r1FYFgYKUA#MLSolutionFactoryAPI "MLSolutionFactory API は、MLSolution スクリプト可能オブジェクトを取得するためのファクトリークラスです。") を使用してインスタンス化されます。{#MLSolutionAPI__classInstantMLSF}
**関連概念**   

* [MLSolutionUtil](https://servicenow-prod.fluidtopics.net/ajbnkWT3NwUM1Dl3uk9d2A#MLSolutionUtilAPI "MLSolutionUtil スクリプトインクルードは、予測インテリジェンス予測を取得するためのメソッドを提供します。")
* [REST API：複数のソリューションの予測を取得する](https://servicenow-prod.fluidtopics.net/b~IuVxzMHLi_bAbImtWwag#agent-intelligence-api "Predictive Intelligence API は、1 つ以上の入力フィールドとトレーニング済みソリューションに基づいてフィールド値を予測するエンドポイントを提供します。")

## MLSolution - applyPrediction(GlideRecord now_GR) {#ariaid-title2}

信頼性の値がしきい値より大きい場合に、分類ソリューションの予測結果を取得し、それを入力 GlideRecord に適用します。
{#MLSolution-applyPrediction_GR__table_hqw_pbm_yfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| now_GR | GlideRecord | 予測を実行して結果を適用する対象の値を含む GlideRecord オブジェクト。 |
[表 : 1. パラメーター]

{#MLSolution-applyPrediction_GR__table_hqw_pbm_yfb} {#MLSolution-applyPrediction_GR__table_iqw_pbm_yfb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | 予測が適用されたかどうかを示すフラグ。 * true：予測が適用された * false：予測が却下された {#MLSolution-applyPrediction_GR__ul_pvl_ggm_ckb} |
[表 : 2. 返される内容]

{#MLSolution-applyPrediction_GR__table_iqw_pbm_yfb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_incident_categorization");

    var inputGR = new GlideRecord("incident");
    inputGR.get("0ef47232db801300864adfea5e961912");

    mlSolution.applyPrediction(inputGR);

## MLSolution - getCapability() {#ariaid-title3}

トレーニング済みソリューションの機能情報を取得します。
{#MLSolution-getCapability__table_em3_pfx_ggb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 3. パラメーター]

{#MLSolution-getCapability__table_em3_pfx_ggb} {#MLSolution-getCapability__table_fm3_pfx_ggb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | トレーニング済みソリューションのタイプ。 可能な値： * 類似性 * 分類 * クラスタリング {#MLSolution-getCapability__ul_sv5_slm_ckb} |
[表 : 4. 返される内容]

{#MLSolution-getCapability__table_fm3_pfx_ggb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_x_global_clustering");

    // configure optional parameters
    var options = {};
    options.group_by = 'network';
    options.cluster_id = 1;
    options.top_n_per_cluster = 3;

    if (mlSolution.getCapability() == 'clustering') {
    	var results = mlSolution.getClusterAssignments(options);
    	// pretty print JSON results
    	gs.print(JSON.stringify(JSON.parse(results), null, 2));
    }

## MLSolution - getClusterAssignments(オブジェクト options) {#ariaid-title4}

クラスタリングソリューションの割り当てを取得します。
{#MLSolution-getClusterAssignments_O__table_t1q_hxt_rhb__entry__3}{#MLSolution-getClusterAssignments_O__ml-cluster-create-xbl}

| 名前 | タイプ | 説明 |
|-|-|-|
| オプション | オブジェクト | オプション。返された結果を、クラスタリングソリューション内のグループとレベルで絞り込むために使用する値。 デフォルト：すべてのクラスターのクラスターメンバーシップを返します。 |
| options.group_by | 文字列 | オプション。クラスターメンバーシップ (assignment_group など) を取得するセグメンテーションフィールドを識別します。 このフィールドは、\[クラスタリング定義\] フォームの \[グループ化\] チェックボックスで提供されるオプションと同じグループ化を提供します。表示される情報は、\[テーブル\] フィールドで選択したテーブルによって異なります。詳細については、「 [クラスタリングソリューションの作成とトレーニング](https://www.servicenow.com/docs/access?context=create-clustering-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US) 」を参照してください。 |
| options.cluster_id | 文字列 | オプション。クラスターサマリー \[ml_cluster_summary\] テーブルのトレーニング済みソリューションのクラスター ID。 |
| options.top_n_per_cluster | 番号 | クラスターごとに受信する上位の結果の数。 |
[表 : 5. パラメーター]

{#MLSolution-getClusterAssignments_O__table_t1q_hxt_rhb} {#MLSolution-getClusterAssignments_O__table_u1q_hxt_rhb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | クラスター情報を含む JSON のアレイ (cluster_id の昇順)。 * cluster_id：文字列。クラスターのソリューション内の一意のクラスター番号。{#MLSolution-getClusterAssignments_O__mlv-getClusterInfo-returnsID} * rec_display_id：文字列。レコードのタイプと番号。{#MLSolution-getClusterAssignments_O__mlv-GetClustrAssn-rec-dispid} * rec_sys_id：文字列。レコード sys_id。{#MLSolution-getClusterAssignments_O__mlv-GetClustrAssn-rec-sysid} * group_by： グループ化されている場合、このクラスターに関連付けられているセグメンテーションフィールドの名前。{#MLSolution-getClusterAssignments_O__mlv-getClusterInfo-returnsGrp} {#MLSolution-getClusterAssignments_O__ul_oz5_dwm_rhb} |
[表 : 6. 返される内容]

{#MLSolution-getClusterAssignments_O__table_u1q_hxt_rhb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_x_global_clustering");

    // configure optional parameters
    var options = {};
    options.group_by = 'network';
    options.cluster_id = '1';
    // returns top 3 results per cluster
    options.top_n_per_cluster = 3;

    var results = mlSolution.getClusterAssignments(options);

出力：

    [{"cluster_id":"1","rec_display_id":"Incident: INC0014483","rec_sys_id":"04e33e7adb401300864adfea5e961900","group_by":"network"},
     {"cluster_id":"1","rec_display_id":"Incident: INC0011133","rec_sys_id":"5bd23af2db401300864adfea5e96194d","group_by":"network"}]

## MLSolution - getClusterForRecord(GlideRecord now_GR) {#ariaid-title5}

クラスタリングソリューションのクラスター情報を取得します。
{#MLSolution-getClusterForRecord_GR__table_ak2_xcn_rhb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| now_GR | GlideRecord | 入力 GlideRecord の名前。 |
[表 : 7. パラメーター]

{#MLSolution-getClusterForRecord_GR__table_ak2_xcn_rhb} {#MLSolution-getClusterForRecord_GR__table_bk2_xcn_rhb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | レコードがクラスターに属する場合は、クラスターサマリー \[ml_cluster_summary\] テーブルの cluster_id。レコードがクラスターに属していない場合は、空の文字列が返されます。 |
[表 : 8. 返される内容]

{#MLSolution-getClusterForRecord_GR__table_bk2_xcn_rhb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("solution_name");
    var now_GR = new GlideRecord('incident');
    if (mlSolution.getCapability() == 'clustering') {
    var clusterId = mlSolution.getClusterForRecord(now_GR);
    }

## MLSolution - getClusterInfo(オブジェクト options) {#ariaid-title6}

指定されたクラスタリングソリューションの情報を取得します。。
{#MLSolution-getClusterInfo_O__table_ak2_xcn_rhb__entry__3}{#MLSolution-getClusterInfo_O__ml-cluster-create-xbl}

| 名前 | タイプ | 説明 |
|-|-|-|
| オプション | オブジェクト | オプション。返された結果を、クラスタリングソリューション内のグループとレベルで絞り込みます。 デフォルト：すべてのクラスターのクラスターメンバーシップを返します。 |
| options.group_by | 文字列 | オプション。クラスターメンバーシップ (assignment_group など) を取得するセグメンテーションフィールドを識別します。 このフィールドは、\[クラスタリング定義\] フォームの \[グループ化\] チェックボックスで提供されるオプションと同じグループ化を提供します。表示される情報は、\[テーブル\] フィールドで選択したテーブルによって異なります。詳細については、「 [クラスタリングソリューションの作成とトレーニング](https://www.servicenow.com/docs/access?context=create-clustering-solution&version=xanadu&pubname=xanadu-intelligent-experiences&ft:locale=en-US) 」を参照してください。 |
| options.cluster_id | 文字列 | オプション。クラスターサマリー \[ml_cluster_summary\] テーブルのトレーニング済みソリューションのクラスター ID。 |
[表 : 9. パラメーター]

{#MLSolution-getClusterInfo_O__table_ak2_xcn_rhb} {#MLSolution-getClusterInfo_O__table_bk2_xcn_rhb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | クラスター情報を含む JSON のアレイ (cluster_id の昇順)。 * cluster_id：文字列。クラスターのソリューション内の一意のクラスター番号。{#MLSolution-getClusterInfo_O__mlv-getClusterInfo-returnsID} * cluster_quality：文字列。0 ～ 100 の数値。数値が大きいほどクラスター密度が高いことを示します。{#MLSolution-getClusterInfo_O__mlv-getClusterInfo-returnsCQ} * cluster_size：文字列。クラスター内のレコードの数。{#MLSolution-getClusterInfo_O__mlv-getClusterInfo-returnsSize} * group_by： グループ化されている場合、このクラスターに関連付けられているセグメンテーションフィールドの名前。{#MLSolution-getClusterInfo_O__mlv-getClusterInfo-returnsGrp} * cluster_concept：文字列。頻度の降順によるクラスターを説明する単語のセット。{#MLSolution-getClusterInfo_O__mlv-getClusterInfo-returnsConcept} {#MLSolution-getClusterInfo_O__ul_oz5_tv5_rhb} |
[表 : 10. 返される内容]

{#MLSolution-getClusterInfo_O__table_bk2_xcn_rhb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_x_global_clustering");

    // configure optional parameters
    var options = {};
    options.group_by = 'network';
    options.cluster_id = 1;

    var results = mlSolution.getClusterInfo(options);

出力：

    [ {"cluster_id":"1","cluster_quality":"56.6","cluster_size":"46","group_by":"SLA","cluster_concept":"issue occur capacity ..."},
      {"cluster_id":"2","cluster_quality":"55.47","cluster_size":"75","group_by":"SLA","cluster_concept":"clone instance request ..."},
    ... ]

## MLSolution - getVersion() {#ariaid-title7}

アクティブなソリューションのバージョンを取得します。
{#MLSolution-getVersion__table_hrt_ngx_ggb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 11. パラメーター]

{#MLSolution-getVersion__table_hrt_ngx_ggb} {#MLSolution-getVersion__table_irt_ngx_ggb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | アクティブなソリューションのバージョン。 |
[表 : 12. 返される内容]

{#MLSolution-getVersion__table_irt_ngx_ggb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("solution_name");

    var solutionVersion = mlSolution.getVersion();

## MLSolution - isActive() {#ariaid-title8}

ソリューションがアクティブかどうかを判断します。
{#MLSolution-isActive__table_xzj_lgx_ggb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 13. パラメーター]

{#MLSolution-isActive__table_xzj_lgx_ggb} {#MLSolution-isActive__table_yzj_lgx_ggb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | ソリューションがアクティブかどうかを示すフラグ。 * true：ソリューションはアクティブである * false：ソリューションは非アクティブである {#MLSolution-isActive__ul_cnk_ltv_bkb} |
[表 : 14. 返される内容]

{#MLSolution-isActive__table_yzj_lgx_ggb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("solution_name");

    var isActive = mlSolution.isActive();

## MLSolution - predict(オブジェクト input, オブジェクト options) {#ariaid-title9}

GlideRecord またはキーと値のペアのアレイを指定して、予測サーバーから予測結果を取得します。
GlideRecord は反復子であるため、このメソッドを使用して複数の入力レコードを含む予測を呼び出すことができます。
{#MLSolution-predict_O_O__table_vv5_yfx_ggb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 入力 | オブジェクト | [GlideRecord](https://servicenow-prod.fluidtopics.net/UU8iPPWC0AAbYz713AvFjQ#c_GlideRecordAPI "GlideRecord API はデータベース操作に使用されます。") または、キーと値のペアとしてフィールド名と値を含む JSON オブジェクトのアレイ。 |
| オプション | オブジェクト | オプション。次のプロパティを持つ、 JSON のキーと値のペア。 * top_n：数値。指定されている場合、指定された予測の数までの上位の結果を返します{#MLSolution-predict_O_O__solution-prediction-topn} * apply_threshold：ブール。ソリューションのしきい値をチェックして結果セットに適用します。しきい値は、類似性のソリューションしきい値または分類のクラスレベルのしきい値です。デフォルト値は true です。{#MLSolution-predict_O_O__solution-prediction-thresh} * custom_results_filter：文字列。類似性ソリューションのみ。エンコードされたクエリを使用して結果が返される元になる許可されたセットを指定します。{#MLSolution-predict_O_O__solution-prediction-custom} {#MLSolution-predict_O_O__ul_eqd_tcs_ckb} |
[表 : 15. パラメーター]

{#MLSolution-predict_O_O__table_vv5_yfx_ggb} {#MLSolution-predict_O_O__table_khq_hgx_ggb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | sys_id または record_number でソートされた予測結果を含む JSON オブジェクト。 * predictedValue：文字列。予測結果を表す値。{#MLSolution-predict_O_O__ml-returnsVal} * predictedSysId：文字列。予測値の sys_id。結果は、情報が予測されている任意のテーブルから取得できます。{#MLSolution-predict_O_O__ml-returnsID} * confidence：数値。予測に関連付けられた信頼性の値。例：53.84。{#MLSolution-predict_O_O__ml-returnsConf} * threshold：数値。予測に関連付けられた構成済みのしきい値の値。{#MLSolution-predict_O_O__ml-returnsThrsh} * detailedResults：オブジェクト。類似性ソリューションのみ。一致するテキストインデックスに関する詳細を含む JSON のキーと値のペア。{#MLSolution-predict_O_O__ml-returnsDetR} {#MLSolution-predict_O_O__ul_fg2_vcs_ckb} |
[表 : 16. 返される内容]

{#MLSolution-predict_O_O__table_khq_hgx_ggb}  

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_incident_categorization");

    // single GlideRecord input
    var input = new GlideRecord("incident");
    input.get("0ef47232db801300864adfea5e961912");

    // configure optional parameters
    var options = {};
    options.top_n = 3;
    options.apply_threshold = false;

    var results = mlSolution.predict(input, options);
    // pretty print JSON results
    gs.print(JSON.stringify(JSON.parse(results), null, 2));

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_incident_categorization");

    // multiple GlideRecord input
    var input = new GlideRecord("incident");
    input.addQuery("sys_created_onONLast week@javascript:gs.beginningOfLastWeek()@javascript:gs.endOfLastWeek()");
    input.query();

    // configure optional parameters
    var options = {};
    options.top_n = 3;
    options.apply_threshold = false;

    var results = mlSolution.predict(input, options);
    // pretty print JSON results
    gs.print(JSON.stringify(JSON.parse(results), null, 2));

出力：

    {
        input_gr_sys_id1: [
                    {
                        predictedValue : xxx,
                        predictedSysId : xx0,
                        confidence : xxx,
                        threshold : xxx,
                        detailedResults : [.....]

                    }, 
                    {
                        predictedValue : yyy,
                        predictedSysId : xx1,
                        confidence : xxx,
                        threshold : xxx,
                        detailedResults : [.....]
                    }
            ],
        input_gr_sys_id2 : [
                    {
                        predictedValue : xxx,
                        predictedSysId : xx0,
                        confidence : xxx,
                        threshold : xxx,
                        detailedResults : [.....]

                    }, 
                ...
            ]
    }

    var mlSolution = sn_ml.MLSolutionFactory.getSolution("ml_incident_categorization");

    // key-value pairs input
    var input = [{"short_description":"my email is not working"}, 
    			{short_description:"need help with password"}];

    // configure optional parameters
    var options = {};
    options.top_n = 3;
    options.apply_threshold = false;

    var results = mlSolution.predict(input, options);
    // pretty print JSON results
    gs.print(JSON.stringify(JSON.parse(results), null, 2));


