org.square.qa.utilities.constructs
Class Models.RaykarModel

java.lang.Object
  extended by org.square.qa.utilities.constructs.Models.RaykarModel
All Implemented Interfaces:
AlgorithmInterface<TypeWID,TypeQ,TypeR>, ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>
Enclosing class:
Models<TypeWID,TypeQ,TypeR>

public class Models.RaykarModel
extends Object
implements ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>


Field Summary
protected  Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combinedEstLabels
           
protected  Map<TypeQ,TypeR> goldStandard
           
protected  TreeSet<TypeR> responseCategories
           
protected  Map<TypeQ,TypeR> tuneGT
           
 boolean useClassPrior
           
 boolean useWorkerPrior
           
protected  Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap
           
protected  Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapGold
           
protected  Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapTune
           
 
Constructor Summary
Models.RaykarModel()
           
 
Method Summary
 Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> getCombinedEstLabels()
          Get computed/partially-computed results
 Map<TypeQ,TypeR> getGoldStandard()
          Get ground truth question response pairs from the gold partition
 Pair<Double,Double> getPosClassBetaParam()
          Get positive class Beta distribution parameters
 TypeR getPositiveClass()
          Get Positive class
 TreeSet<TypeR> getResponseCategories()
          Get valid response categories
 Map<TypeQ,TypeR> getTuneGT()
          Get ground truth question response pairs from the tune partition
 Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> getWorkerPriors()
          Get worker priors
 Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMap()
          Get all responses stored for each worker
 Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMapGold()
          Get worker responses from the Gold partition
 Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMapTune()
          Get worker responses from the Tune partition
 boolean hasCombinedEstLabels()
          Checks if results are computed
 boolean hasGoldStandard()
          Checks if gold standard is used by the algorithm (supervised)
 boolean hasPosClassBetaParam()
          Check if positive class Beta distribution is set
 boolean hasPositiveClass()
          Check for Postive Class
 boolean hasResponseCategories()
          Checks for presence of response categories
 boolean hasTuneGT()
          Checks if ground truth for tune partition is used by the algorithm (lightly-supervised)
 boolean hasWorkerPriors()
          Checks if worker priors are supported
 boolean hasWorkersMap()
          Checks for presence of worker responses from the evaluation partition
 boolean hasWorkersMapGold()
          Checks for presence of worker responses from the gold partition
 boolean hasWorkersMapTune()
          Checks for presence of worker responses from the tune partition
 boolean isSemiSupervisedModel()
          Checks if algorithm is configured to run with 'light-supervision'
 boolean isSupervisedModel()
          Checks if algorithm is configured to run with 'supervision'
 boolean isUnsupervisedModel()
          Checks if algorithm is configured to run 'unsupervised'
 void setCombinedEstLabels(Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combinedEstLabels)
          Load computed/partially-computed results
 void setGoldStandard(Map<TypeQ,TypeR> goldStandard)
          Set ground truth question response pairs from the gold partition
 void setPosClassBetaParam(Pair<Double,Double> posClassBetaParam)
          Set positive class Beta distribution parameters
 void setPositiveClass(TypeR positiveClass)
          Set positive class
 void setResponseCategories(TreeSet<TypeR> responseCategories)
          Set response categories
 void setTuneGT(Map<TypeQ,TypeR> tuneGT)
          Set ground truth question response pairs from the tune partition
 void setWorkerPriors(Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> workerPriors)
          Set worker priors
 void setWorkersMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
          Set responses to questions for each worker
 void setWorkersMapGold(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapGold)
          Set worker responses from the Gold partition
 void setWorkersMapTune(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapTune)
          Set worker responses from the Tune partition
 void updateClassPriorParam(Pair<Double,Double> posClassBetaParam)
          Update positive class prior
 void updateWorkerPriors(Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> workerPriors)
          Update worker priors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.square.qa.algorithms.AlgorithmInterface
getCombinedEstLabels, getGoldStandard, getResponseCategories, getTuneGT, getWorkersMap, getWorkersMapGold, getWorkersMapTune, hasCombinedEstLabels, hasGoldStandard, hasResponseCategories, hasTuneGT, hasWorkersMap, hasWorkersMapGold, hasWorkersMapTune, setCombinedEstLabels, setGoldStandard, setResponseCategories, setTuneGT, setWorkersMap, setWorkersMapGold, setWorkersMapTune
 

Field Detail

useClassPrior

public boolean useClassPrior

useWorkerPrior

public boolean useWorkerPrior

workersMap

protected Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap

responseCategories

protected TreeSet<TypeR> responseCategories

workersMapTune

protected Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapTune

workersMapGold

protected Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapGold

tuneGT

protected Map<TypeQ,TypeR> tuneGT

goldStandard

protected Map<TypeQ,TypeR> goldStandard

combinedEstLabels

protected Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combinedEstLabels
Constructor Detail

Models.RaykarModel

public Models.RaykarModel()
Method Detail

isUnsupervisedModel

public boolean isUnsupervisedModel()
Description copied from interface: ExtendedAlgorithmInterface
Checks if algorithm is configured to run 'unsupervised'

Specified by:
isUnsupervisedModel in interface ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if model is configured to estimate labels without supervision

isSemiSupervisedModel

public boolean isSemiSupervisedModel()
Description copied from interface: ExtendedAlgorithmInterface
Checks if algorithm is configured to run with 'light-supervision'

Specified by:
isSemiSupervisedModel in interface ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if model is configured to estimate labels with light-supervision

isSupervisedModel

public boolean isSupervisedModel()
Description copied from interface: ExtendedAlgorithmInterface
Checks if algorithm is configured to run with 'supervision'

Specified by:
isSupervisedModel in interface ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if model is configured to estimate labels with supervision

hasWorkerPriors

public boolean hasWorkerPriors()
Description copied from interface: ExtendedAlgorithmInterface
Checks if worker priors are supported

Specified by:
hasWorkerPriors in interface ExtendedAlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if worker priors are supported

getWorkerPriors

public Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> getWorkerPriors()
Get worker priors

Returns:
a Map from workers to priors

setWorkerPriors

public void setWorkerPriors(Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> workerPriors)
Set worker priors

Parameters:
workerPriors - is a Map from workers to priors

hasPosClassBetaParam

public boolean hasPosClassBetaParam()
Check if positive class Beta distribution is set

Returns:
true is Beta parameters are available

getPosClassBetaParam

public Pair<Double,Double> getPosClassBetaParam()
Get positive class Beta distribution parameters

Returns:
a Pair of Beta parameters

setPosClassBetaParam

public void setPosClassBetaParam(Pair<Double,Double> posClassBetaParam)
Set positive class Beta distribution parameters

Parameters:
posClassBetaParam - is a Pair of Doubles holding positive class beta parameters

updateWorkerPriors

public void updateWorkerPriors(Map<TypeWID,Pair<Pair<Double,Double>,Pair<Double,Double>>> workerPriors)
Update worker priors

Parameters:
workerPriors - is a Map from workers to priors

updateClassPriorParam

public void updateClassPriorParam(Pair<Double,Double> posClassBetaParam)
Update positive class prior

Parameters:
posClassBetaParam - is a Pair of Doubles holding positive class beta parameters

hasPositiveClass

public boolean hasPositiveClass()
Check for Postive Class

Returns:
a boolean indicating presence of Postive class

getPositiveClass

public TypeR getPositiveClass()
Get Positive class

Returns:
positive class

setPositiveClass

public void setPositiveClass(TypeR positiveClass)
Set positive class

Parameters:
positiveClass - is of response type holding positive class

getWorkersMap

public Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMap()
Description copied from interface: AlgorithmInterface
Get all responses stored for each worker

Specified by:
getWorkersMap in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
a Map from Worker ID to a worker object holding questions and responses

setWorkersMap

public void setWorkersMap(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMap)
Description copied from interface: AlgorithmInterface
Set responses to questions for each worker

Specified by:
setWorkersMap in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
workersMap - is a Map from Worker ID to a worker object holding questions and responses

getResponseCategories

public TreeSet<TypeR> getResponseCategories()
Description copied from interface: AlgorithmInterface
Get valid response categories

Specified by:
getResponseCategories in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
is a sorted set of response categories

setResponseCategories

public void setResponseCategories(TreeSet<TypeR> responseCategories)
Description copied from interface: AlgorithmInterface
Set response categories

Specified by:
setResponseCategories in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
responseCategories - is a TreeSet of TypeR

getWorkersMapTune

public Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMapTune()
Description copied from interface: AlgorithmInterface
Get worker responses from the Tune partition

Specified by:
getWorkersMapTune in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
a Map from workers to objects containing worker questions and responses

setWorkersMapTune

public void setWorkersMapTune(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapTune)
Description copied from interface: AlgorithmInterface
Set worker responses from the Tune partition

Specified by:
setWorkersMapTune in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
workersMapTune - is a Map from workers to objects containing worker questions and responses

getWorkersMapGold

public Map<TypeWID,workersDataStruct<TypeQ,TypeR>> getWorkersMapGold()
Description copied from interface: AlgorithmInterface
Get worker responses from the Gold partition

Specified by:
getWorkersMapGold in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
a Map from workers to objects containing worker questions and responses

setWorkersMapGold

public void setWorkersMapGold(Map<TypeWID,workersDataStruct<TypeQ,TypeR>> workersMapGold)
Description copied from interface: AlgorithmInterface
Set worker responses from the Gold partition

Specified by:
setWorkersMapGold in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
workersMapGold - is a Map from workers to objects containing worker questions and responses

getTuneGT

public Map<TypeQ,TypeR> getTuneGT()
Description copied from interface: AlgorithmInterface
Get ground truth question response pairs from the tune partition

Specified by:
getTuneGT in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
is a Map from questions to responses

setTuneGT

public void setTuneGT(Map<TypeQ,TypeR> tuneGT)
Description copied from interface: AlgorithmInterface
Set ground truth question response pairs from the tune partition

Specified by:
setTuneGT in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
tuneGT - is a Map from questions to responses

getGoldStandard

public Map<TypeQ,TypeR> getGoldStandard()
Description copied from interface: AlgorithmInterface
Get ground truth question response pairs from the gold partition

Specified by:
getGoldStandard in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
is a Map from questions to responses

setGoldStandard

public void setGoldStandard(Map<TypeQ,TypeR> goldStandard)
Description copied from interface: AlgorithmInterface
Set ground truth question response pairs from the gold partition

Specified by:
setGoldStandard in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
goldStandard - is a Map from questions to responses

hasWorkersMap

public boolean hasWorkersMap()
Description copied from interface: AlgorithmInterface
Checks for presence of worker responses from the evaluation partition

Specified by:
hasWorkersMap in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if workers responses are loaded

hasWorkersMapTune

public boolean hasWorkersMapTune()
Description copied from interface: AlgorithmInterface
Checks for presence of worker responses from the tune partition

Specified by:
hasWorkersMapTune in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if workers responses are loaded

hasWorkersMapGold

public boolean hasWorkersMapGold()
Description copied from interface: AlgorithmInterface
Checks for presence of worker responses from the gold partition

Specified by:
hasWorkersMapGold in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if workers responses are loaded

hasResponseCategories

public boolean hasResponseCategories()
Description copied from interface: AlgorithmInterface
Checks for presence of response categories

Specified by:
hasResponseCategories in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if response categories are loaded

hasGoldStandard

public boolean hasGoldStandard()
Description copied from interface: AlgorithmInterface
Checks if gold standard is used by the algorithm (supervised)

Specified by:
hasGoldStandard in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if gold standard is available

hasTuneGT

public boolean hasTuneGT()
Description copied from interface: AlgorithmInterface
Checks if ground truth for tune partition is used by the algorithm (lightly-supervised)

Specified by:
hasTuneGT in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if ground truth for tune partition is available

getCombinedEstLabels

public Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> getCombinedEstLabels()
Description copied from interface: AlgorithmInterface
Get computed/partially-computed results

Specified by:
getCombinedEstLabels in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
a Map from questions to Pair of predicted response and response probabilities

hasCombinedEstLabels

public boolean hasCombinedEstLabels()
Description copied from interface: AlgorithmInterface
Checks if results are computed

Specified by:
hasCombinedEstLabels in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Returns:
true if results have been computed

setCombinedEstLabels

public void setCombinedEstLabels(Map<TypeQ,Pair<TypeR,Map<TypeR,Double>>> combinedEstLabels)
Description copied from interface: AlgorithmInterface
Load computed/partially-computed results

Specified by:
setCombinedEstLabels in interface AlgorithmInterface<TypeWID,TypeQ,TypeR>
Parameters:
combinedEstLabels - is a Map from questions to Pair of predicted response and response probabilities


Copyright © 2013. All Rights Reserved.