AWS Javascript SDK PersonalizeRuntime getPersonalizedRanking does not return scores

0

According to the documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/PersonalizeRuntime.html#getPersonalizedRanking-property getPersonalizedRanking should return an array of objects that include both the itemId and score. When I use this function I only get the item ids, and no scores. Running this on the console gives me the same order of item ids and also includes the scores.

Is there something I'm missing or is this potentially a bug in the javascript sdk?

Here are my params:

{
  campaignArn: "removed",
  inputList: [
    "12-7-53",
    "170-7-53",
    "883-7-53",
  ],
  userId: "1317",
  context: {
  },
}

And the repsonse:

{
  personalizedRanking: [
    {
      itemId: "883-7-53",
    },
    {
      itemId: "170-7-53",
    },
    {
      itemId: "12-7-53",
    },
  ],
}
ksach
질문됨 일 년 전194회 조회
1개 답변
0
수락된 답변

I was able to print out the scores for GetPersonalizedRanking with AWS SDK JavaScript version 2.1404.0 and Node version 20.3.1, I ran the code below in my local environment:

const AWS = require('aws-sdk')

AWS.config.update({
  accessKeyId: 'INSERT-ACCESS-KEY',
  secretAccessKey: 'INSERT-SECRET-KEY',
  region: "us-east-1"
})

const personalize = new AWS.PersonalizeRuntime();

var params = {
  campaignArn: "arn:aws:personalize:us-east-1:account:campaign/example-campaign-name",
  inputList: ['257', '201', '495', '399', '184', '919', '222', '227', '450', '151', '373', '380'],
  userId: '2', 
  context: {} 
};

personalize.getPersonalizedRanking(params, (err,data) => {
  if(err){
    console.log(err);
  }else{
    console.log(JSON.stringify(data.personalizedRanking));
    const rankedItems = data.personalizedRanking.map  ((item) => item.itemId);
    console.log("OUTPUT " + rankedItems);
  }
});

I then received an output with the scores, below is an example:

{
    "itemId": "495",
    "score": 0.988938,
    "promotionName": null
}

I suggest checking the SDK and Node versions that you are using and try the versions I have used here to see if the scores will appear in the output. But should you still face an issue of scores being excluded in the response, then I would suggest raising a case with AWS Premium Support [1] for further troubleshooting to understand why the scores are not being passed.

I hope this helps.

Reference:

[1] https://aws.amazon.com/premiumsupport/faqs/

AWS
답변함 일 년 전
  • Thank you. It was indeed the sdk version.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠