Skip to content

Commit

Permalink
QPAMetric trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Yip committed Mar 22, 2015
1 parent 7c293fb commit cb7e3bc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions core/src/main/scala/io/prediction/controller/Metric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ extends Serializable {
* @group Evaluation
*/
abstract class AverageMetric[EI, Q, P, A]
extends Metric[EI, Q, P, A, Double] {
extends Metric[EI, Q, P, A, Double]
with QPAMetric[Q, P, A, Double] {
/** Implement this method to return a score that will be used for averaging
* across all QPA tuples.
*/
Expand Down Expand Up @@ -86,7 +87,8 @@ extends Metric[EI, Q, P, A, Double] {
* @group Evaluation
*/
abstract class SumMetric[EI, Q, P, A]
extends Metric[EI, Q, P, A, Double] {
extends Metric[EI, Q, P, A, Double]
with QPAMetric[Q, P, A, Double] {
/** Implement this method to return a score that will be used for summing
* across all QPA tuples.
*/
Expand Down Expand Up @@ -117,7 +119,8 @@ extends Metric[EI, Q, P, A, Double] {
* @group Evaluation
*/
abstract class OptionAverageMetric[EI, Q, P, A]
extends Metric[EI, Q, P, A, Double] {
extends Metric[EI, Q, P, A, Double]
with QPAMetric[Q, P, A, Option[Double]] {
/** Implement this method to return a score that will be used for averaging
* across all QPA tuples.
*/
Expand Down Expand Up @@ -149,4 +152,8 @@ extends Metric[EI, Q, P, A, Double] {
}



/** Trait for metric which returns a score based on Query, PredictedResult, and ActualResult.
*/
trait QPAMetric[Q, P, A, R] {
def calculate(q: Q, p: P, a: A): R
}

0 comments on commit cb7e3bc

Please sign in to comment.