ClassificationSolution - グローバル
ClassificationSolution API は、ストアで使用されるスクリプト可能なオブジェクトです予測インテリジェンス。
この API には 予測インテリジェンス プラグイン (com.glide.platform_ml) が必要です。この API は sn_ml 名前空間内で提供されます。
- DatasetDefinition API を使用してデータセットを作成します。
- オプション。Encoder API を使用してエンコーダーを構築します。
- コンストラクタ― を使用して、分類ソリューションオブジェクトを作成します。
- ClassificationSolutionStore - add() メソッドを使用して、ソリューションオブジェクトを分類ソリューションストアに追加します。
- submitTrainingJob() メソッドを使用してソリューションをトレーニングします。これにより、ClassificationSolutionVersion API を使用して管理できるオブジェクトのバージョンが作成されます。
- ClassificationSolutionVersion –predict() メソッドを使用して予測を取得します。
使用上のガイドラインについては、「 ML API の使用」を参照してください。
ClassificationSolution - ClassificationSolution(オブジェクト config)
分類のソリューションを作成します。
| 名前 | タイプ | 説明 |
|---|---|---|
| config | オブジェクト | の構成プロパティを含む JavaScript オブジェクト ソリューション。 |
| config.algorithmConfig | オブジェクト | アルゴリズム設定プロパティを含む JavaScript オブジェクト。 |
| config.algorithmConfig.algorithm | 文字列 | ソリューションをエンコードする方法。
可能な値:
|
| config.algorithmConfig.targetClassRecall | 文字列 | クラスリコールパラメーターを適用して、特定のクラスをバイアスするソリューションのトレーニングを操作します。形式は "<ClassName:RecallValue>" です。RecallValue はパーセンテージを表す 0 〜 100 の数値です。例えば、Email クラスでトレーニングするすべてのレコードについて、このソリューションパラメーターを 90% の精度に設定して適用するには、値を "Email:90"に設定します。 |
| config.dataset | オブジェクト | DatasetDefinition 名。 |
| config.domainName | 文字列 | オプション。このデータセットに関連付けられたドメイン名。「 ドメイン分離」および 予測インテリジェンス「」を参照してください。 デフォルト:現在のドメイン。例: |
| config.encoder | オブジェクト | オプション。このソリューションに割り当てるトレーニング済みのエンコーダーオブジェクト。「Encoder - Encoder(オブジェクト config)」を参照してください。 |
| config.groupByFieldName | 文字列 | オプション。レコードをグループ化して分類ソリューションを構築するために使用するフィールド名。 使用方法については、「 分類でのグループ化の使用」を参照してください。 |
| config.inputFieldNames | アレイ | 文字列としての入力フィールド名のリスト。モデルは、次のフィールドを使用して予測を行います。 |
| config.label | 文字列 | 予測タスクを識別します。 |
| config.minRowCount | 文字列 | オプション。トレーニング用のデータセットに必要なレコードの最小数。 デフォルト:10000 |
| config.predictedFieldName | 文字列 | 予測可能性についてトレーニングするフィールドを識別します。 |
| config.processingLanguage | 文字列 | オプション。2 文字の ISO 639-1 言語コード形式の処理言語。 デフォルト値:「en」 |
| config.stopwords | アレイ | オプション。language プロパティ設定に基づいて自動的に生成される文字列のプリセットリスト。詳細については、「 カスタムストップワードリストの作成」を参照してください。 デフォルト:英語のストップワード |
| config.trainingFrequency | 文字列 | モデルを再トレーニングする頻度。
可能な値:
|
次の例は、オブジェクトを作成して ClassificationSolution ストア。
var myData = new sn_ml.DatasetDefinition(
{
'tableName' : 'incident',
'fieldNames' : ['category', 'short_description', 'priority'],
'fieldDetails' : [
{
'name' : 'category',
'type' : 'nominal'
},
{
'name' : 'short_description',
'type' : 'text'
}],
'encodedQuery' : 'activeANYTHING'
});
var mySolution = new sn_ml.ClassificationSolution({
'label': "my solution definition",
'dataset' : myData,
'predictedFieldName' : 'category',
'inputFieldNames': ['short_description']
});
var myClassificationName = sn_ml.ClassificationSolutionStore.add(mySolution);
ClassificationSolution - cancelTrainingJob()
トレーニングのために送信されたソリューションオブジェクトのジョブをキャンセルします。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、既存のトレーニングジョブをキャンセルする方法を示しています。
var mySolution = sn_ml.ClassificationSolutionStore.get('ml_sn_global_global_classification');
mySolution.cancelTrainingJob();
ClassificationSolution - getActiveVersion()
アクティブな ClassificationSolutionVersion オブジェクト。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| オブジェクト | アクティブな ClassificationSolutionVersion オブジェクト。 |
次の例は、 ClassificationSolution ストアからアクティブなバージョンを取得し、そのトレーニングステータスを返す
var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');
gs.print(JSON.stringify(JSON.parse(mlSolution.getActiveVersion().getStatus()), null, 2));
出力:
{
"state": "solution_complete",
"percentComplete": "100",
"hasJobEnded": "true"
}
ClassificationSolution - getAllVersions()
分類のソリューションの のすべてのバージョンを取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| アレイ | ソリューションオブジェクトの既存のバージョン。関連項目 ClassificationSolutionVersion API。 |
次の例は、すべての ClassificationSolution バージョンオブジェクトを取得し、それらに対して getVersionNumber() および getStatus() ソリューションバージョンメソッドを呼び出す方法を示しています。
var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');
var mlSolutionVersions = mlSolution.getAllVersions();
for (i = 0; i < mlSolutionVersions.length; i++) {
gs.print("Version " + mlSolutionVersions[i].getVersionNumber() + " Status: " + mlSolutionVersions[i].getStatus() +"\n");
};
出力:
Version 3 Status: {"state":"solution_complete","percentComplete":"100","hasJobEnded":"true"}
Version 2 Status: {"state":"solution_complete","percentComplete":"100","hasJobEnded":"true"}
Version 1 Status: {"state":"solution_cancelled","percentComplete":"0","hasJobEnded":"true"}
ClassificationSolution - getLatestVersion()
ソリューション の最新バージョンを取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| オブジェクト | ClassificationSolutionVersion の最新バージョンに対応するオブジェクト a ClassificationSolution()。 |
次の例は、ソリューションの最新バージョンを取得して、トレーニングのステータスを返す方法を示しています。
var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');
gs.print(JSON.stringify(JSON.parse(mlSolution.getLatestVersion().getStatus()), null, 2));
出力:
{
"state": "solution_complete",
"percentComplete": "100",
"hasJobEnded": "true"
}
ClassificationSolution - getName()
ストアの操作に使用するオブジェクトの名前を取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| 文字列 | ソリューションオブジェクトの名前。 |
次の例は、 ClassificationSolution データセット情報を更新し、オブジェクトの名前を出力
// Update solution
var myIncidentData = new sn_ml.DatasetDefinition({
'tableName' : 'incident',
'fieldNames' : ['category', 'short_description', 'priority'],
'encodedQuery' : 'activeANYTHING'
});
var eligibleFields = JSON.parse(myIncidentData.getEligibleFields('classification'));
var myClassification = new sn_ml.ClassificationSolution({
'label': "my classification solution",
'dataset' : myIncidentData,
'inputFieldNames': eligibleFields['eligibleInputFieldNames'],
'predictedFieldName': 'category'
});
// update solution
sn_ml.ClassificationSolutionStore.update('ml_x_snc_global_global_my_solution_definition_4', myClassification);
// print solution name
gs.print('Solution Name: '+myClassification.getName());
出力:
Solution Name: ml_x_snc_global_global_my_solution_definition_4
ClassificationSolution - getProperties()
ソリューションオブジェクトプロパティを取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| オブジェクト | ClassificationSolutionStore のデータセットのコンテンツと ClassificationSolution() オブジェクトの詳細。 |
| <Object>.algorithmConfig | ソリューションをエンコードするメソッド。 データタイプ:オブジェクト |
| <Object>.algorithmConfig.algorithm | このソリューションをトレーニングするためのエンコーディングアルゴリズムの名前。 可能な値:
データタイプ:文字列。 |
| <Object>.algorithmConfig.targetClassRecall | 特定のクラスをバイアスするソリューションのトレーニングを操作するためのクラスリコールパラメーター。リコール値は、パーセンテージを表す 0 〜 100 の数値です。 データタイプ:文字列 |
| <Object>.datasetProperties | ソリューションに関連付けられた DatasetDefinition() オブジェクトのプロパティを一覧表示します。
データタイプ:オブジェクト |
| <Object>.datasetProperties.tableName | データセットのテーブルの名前。例:"tableName" : "Incident" データタイプ:文字列。 |
| <Object>.datasetProperties.fieldNames | 指定されたテーブルからの文字列としてのフィールド名のリスト。例:"fieldNames" : ["short_description", "priority"] データタイプ:アレイ。 |
| <Object>.datasetProperties.fieldNames.fieldDetails | フィールドプロパティを指定する JavaScript オブジェクトのリスト。
データタイプ:アレイ。 |
| <Object>.datasetProperties.fieldNames.fieldDetails.<object>.name | このデータセットを制限する情報のタイプを定義するフィールドの名前。 データタイプ:文字列。 |
| <Object>.datasetProperties.fieldDetails.<object>.type | 機械学習フィールドタイプ。 データタイプ:文字列。 |
| <Object>.datasetProperties.fieldDetails.encodedQuery | 標準の Glide 形式のエンコードされたクエリ文字列。「 エンコードされたクエリ文字列」を参照してください。 データタイプ:文字列。 |
| <Object>.domainName | このデータセットに関連付けられたドメイン名。「 ドメイン分離」および 予測インテリジェンス「」を参照してください。 データタイプ:文字列。 |
| <Object>.encoder | このソリューションに割り当てられるエンコーダーオブジェクト。「Encoder - Encoder(オブジェクト config)」を参照してください。 データタイプ:オブジェクト |
| <Object>.groupByFieldName | レコードをグループ化して分類ソリューションを構築するために使用するフィールド名。 データタイプ:文字列 |
| <Object>.inputFieldNames | 文字列としての入力フィールド名のリスト。モデルは、次のフィールドを使用して予測を行います。 データタイプ:文字列。 |
| <Object>.label | 予測タスクを識別します。
データタイプ:文字列。 |
| <Object>.name | システムによって割り当てられた名前。 データタイプ:文字列。 |
| <Object>.predictedFieldName | 予測可能性についてトレーニングするフィールドを識別します。 データタイプ:文字列。 |
| <Object>.processingLanguage | 2 文字の ISO 639-1 言語コード形式の処理言語。 データタイプ:文字列。 |
| <Object>.scope | オブジェクトスコープ。現在、有効な値は global のみです。データタイプ:文字列 |
| <Object>.stopwords | オプション。language プロパティ設定に基づいて自動的に生成される文字列のプリセットリスト。詳細については、「 カスタムストップワードリストの作成」を参照してください。 データタイプ:アレイ。 |
| <Object>.trainingFrequency | モデルを再トレーニングする頻度。 可能な値:
データタイプ:文字列。 |
次の例では、ストア内のソリューションオブジェクトのプロパティを取得します。
var mySolution = sn_ml.ClassificationSolutionStore.get('ml_sn_global_global_classification_solution');
gs.print(JSON.stringify(JSON.parse(mySolution.getProperties()), null, 2));
*** Script: {
"datasetProperties": {
"tableName": "incident",
"fieldNames": [
"category",
"short_description",
"priority",
"assignment_group.name"
],
"fieldDetails": [
{
"name": "category",
"type": "nominal"
},
{
"name": "short_description",
"type": "text"
}
]
},
"domainName": "global",
"inputFieldNames": [
"short_description"
],
"label": "my solution definition",
"name": "ml_x_snc_global_global_my_solution_definition_26",
"predictedFieldName": "category",
"processingLanguage": "en",
"scope": "global",
"stopwords": [
"Default English Stopwords"
],
"trainingFrequency": "run_once"
}ClassificationSolution - getVersion(文字列 version)
指定されたバージョン番号を使用します。ソリューションを取得します。
| 名前 | タイプ | 説明 |
|---|---|---|
| version | 文字列 | ソリューションの既存のバージョン番号。 |
| タイプ | 説明 |
|---|---|
| オブジェクト | ClassificationSolutionVersion API メソッドを呼び出すことができる ClassificationSolution() オブジェクトの指定されたバージョン。 |
次の例は、バージョン番号別にソリューションのトレーニングステータスを取得する方法を示しています。
var mlSolution = sn_ml.ClassificationSolutionStore.get('ml_x_snc_global_global_classification');
gs.print(JSON.stringify(JSON.parse(mlSolution.getVersion('1').getStatus()), null, 2));
出力:
{
"state": "solution_complete",
"percentComplete": "100",
"hasJobEnded": "true"
}
ClassificationSolution - setActiveVersion(文字列 version)
ストア内の指定されたバージョンのソリューションをアクティブ化します。
| 名前 | タイプ | 説明 |
|---|---|---|
| version | 文字列 | アクティブ化する ClassificationSolution() オブジェクトバージョンの名前。 このバージョンをアクティブ化すると、他のバージョンが非アクティブになります。 |
| タイプ | 説明 |
|---|---|
| なし |
次の例は、ストア内のソリューションバージョンを有効にする方法を示しています。
sn_ml.ClassificationSolution.setActiveVersion("ml_incident_categorization");
ClassificationSolution - submitTrainingJob()
トレーニングジョブを送信します。
| 名前 | タイプ | 説明 |
|---|---|---|
| なし |
| タイプ | 説明 |
|---|---|
| オブジェクト | ClassificationSolutionVersion ClassificationSolution に対応するオブジェクト トレーニング対象 |
次の例は、データセットを作成してソリューションに適用し、ソリューション をストアに追加して、トレーニングジョブを送信する方法を示しています。
// Create a dataset
var myData = new sn_ml.DatasetDefinition({
'tableName' : 'incident',
'fieldNames' : ['assignment_group', 'short_description', 'description'],
'encodedQuery' : 'activeANYTHING'
});
// Create a solution
var mySolution = new sn_ml.ClassificationSolution({
'label': "my solution definition",
'dataset' : myData,
'predictedFieldName' : 'assignment_group',
'inputFieldNames':['short_description']
});
// Add the solution to the store to later be able to retrieve it.
var my_unique_name = sn_ml.ClassificationSolutionStore.add(mySolution);
// Train the solution - this is a long running job
var myClassifierVersion = mySolution.submitTrainingJob();