org.square.qa.utilities.constructs
Class GeneralUtils

java.lang.Object
  extended by org.square.qa.utilities.constructs.GeneralUtils

public class GeneralUtils
extends Object


Nested Class Summary
static class GeneralUtils.nFoldSet
           
 
Constructor Summary
GeneralUtils()
           
 
Method Summary
static void computeMetrics(org.jblas.DoubleMatrix resultVector, Metrics metrics, Pair<org.jblas.DoubleMatrix,org.jblas.DoubleMatrix> groundTruth, Pair<org.jblas.DoubleMatrix,org.jblas.DoubleMatrix>... gold)
           
static void fillNFoldClass(Set<String> responseCategories)
          Update NFold class with mapping from workers, questions and categories to Integer
static Pair<Double,Double> getBetaParam(double mean, double variance)
          Get the parameters of a Beta distribution for input mean and variance
static GeneralUtilsParameterized<String,String,String> getParamUtils()
          Get parameterized utils object
static Set<String> getQuestions(Map<String,workersDataStruct<String,String>> workersMap)
          Extract questions from workers map
static void loadNFoldSet(File loadDir)
          Load n fold sets from files
static void printAll(File dir)
          Print NFold data to files
static void printStatistics(Map<String,workersDataStruct<String,String>> workersMap, File... outDir)
          Print data statistics
static void setNFoldSets(int n)
          Compute n folds from data 5 fold -> 20% => n = 5 80% => n = -5
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtils

public GeneralUtils()
Method Detail

getParamUtils

public static GeneralUtilsParameterized<String,String,String> getParamUtils()
Get parameterized utils object

Returns:
GeneralUtilsParameterized object with worker ids, questions and responses instantiated as strings

getBetaParam

public static Pair<Double,Double> getBetaParam(double mean,
                                               double variance)
Get the parameters of a Beta distribution for input mean and variance

Parameters:
mean - is double holding mean of the desired Beta distribution
variance - is a double holding the variance of the desired Beta distribution
Returns:
a Pair of Doubles holding a and b paramters of the corresponding Beta distribution

getQuestions

public static Set<String> getQuestions(Map<String,workersDataStruct<String,String>> workersMap)
Extract questions from workers map

Parameters:
workersMap - is a Map from workers (String) to an object holding worker questions and responses (Strings)
Returns:
a Set of questions (String)

computeMetrics

public static void computeMetrics(org.jblas.DoubleMatrix resultVector,
                                  Metrics metrics,
                                  Pair<org.jblas.DoubleMatrix,org.jblas.DoubleMatrix> groundTruth,
                                  Pair<org.jblas.DoubleMatrix,org.jblas.DoubleMatrix>... gold)
Parameters:
resultVector -
metrics - is a Metrics object to hold computed metrics
groundTruth - is a Pair of DoubleMatrix and DoubleMatrix holding questions and responses
gold - is the supervised/semi-supervised data to be excluded from metrics computation

fillNFoldClass

public static void fillNFoldClass(Set<String> responseCategories)
Update NFold class with mapping from workers, questions and categories to Integer

Parameters:
responseCategories - is a Set of String holding response categories

setNFoldSets

public static void setNFoldSets(int n)
Compute n folds from data 5 fold -> 20% => n = 5 80% => n = -5

Parameters:
n - is an int (positive till 50% use symmetrically negative for higher folds)

printAll

public static void printAll(File dir)
                     throws IOException
Print NFold data to files

Parameters:
dir - is a File holding the print path for files
Throws:
IOException

printStatistics

public static void printStatistics(Map<String,workersDataStruct<String,String>> workersMap,
                                   File... outDir)
                            throws FileNotFoundException
Print data statistics

Parameters:
workersMap - workersMap is a Map from workers to an object holding questions and responses
outDir - outDir of type File is the output directory to print files
Throws:
FileNotFoundException

loadNFoldSet

public static void loadNFoldSet(File loadDir)
                         throws IOException
Load n fold sets from files

Parameters:
loadDir - is a File holding path of the n fold files
Throws:
IOException


Copyright © 2013. All Rights Reserved.