Skip to content

Commit

Permalink
Merge branch 'livedoc' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Jul 19, 2017
2 parents 96d4c54 + 83f5ef7 commit c903de9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions docs/manual/source/templates/similarproduct/dase.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ case class Query(
categories: Option[Set[String]],
whiteList: Option[Set[String]],
blackList: Option[Set[String]]
) extends Serializable
)
```

The `PredictedResult` case class defines the format of **predicted result**,
Expand All @@ -55,12 +55,12 @@ with:
```scala
case class PredictedResult(
itemScores: Array[ItemScore]
) extends Serializable
)

case class ItemScore(
item: String,
score: Double
) extends Serializable
)
```

Finally, `SimilarProductEngine` is the *Engine Factory* that defines the
Expand Down Expand Up @@ -531,27 +531,27 @@ INFO: You can easily modify `isCandidate()` checking or `whiteList` generation i
val topScores = getTopN(filteredScore, query.num)(ord).toArray

val itemScores = topScores.map { case (i, s) =>
new ItemScore(
ItemScore(
item = model.itemIntStringMap(i),
score = s
)
}

new PredictedResult(itemScores)
PredictedResult(itemScores)
}
```

Note that the item IDs in top N results are the `Int` indices. You map them back to `String` with `itemIntStringMap` before they are returned:

```scala
val itemScores = topScores.map { case (i, s) =>
new ItemScore(
ItemScore(
item = model.itemIntStringMap(i),
score = s
)
}

new PredictedResult(itemScores)
PredictedResult(itemScores)
```

PredictionIO passes the returned `PredictedResult` object to *Serving*.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class Serving
.take(query.num)
.map { case (k,v) => ItemScore(k, v) }

new PredictedResult(combined)
PredictedResult(combined)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Modify how to create the ItemScore object using the properties.
val itemScores = topScores.map { case (i, s) =>
// MODIFIED
val it = model.items(i)
new ItemScore(
ItemScore(
item = model.itemIntStringMap(i),
title = it.title,
date = it.date,
Expand Down

0 comments on commit c903de9

Please sign in to comment.