Last active
January 29, 2016 16:43
-
-
Save ldacosta/5d14664c924265aebd26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////// | |
// Generic | |
trait Model[T1,T2] { | |
def train(t: List[(T1, T2)]): Unit // or Boolean? | |
def predict(t: T1): Set[(T2, Confidence)] | |
} | |
trait LinearModel[T1,T2] extends Model[T1,T2] { | |
private val m: MLLibLinearModel // -ish | |
} | |
trait Recommender[T1, T2, R] { | |
def m: Model[T1,T2] | |
def getRecommendations(t: T1): Set[(R, Confidence)] | |
} | |
///////////////////////////////// | |
// Specific to ProgramModel | |
type Contacts = Double | |
type Budget = Double | |
case class ProgramModel(m: MLLibLinearModel) extends LinearModel[(Date, Budget), Contacts] { | |
def train(t: List[((Date, Budget), Contacts)]): Unit = { | |
m.train { ... } // train a linear model with t | |
} | |
def predict(t: (Date, Budget)): Set[(Contacts, Confidence)] = { | |
// run m to generate Contacts out of the date and the budget | |
} | |
} | |
trait ProgramRecommendation | |
case class AugmentBudget(howMuch: Money) extends ProgramRecommendation | |
case class LowerBudget(howMuch: Money) extends ProgramRecommendation | |
case class ProgramRecommender(m: Model[((Date, Budget), Contacts)]) extends Recommender[(Date, Budget), Contacts, ProgramRecommendation] { | |
def getRecommendations(t: (Date, Budget)): Set[(ProgramRecommendation, Confidence)] = { | |
// run <m>, determine Recommendations | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment