module HLearn.Models.Classifiers.Common
where
import HLearn.Algebra
import HLearn.Models.Distributions
indicator :: (Num a) => Bool -> a
indicator b =
if b
then 1
else 0
bool2num :: (Num a) => Bool -> a
bool2num b =
if b
then 1
else 1
num2bool :: (Ord a, Num a) => a -> Bool
num2bool a =
if a<0
then False
else True
class Labeled dp where
type Label dp
type Attributes dp
getLabel :: dp -> Label dp
getAttributes :: dp -> Attributes dp
instance Labeled (label,attr) where
type Label (label,attr) = label
type Attributes (label,attr) = attr
getLabel = fst
getAttributes = snd
class
( Labeled (Datapoint model)
) => ProbabilityClassifier model
where
type ResultDistribution model
probabilityClassify :: model -> Attributes (Datapoint model) -> ResultDistribution model
class MarginClassifier model where
margin :: model -> Attributes (Datapoint model) -> (Ring model, Label (Datapoint model))
class
( Labeled (Datapoint model)
) => Classifier model
where
classify :: model -> Attributes (Datapoint model) -> Label (Datapoint model)
class (Classifier model, Ring model ~ Label (Datapoint model)) => Regression model
instance (Classifier model, Ring model ~ Label (Datapoint model)) => Regression model