MLPredictor - 전역 (사용하지 않음)
MLPredictor API는 예측을 위한 예측 인텔리전스 유틸리티 메서드를 제공합니다.
MLPredictor API에는 플러그인(com.glide.platform_ml)이 예측 인텔리전스 필요하며 sn_ml 네임스페이스 내에서 제공됩니다.
이 클래스에는 입력 데이터에서 예측 결과를 가져오는 데 필요한 모든 메서드가 포함되어 있습니다.
MLPredictor - MLPredictor()
새 MLPredictor 개체를 인스턴스화합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
다음 예제에서는 비즈니스 규칙에서 MLPredictor 개체를 사용하여 예측 후 최종 값을 기록하는 방법을 보여 줍니다.
function executeRule(current, previous /*null when async*/) {
var predictor = new MLPredictor();
predictor.recordFinalValuesInPredictionResults(current, "On close");
}(current, previous);
MLPredictor - applyPrediction(GlideRecord now_GR, 배열 솔루션)
지정된 솔루션 배열의 예측 값을 지정된 기록으로 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 예측 솔루션 배열을 적용할 기록입니다. |
| 솔루션 | 배열 | GlideRecord와 연결된 지정된 솔루션 객체입니다. |
| 유형 | 설명 |
|---|---|
| void |
다음 예시에서는 비즈니스 규칙에서 applyPrediction() 메서드를 사용하는 방법을 보여줍니다.
(function executeRule(current, previous /*null when async*/) {
var mlPredictor = new MLPredictor();
//Get the list of active solutions for the glide record table
var solutions = mlPredictor.findActiveSolutionsForRecord(current);
//Run prediction and apply predicted value to the record
mlPredictor.applyPrediction(current, solution);
})(current, previous);
MLPredictor - applyPredictionForSolution(GlideRecord now_GR, 객체 솔루션)
지정된 분류 솔루션의 예측 값을 지정된 GlideRecord에 적용합니다.
GlideRecord의 각 솔루션에 대해 이 메서드를 호출하여 결과를 예측하고 인시던트의 필드 값을 해당 결과로 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 예측을 실행하고 결과를 적용할 값을 포함하는 GlideRecord 객체입니다. |
| 솔루션 | 객체 | 실행할 분류 솔루션 객체입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | 예측 성공 시 True, 그렇지 않으면 오류. |
이 템플릿을 사용하려면 인시던트 기반 예측(템플릿) 비즈니스 규칙을 복사하고, 새 기록을 활성으로 만들고, 주석이 있는 지침에 따라 solutionNames 변수를 초기화합니다.
(function executeRule(current, previous /*null when async*/) {
var solutionNames = ["solution1", "solution2", ...];
/* For domain separation (MSP) use case */
// var solutionNames;
// if (current.sys_domain == "A")
// solutionNames = ["solution_A1", "solution_A2", ...];
// else if (current.sys_domain == "B")
// solutionNames = ["solution_B1", "solution_B2", ...];
// else
// ...
var predictor = new MLPredictor();
var info = "";
solutionNames.forEach(function(solutionName) {
var solution = predictor.findActiveSolution(solutionName);
if (!solution)
return;
/* The next line of code does the prediction and updates the current record. */
predictor.applyPredictionForSolution(current, solution);
/* If no prediction is done, do not build the prediction info message. */
if (!predictor.applyPredictionForSolution(current, solution))
return;
/* If user doesn't have 'itil' role, we don't build prediction info message. */
if (!gs.hasRole('itil'))
return;
/* Building prediction info message */
var fieldName = solution.getPredictedField();
var fieldLabel = current.getElement(fieldName).getED().getLabel();
var predictedDisplayValue = current.getDisplayValue(fieldName);
var msg = gs.getMessage("Predicted {0} for {1}.", [predictedDisplayValue, fieldLabel]);
if (info.length > 0)
info += " ";
info += msg;
});
/* Print out prediction info message on screen. */
if (info.length > 0) {
var incidentUrl = "<a href='"+current.getLink()+"'>"+current.number+":</a>";
gs.addInfoMessage(incidentUrl + " " + info);
}
})(current, previous);
MLPredictor - findActiveSolution(String solutionName)
솔루션 개체를 가져옵니다.
이 메서드는 ml_solution 정의와 솔루션이 활성 상태인 경우에만 솔루션을 반환합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| solutionName | 문자열 | ml_solution 기록의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 객체 | ml_solution 정의 및 솔루션이 활성 상태이면 지정된 solutionName 에 대한 솔루션 객체이고, 그렇지 않으면 null입니다. |
이 예제에서는 하드 코딩된 값을 사용하여 지정된 기계 학습 모델에 전달합니다. 결과 및 신뢰도 변수를 사용하여 값 또는 기타 비즈니스 논리를 설정할 수 있습니다.
var solutionName = 'ml_incident_assignment';
var shortDescriptionValue = "Unable to connect!"
var input = {
short_description : shortDescriptionValue
};
var MLP = new MLPredictor();
var solution = MLP.findActiveSolution(solutionName);
var predictedOutcome = solution.predictText(input);
var outcome = predictedOutcome.predictedValue();
var confidence = predictedOutcome.confidence();
gs.info("Predicted value: " + outcome)
gs.info("Confidence: " + confidence)
출력:
DxC_ML:
******* Finished Prediction********* *** Script: Predicted value: Software *** Script:
Confidence: 80.78079080096245
MLPredictor - findActiveSolutionsForRecord(GlideRecord now_GR)
지정된 GlideRecord의 테이블에 대한 활성 솔루션을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 활성 솔루션 객체를 수집할 GlideRecord입니다. |
| 유형 | 설명 |
|---|---|
| 배열 | 지정된 레코드가 있는 테이블과 연결된 활성 솔루션 객체의 배열입니다. |
이 스크립트는 GlideRecord(예: 인시던트)를 전달하고 GlideRecord에 대한 모든 솔루션을 처리하여 각각에 대한 값을 반환합니다.
/* This is only to get a hard-coded GR */
var current = new GlideRecord('incident');
current.get('965c9e5347c12200e0ef563dbb9a7156');
var predictor = new MLPredictor();
var solutions = predictor.findActiveSolutionsForRecord(current);
solutions.forEach(function(solution) {
var outcome = solution.predict(current);
/* Use this to set the field to the predicted value in the GlideRecord */
var fieldName = solution.getPredictedField();
current[fieldName] = outcome.predictedValue();
current.update();
gs.info("Predicted value: " + outcome.predictedValue())
gs.info("Confidence: " + outcome.confidence())
});
출력(할당 그룹 예측):
DxC_ML: ******* Finished Prediction*********
*** Script: Predicted value: Software *** Script: Confidence:
99.74530683715315
출력(범주 예측):
DxC_ML:
******* Finished Prediction********* *** Script: Predicted value: Software *** Script:
Confidence: 98.7172805135524
MLPredictor - getPredictedValue(객체 솔루션, 객체 결과)
지정된 예측 결과에 따라 지정된 솔루션에 대한 예측 값을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 솔루션 | 객체 | 예측 값을 얻을 솔루션입니다. |
| 결과 | 객체 | 지정된 솔루션에 대한 예측 결과 결과(var outcome = solution.predict(now_GR)). |
| 유형 | 설명 |
|---|---|
| 문자열 | 예측의 지정된 결과에 따라 지정된 솔루션에 대한 예측 값입니다. |
| 영 | 예측 신뢰도가 임계치를 충족하지 않는 경우 null을 반환합니다. |
MLPredictor - getPredictions(GlideRecord now_GR, 객체 솔루션, 객체 옵션)
지정된 솔루션에 대한 예측을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 예측할 GlideRecord입니다. |
| 솔루션 | 객체 | 실행할 솔루션 객체입니다. |
| 옵션 | 객체 | 다음 속성이 있는 선택적 JSON 객체 키 값 쌍:
|
| 유형 | 설명 |
|---|---|
| 배열 | 예측 결과 객체의 배열 |
다음 예에서는 지정된 솔루션을 호출하고 해당 솔루션에 대해 예측을 실행합니다.
function printOutcomeArr(outcomeArr) {
gs.print('################## Results ##################');
for (var i=0; i<outcomeArr.length; i++) {
var outcome = outcomeArr[i];
gs.print((i+1) + ' : ' + outcome.predictedValue() + ', ' + outcome.predictedValueSysId() + ', ' + outcome.confidence());
}
}
var solutionName = 'ml_x_snc_global_prop_flip_test';
var predictor = new MLPredictor();
var solution = predictor.findActiveSolution(solutionName);
var now_GR = new GlideRecord('incident');
now_GR.get('1c741bd70b2322007518478d83673af3');
var options = {};
options.top_n = '10'; // top_n is an integer between 1 and 1000
options.apply_threshold = false; // Value can be set to true or false
printOutcomeArr(predictor.getPredictions(now_GR, solution, options));
MLPredictor - isClassificationSolution(객체 솔루션)
솔루션 객체가 분류 유형인지 식별합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 솔루션 | 객체 | ML 솔루션의 이름입니다. |
| 유형 | 설명 |
|---|---|
| 부울 | 입력 솔루션이 분류 유형이면 true를 반환하고 그렇지 않으면 false를 반환합니다. |
var isClassificationSolution = this.isClassificationSolution(solution);
//classification solution each class has different threshold
//therefore needs to get all the results from ml engine
if (applyThreshold && isClassificationSolution) {
var maxClassificationTopN = 50;
outcomeArr = solution.predictTopN(now_GR, maxClassificationTopN);
}
else {
outcomeArr = solution.predictTopN(now_GR, topN);
}
if (outcomeArr === null) {
//instead of returning null returning empty array
return [];
}
MLPredictor - isSimilaritySolution(객체 솔루션)
솔루션 객체가 유사성 유형인지 식별합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 솔루션 | 객체 | ML 솔루션의 이름입니다. 예를 들어 ml_incident_categorization. |
| 유형 | 설명 |
|---|---|
| 부울 | 입력 솔루션이 유사성 유형이면 true를 반환하고 그렇지 않으면 false를 반환합니다. |
MLPredictor - outcome.confidence()
예측 값의 신뢰도를 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 예측의 예상 정확도(백분율)입니다. 예: 53.84615375762915 |
var MLP = new MLPredictor();
var solution = MLP.findActiveSolution(solutionName);
var predictedOutcome = solution.predictText(input);
var outcome = predictedOutcome.predictedValue();
var confidence = predictedOutcome.confidence();
gs.info("Predicted value: " + outcome)
gs.info("Confidence: " + confidence)
MLPredictor - outcome.predictedValue()
MLPredictor 결과 객체에서 예측 값을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | Outcome 객체의 예측 값입니다. |
var MLP = new MLPredictor();
var solution = MLP.findActiveSolution(solutionName);
var predictedOutcome = solution.predictText(input);
var outcome = predictedOutcome.predictedValue();
var confidence = predictedOutcome.confidence();
gs.info("Predicted value: " + outcome)
gs.info("Confidence: " + confidence)
MLPredictor - outcome.predictedValueSysId()
예측 값의 sys_id 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 예측 값 sys_id. |
function printOutcomeArr(outcomeArr) {
gs.print('################## Results ##################');
for (var i=0; i<outcomeArr.length; i++) {
var outcome = outcomeArr[i];
gs.print((i+1) + ' : ' + outcome.predictedValue() + ', ' + outcome.predictedValueSysId() + ', ' + outcome.confidence());
}
MLPredictor - recordFinalValuesInPredictionResults(GlideRecord now_GR, 문자열 이유)
최종 예측 결과 값을 선택적으로 지정된 이유와 함께 지정된 GlideRecord로 설정합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 최종 예측 결과 값을 설정할 GlideRecord입니다. |
| 이유 | 문자열 | 옵션입니다. 결과를 적용하는 이유. |
| 유형 | 설명 |
|---|---|
| void |
다음 예에서 recordFinalValuesInPredictionResults() 메서드는 인시던트가 종결될 때 호출됩니다.
(function executeRule(current, previous /*null when async*/) {
var predictor = new MLPredictor();
predictor.recordFinalValuesInPredictionResults(current, "On close");
})(current, previous);
MLPredictor - solution.getCapability()
교육된 솔루션의 역량 정보를 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 교육된 솔루션의 정의 ID 및 버전입니다. 그렇지 않으면 오류 메시지가 표시됩니다. |
MLPredictor - solution.getName()
예측에 사용되는 솔루션의 이름을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 예측에 사용할 솔루션의 이름입니다. 예: ml_incident_categorization |
MLPredictor - solution.getPredictedField()
솔루션의 예측 값을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 솔루션의 예측 출력 필드 값 |
/* Get a hard-coded GR */
var current = new GlideRecord('incident');
current.get('965c9e5347c12200e0ef563dbb9a7156');
var predictor = new MLPredictor();
var solutions = predictor.findActiveSolutionsForRecord(current);
solutions.forEach(function(solution) {
var outcome = solution.predict(current);
/* Use this to set the field to the predicted value in the GlideRecord */
var fieldName = solution.getPredictedField();
current[fieldName] = outcome.predictedValue();
current.update();
gs.info("Predicted value: " + outcome.predictedValue())
gs.info("Confidence: " + outcome.confidence())
});
MLPredictor - solution.getThreshold(String className)
솔루션 임계치를 가져옵니다.
임계치는 최소 예측 정확도를 반영하는 백분율을 나타냅니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| className | 문자열 | 솔루션 출력 필드의 지정된 범주 값 |
| 유형 | 설명 |
|---|---|
| 번호 | 임계치 값은 0에서 100 사이의 백분율로 표시됩니다. |
MLPredictor - solution.getVersion()
활성 솔루션의 버전을 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 문자열 | 활성 솔루션의 버전 |
MLPredictor - solution.isActive()
지정된 솔루션이 활성 상태인지 여부를 확인합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 솔루션이 활성 상태이면 True, 그렇지 않으면 False입니다. |
MLPredictor - solution.predict(GlideRecord now_GR, 객체 임계치)
솔루션 예측 결과를 결과 객체로 가져옵니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 솔루션 입력 테이블의 GlideRecord |
| 임계치 | 객체 | 임계값(유사성에 대한 솔루션 수준 임계치, 분류에 대한 클래스 수준 임계치) |
| 유형 | 설명 |
|---|---|
| 객체 | 지정된 솔루션의 예측 결과 결과(var outcome = solution.predict(now_GR)) |
solutions.forEach(function(solution) {
var outcome = solution.predict(current);
/* Use this to set the field to the predicted value in the GlideRecord
var fieldName = solution.getPredictedField();
current[fieldName] = outcome.predictedValue();
current.update();
*/
gs.info("Predicted value: " + outcome.predictedValue())
gs.info("Confidence: " + outcome.confidence())
});
MLPredictor - solution.predictTopN(GlideRecord now_GR, 객체 topN)
예상되는 예측 수까지 결과 객체 목록을 반환합니다. 최대 1,000개의 예측을 수행합니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| now_GR | GlideRecord | 솔루션의 GlideRecord |
| topN | 객체 | 예상 예측 수, 1,000을 초과하는 숫자는 1,000개의 결과를 반환합니다. |
| 유형 | 설명 |
|---|---|
| 배열 | GlideRecord, 임계치, 시스템 ID 및 예상 예측 수(topN 객체)를 포함하는 배열의 결과 객체 목록 |
var isClassificationSolution = this.isClassificationSolution(solution);
//classification solution each class has different threshold
//therefore needs to get all the results from ml engine
if (applyThreshold && isClassificationSolution) {
var maxClassificationTopN = 50;
outcomeArr = solution.predictTopN(now_GR, maxClassificationTopN);
}
else {
outcomeArr = solution.predictTopN(now_GR, topN);
}
if (outcomeArr === null) {
//instead of returning null returning empty array
return [];
}