Skip to content

Commit

Permalink
CoreML itemSimilarityRecommender support (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Dec 20, 2019
1 parent 45136c3 commit 972b879
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/coreml-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,20 @@
"category": "Normalization",
"description": "A layer that performs mean variance normalization, along axis = -3."
}
},
{
"name": "itemSimilarityRecommender",
"schema": {
"inputs": [
{ "name": "item" },
{ "name": "numRecommendations" },
{ "name": "itemRestriction" },
{ "name": "itemExclusion" }
],
"outputs": [
{ "name": "recommendedItemList" },
{ "name": "recommendedItemScore" }
]
}
}
]
11 changes: 11 additions & 0 deletions src/coreml.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ coreml.Graph = class {
this._updateClassifierOutput(group, model.kNearestNeighborsClassifier);
return 'kNearestNeighborsClassifier';
}
else if (model.itemSimilarityRecommender) {
const itemSimilarityRecommenderParams = {
itemStringIds: model.itemSimilarityRecommender.itemStringIds.vector,
itemItemSimilarities: model.itemSimilarityRecommender.itemItemSimilarities
}
this._createNode(scope, group, 'itemSimilarityRecommender', null,
itemSimilarityRecommenderParams,
model.description.input.map((feature) => feature.name),
model.description.output.map((feature) => feature.name));
return 'itemSimilarityRecommender'
}
else if (model.customModel) {
this._createNode(scope, group, 'customModel', null,
{ className: model.customModel.className, parameters: model.customModel.parameters },
Expand Down
7 changes: 7 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,13 @@
"format": "Core ML v1",
"link": "https://github.com/tf-coreml/tf-coreml/issues/252"
},
{
"type": "coreml",
"target": "MovieRecommender.mlmodel",
"source": "https://github.com/anupamchugh/iowncode/blob/master/CoreMLRecommender/CoreMLRecommender/MovieRecommender.mlmodel?raw=true",
"format": "Core ML v4",
"link": "https://github.com/anupamchugh/iowncode/tree/master/CoreMLRecommender"
},
{
"type": "coreml",
"target": "NamesDT.mlmodel",
Expand Down

0 comments on commit 972b879

Please sign in to comment.