icub-client
Namespaces | Classes | Functions | Variables

Drivers folder containing driver classes that inherit from SAMDriver to implement custom functionality. More...

+ Collaboration diagram for SAM Drivers:

Namespaces

 SAM.SAM_Core.samOptimiser
 

Classes

class  SAM.SAM_Core.SAMDriver.SAMDriver
 SAM Driver parent class that defines the methods by which models are initialised, trained and saved. More...
 
class  SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin
 Class developed for the implementation of windowed real time action recognition. More...
 
class  SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction
 Class developed for the implementation of face recognition. More...
 

Functions

def SAM.SAM_Core.SAMDriver.SAMDriver.__init__ (self)
 Initialisation for SAMDriver. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.saveParameters (self)
 Method to store variables generated during training which are required during interaction in self.paramsDict. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.testPerformance (self, testModel, Yall, Lall, YtestAll, LtestAll, verbose)
 Method for testing the whole dataset for overall performance. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.training (self, modelNumInducing, modelNumIterations, modelInitIterations, fname, save_model, economy_save, keepIfPresent=True, kernelStr=None)
 Method to train, store and load the learned model. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.prepareData (self, model='mrd', Ntr=50, randSeed=0, normalise=True)
 Method for randomly splitting data and preparing Y dictionary. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.processLiveData (self, dataList, thisModel, verbose=False)
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
def SAM.SAM_Core.SAMDriver.SAMDriver.formatGeneratedData (self, instance)
 Method which receives an instance generated from a model via a label and formats the received vector by reshaping it or adding crucial data with it for it to be deciphered at the receiving end. More...
 

Variables

 SAM.SAM_Core.SAMDriver.SAMDriver.SAMObject
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Y
 
 SAM.SAM_Core.SAMDriver.SAMDriver.L
 
 SAM.SAM_Core.SAMDriver.SAMDriver.X
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ytest
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ltest
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ytestn
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ltestn
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ymean
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ystd
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Yn
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Ln
 
 SAM.SAM_Core.SAMDriver.SAMDriver.segTrainConf
 
 SAM.SAM_Core.SAMDriver.SAMDriver.segTrainPerc
 
 SAM.SAM_Core.SAMDriver.SAMDriver.segTestConf
 
 SAM.SAM_Core.SAMDriver.SAMDriver.segTestPerc
 
 SAM.SAM_Core.SAMDriver.SAMDriver.data_labels
 
 SAM.SAM_Core.SAMDriver.SAMDriver.paramsDict
 
 SAM.SAM_Core.SAMDriver.SAMDriver.verbose
 
 SAM.SAM_Core.SAMDriver.SAMDriver.model_mode
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Quser
 
 SAM.SAM_Core.SAMDriver.SAMDriver.listOfModels
 
 SAM.SAM_Core.SAMDriver.SAMDriver.model_type
 
 SAM.SAM_Core.SAMDriver.SAMDriver.modelLabel
 
 SAM.SAM_Core.SAMDriver.SAMDriver.textLabels
 
 SAM.SAM_Core.SAMDriver.SAMDriver.participantList
 
 SAM.SAM_Core.SAMDriver.SAMDriver.varianceThreshold
 
 SAM.SAM_Core.SAMDriver.SAMDriver.fname
 
 SAM.SAM_Core.SAMDriver.SAMDriver.optimiseRecall
 
 SAM.SAM_Core.SAMDriver.SAMDriver.modelLoaded
 
 SAM.SAM_Core.SAMDriver.SAMDriver.parallelOperation
 
 SAM.SAM_Core.SAMDriver.SAMDriver.calibrated
 
 SAM.SAM_Core.SAMDriver.SAMDriver.rawTextData
 
 SAM.SAM_Core.SAMDriver.SAMDriver.rawData
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Yall
 
 SAM.SAM_Core.SAMDriver.SAMDriver.Lall
 
 SAM.SAM_Core.SAMDriver.SAMDriver.YtestAll
 
 SAM.SAM_Core.SAMDriver.SAMDriver.LtestAll
 
 SAM.SAM_Core.SAMDriver.SAMDriver.classifiers
 
 SAM.SAM_Core.SAMDriver.SAMDriver.classif_thresh
 
 SAM.SAM_Core.SAMDriver.SAMDriver.model_num_inducing
 
 SAM.SAM_Core.SAMDriver.SAMDriver.model_num_iterations
 
 SAM.SAM_Core.SAMDriver.SAMDriver.model_init_iterations
 
 SAM.SAM_Core.SAMDriver.SAMDriver.additionalParametersList
 

Detailed Description

Drivers folder containing driver classes that inherit from SAMDriver to implement custom functionality.


Class Documentation

◆ SAM::SAM_Core::SAMDriver::SAMDriver

class SAM::SAM_Core::SAMDriver::SAMDriver

SAM Driver parent class that defines the methods by which models are initialised, trained and saved.

Definition at line 35 of file SAMDriver.py.

+ Inheritance diagram for SAM.SAM_Core.SAMDriver.SAMDriver:

Public Member Functions

def __init__ (self)
 Initialisation for SAMDriver. More...
 
def loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def saveParameters (self)
 Method to store variables generated during training which are required during interaction in self.paramsDict. More...
 
def testPerformance (self, testModel, Yall, Lall, YtestAll, LtestAll, verbose)
 Method for testing the whole dataset for overall performance. More...
 
def training (self, modelNumInducing, modelNumIterations, modelInitIterations, fname, save_model, economy_save, keepIfPresent=True, kernelStr=None)
 Method to train, store and load the learned model. More...
 
def prepareData (self, model='mrd', Ntr=50, randSeed=0, normalise=True)
 Method for randomly splitting data and preparing Y dictionary. More...
 
def readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def processLiveData (self, dataList, thisModel, verbose=False)
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
def formatGeneratedData (self, instance)
 Method which receives an instance generated from a model via a label and formats the received vector by reshaping it or adding crucial data with it for it to be deciphered at the receiving end. More...
 

Public Attributes

 SAMObject
 
 Y
 
 L
 
 X
 
 Ytest
 
 Ltest
 
 Ytestn
 
 Ltestn
 
 Ymean
 
 Ystd
 
 Yn
 
 Ln
 
 segTrainConf
 
 segTrainPerc
 
 segTestConf
 
 segTestPerc
 
 data_labels
 
 paramsDict
 
 verbose
 
 model_mode
 
 Quser
 
 listOfModels
 
 model_type
 
 modelLabel
 
 textLabels
 
 participantList
 
 varianceThreshold
 
 fname
 
 optimiseRecall
 
 modelLoaded
 
 parallelOperation
 
 calibrated
 
 rawTextData
 
 rawData
 
 Yall
 
 Lall
 
 YtestAll
 
 LtestAll
 
 classifiers
 
 classif_thresh
 
 model_num_inducing
 
 model_num_iterations
 
 model_init_iterations
 
 additionalParametersList
 

◆ SAM::SAM_Drivers::SAMDriver_ARWin::SAMDriver_ARWin

class SAM::SAM_Drivers::SAMDriver_ARWin::SAMDriver_ARWin

Class developed for the implementation of windowed real time action recognition.

Definition at line 28 of file SAMDriver_ARWin.py.

+ Inheritance diagram for SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin:

Public Member Functions

def __init__ (self)
 Initialise class using SAMDriver.__init__ and augment with custom parameters. More...
 
def loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def saveParameters (self)
 Override SAMDriver.saveParameters. More...
 
def testPerformance (self, testModel, Yall, Lall, YtestAll, LtestAll, verbose)
 Custom testPerformance method. More...
 
def diskDataToLiveData (self, root_data_dir)
 This method reads in time series data from disk for SAMDriver_ARWin. More...
 
def convertToDict (self, rawData, mode, verbose)
 Convert list of strings time series to dictionary with joints and objects as different items of the dictionary and windows of positions for each joint. More...
 
def readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def listOfClassificationVectors (self, featureSequence, objectsList, partnerName='partner')
 Constructs a list of classifications to carry out. More...
 
def messageChecker (self, dataMessage, mode)
 Method to check validity of incoming messages and split into components if valid. More...
 
def processLiveData (self, dataList, thisModel, verbose=False, returnUnknown=False, printClass=True, additionalData=dict())
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
- Public Member Functions inherited from SAM.SAM_Core.SAMDriver.SAMDriver
def __init__ (self)
 Initialisation for SAMDriver. More...
 
def loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def saveParameters (self)
 Method to store variables generated during training which are required during interaction in self.paramsDict. More...
 
def testPerformance (self, testModel, Yall, Lall, YtestAll, LtestAll, verbose)
 Method for testing the whole dataset for overall performance. More...
 
def training (self, modelNumInducing, modelNumIterations, modelInitIterations, fname, save_model, economy_save, keepIfPresent=True, kernelStr=None)
 Method to train, store and load the learned model. More...
 
def prepareData (self, model='mrd', Ntr=50, randSeed=0, normalise=True)
 Method for randomly splitting data and preparing Y dictionary. More...
 
def readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def processLiveData (self, dataList, thisModel, verbose=False)
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
def formatGeneratedData (self, instance)
 Method which receives an instance generated from a model via a label and formats the received vector by reshaping it or adding crucial data with it for it to be deciphered at the receiving end. More...
 

Public Attributes

 data
 
 numJoints
 
 dataLogList
 
 labelsLogList
 
 itemsPerJoint
 
 featureSequence
 
 handsCombined
 
 data2Labels
 
 dataVec
 
 allDataDict
 
 listOfVectorsToClassify
 
 seqTestConf
 
 seqTestPerc
 
 additionalParametersList
 
 rawTextData
 
 Y
 
 L
 
- Public Attributes inherited from SAM.SAM_Core.SAMDriver.SAMDriver
 SAMObject
 
 Y
 
 L
 
 X
 
 Ytest
 
 Ltest
 
 Ytestn
 
 Ltestn
 
 Ymean
 
 Ystd
 
 Yn
 
 Ln
 
 segTrainConf
 
 segTrainPerc
 
 segTestConf
 
 segTestPerc
 
 data_labels
 
 paramsDict
 
 verbose
 
 model_mode
 
 Quser
 
 listOfModels
 
 model_type
 
 modelLabel
 
 textLabels
 
 participantList
 
 varianceThreshold
 
 fname
 
 optimiseRecall
 
 modelLoaded
 
 parallelOperation
 
 calibrated
 
 rawTextData
 
 rawData
 
 Yall
 
 Lall
 
 YtestAll
 
 LtestAll
 
 classifiers
 
 classif_thresh
 
 model_num_inducing
 
 model_num_iterations
 
 model_init_iterations
 
 additionalParametersList
 

Constructor & Destructor Documentation

◆ __init__()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.__init__ (   self)

Initialise class using SAMDriver.__init__ and augment with custom parameters.

additionalParameterList is a list of extra parameters to preserve between training and interaction.

Definition at line 34 of file SAMDriver_ARWin.py.

Member Function Documentation

◆ convertToDict()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.convertToDict (   self,
  rawData,
  mode,
  verbose 
)

Convert list of strings time series to dictionary with joints and objects as different items of the dictionary and windows of positions for each joint.

Parameters
rawDataList of strings read in from files.
mode'testing' or 'live'. 'testing' will format strings read from file. 'live' will format strings received via Yarp during interaction.
verboseSwitch logging to stdout on or off.
Returns
Dictionary with the windowed data, list of joints present in dictionary items, list of objects present in dictionary items.

Definition at line 272 of file SAMDriver_ARWin.py.

◆ diskDataToLiveData()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.diskDataToLiveData (   self,
  root_data_dir 
)

This method reads in time series data from disk for SAMDriver_ARWin.

Returns
list of strings with raw data and list of strings with ground truth classifications.

Definition at line 198 of file SAMDriver_ARWin.py.

◆ listOfClassificationVectors()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.listOfClassificationVectors (   self,
  featureSequence,
  objectsList,
  partnerName = 'partner' 
)

Constructs a list of classifications to carry out.

Consider an example where featureSequence consists of `object', 'hand', 'head'. Assuming there are 2 objects in the scene, this method constructs 4 possible vectors to classify.
1) object1, rightHand, head
2) object1, leftHand, head
3) object2, rightHand, head
4) object2, leftHand, head

Parameters
featureSequenceOrganisation of features within the feature vector.
objectsListList of objects currently in the scene.
partnerNameObject name to ignore. This ignores the motion of the interacting agent.
Returns
List of vectors to classify.

Definition at line 763 of file SAMDriver_ARWin.py.

◆ loadParameters()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.loadParameters (   self,
  parser,
  trainName 
)

Function to load parameters from the model config.ini file.

Method to load parameters from file loaded in parser from within section trainName and store these parameters in self.paramsDict.

Parameters
parserSafeConfigParser with pre-read config file.
trainNameSection from which parameters are to be read.
Returns
None

Definition at line 65 of file SAMDriver_ARWin.py.

◆ messageChecker()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.messageChecker (   self,
  dataMessage,
  mode 
)

Method to check validity of incoming messages and split into components if valid.

Parameters
dataMessageString message to validate.
modeMode of validation. Either 'test' or 'live'.
Returns
List of strings with split sections and a boolean indicating validity of received string.

Definition at line 800 of file SAMDriver_ARWin.py.

◆ processLiveData()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.processLiveData (   self,
  dataList,
  thisModel,
  verbose = False,
  returnUnknown = False,
  printClass = True,
  additionalData = dict() 
)

Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not.

Parameters
dataListList of dataFrames collected. Length of list is variable.
thisModelList of models required for testing.
verboseBoolean turning logging to stdout on or off.
returnUnknownBoolean to turn on or off the return a sentence if the classification is unknown.
printClassBoolean to turn on or off logging of classification to stdout.
additionalDataDictionary containing additional data required for classification to occur.
Returns
String with result of classification, likelihood of the classification, and list of frames with the latest x number of frames popped where x is the window length of the model. Classification result can be string 'None' if the classification is unknown or message is invalid or None if a different error occurs.

Definition at line 851 of file SAMDriver_ARWin.py.

◆ readData()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.readData (   self,
  root_data_dir,
  participant_index,
  args,
  kw 
)

Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n.

This method reads data<number>.log files and the corresponding labels<number>.log files present in the root_data_dir and formats the time series data into normalised and smoothed windows. Subsequently depending on the list of joints chosen by the user and other parameters set in the config file present in the root_data_dir, the information of the different joints and objects are appended into a single feature vector. Number of feature vectors is equal to the number of windows extracted from the time series data.

Parameters
root_data_dirData directory.
participant_indexList of subfolders to consider. Can be left as an empty list.
Returns
None

Definition at line 417 of file SAMDriver_ARWin.py.

◆ saveParameters()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.saveParameters (   self)

Override SAMDriver.saveParameters.

This function adds items of additionalParametersList to paramsDict to be saved.

Definition at line 153 of file SAMDriver_ARWin.py.

◆ testPerformance()

def SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.testPerformance (   self,
  testModel,
  Yall,
  Lall,
  YtestAll,
  LtestAll,
  verbose 
)

Custom testPerformance method.

This augments the standard testPerformance method by including testing of known and unknown together with testing on known training points and known testing points.

Parameters
testModelSAMObject Model to be tested.
YallNumpy array with training data vectors to be tested.
LallList with corresponding training data labels.
YtestAllNumpy array with testing data vectors to be tested.
LtestAllList with corresponding testing data labels.
verboseBoolean turning logging to stdout on or off.
Returns
Square numpy array confusion matrix.

Definition at line 176 of file SAMDriver_ARWin.py.

Member Data Documentation

◆ additionalParametersList

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.additionalParametersList

Definition at line 49 of file SAMDriver_ARWin.py.

◆ allDataDict

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.allDataDict

Definition at line 45 of file SAMDriver_ARWin.py.

◆ data

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.data

Definition at line 36 of file SAMDriver_ARWin.py.

◆ data2Labels

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.data2Labels

Definition at line 43 of file SAMDriver_ARWin.py.

◆ dataLogList

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.dataLogList

Definition at line 38 of file SAMDriver_ARWin.py.

◆ dataVec

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.dataVec

Definition at line 44 of file SAMDriver_ARWin.py.

◆ featureSequence

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.featureSequence

Definition at line 41 of file SAMDriver_ARWin.py.

◆ handsCombined

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.handsCombined

Definition at line 42 of file SAMDriver_ARWin.py.

◆ itemsPerJoint

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.itemsPerJoint

Definition at line 40 of file SAMDriver_ARWin.py.

◆ L

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.L

Definition at line 740 of file SAMDriver_ARWin.py.

◆ labelsLogList

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.labelsLogList

Definition at line 39 of file SAMDriver_ARWin.py.

◆ listOfVectorsToClassify

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.listOfVectorsToClassify

Definition at line 46 of file SAMDriver_ARWin.py.

◆ numJoints

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.numJoints

Definition at line 37 of file SAMDriver_ARWin.py.

◆ rawTextData

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.rawTextData

Definition at line 208 of file SAMDriver_ARWin.py.

◆ seqTestConf

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.seqTestConf

Definition at line 47 of file SAMDriver_ARWin.py.

◆ seqTestPerc

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.seqTestPerc

Definition at line 48 of file SAMDriver_ARWin.py.

◆ Y

SAM.SAM_Drivers.SAMDriver_ARWin.SAMDriver_ARWin.Y

Definition at line 739 of file SAMDriver_ARWin.py.

◆ SAM::SAM_Drivers::SAMDriver_interaction::SAMDriver_interaction

class SAM::SAM_Drivers::SAMDriver_interaction::SAMDriver_interaction

Class developed for the implementation of face recognition.

Definition at line 26 of file SAMDriver_interaction.py.

+ Inheritance diagram for SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction:

Public Member Functions

def __init__ (self)
 Initialise class using SAMDriver.__init__ and augment with custom parameters. More...
 
def loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def saveParameters (self)
 Executes SAMDriver.saveParameters to save default parameters. More...
 
def readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def processLiveData (self, dataList, thisModel, verbose, additionalData=dict())
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
def formatGeneratedData (self, instance)
 Method to transform a generated instance from the model into a Yarp formatted output. More...
 
- Public Member Functions inherited from SAM.SAM_Core.SAMDriver.SAMDriver
def __init__ (self)
 Initialisation for SAMDriver. More...
 
def loadParameters (self, parser, trainName)
 Function to load parameters from the model config.ini file. More...
 
def saveParameters (self)
 Method to store variables generated during training which are required during interaction in self.paramsDict. More...
 
def testPerformance (self, testModel, Yall, Lall, YtestAll, LtestAll, verbose)
 Method for testing the whole dataset for overall performance. More...
 
def training (self, modelNumInducing, modelNumIterations, modelInitIterations, fname, save_model, economy_save, keepIfPresent=True, kernelStr=None)
 Method to train, store and load the learned model. More...
 
def prepareData (self, model='mrd', Ntr=50, randSeed=0, normalise=True)
 Method for randomly splitting data and preparing Y dictionary. More...
 
def readData (self, root_data_dir, participant_index, args, kw)
 Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n. More...
 
def processLiveData (self, dataList, thisModel, verbose=False)
 Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not. More...
 
def formatGeneratedData (self, instance)
 Method which receives an instance generated from a model via a label and formats the received vector by reshaping it or adding crucial data with it for it to be deciphered at the receiving end. More...
 

Public Attributes

 additionalParametersList
 
 Y
 
 L
 
- Public Attributes inherited from SAM.SAM_Core.SAMDriver.SAMDriver
 SAMObject
 
 Y
 
 L
 
 X
 
 Ytest
 
 Ltest
 
 Ytestn
 
 Ltestn
 
 Ymean
 
 Ystd
 
 Yn
 
 Ln
 
 segTrainConf
 
 segTrainPerc
 
 segTestConf
 
 segTestPerc
 
 data_labels
 
 paramsDict
 
 verbose
 
 model_mode
 
 Quser
 
 listOfModels
 
 model_type
 
 modelLabel
 
 textLabels
 
 participantList
 
 varianceThreshold
 
 fname
 
 optimiseRecall
 
 modelLoaded
 
 parallelOperation
 
 calibrated
 
 rawTextData
 
 rawData
 
 Yall
 
 Lall
 
 YtestAll
 
 LtestAll
 
 classifiers
 
 classif_thresh
 
 model_num_inducing
 
 model_num_iterations
 
 model_init_iterations
 
 additionalParametersList
 

Constructor & Destructor Documentation

◆ __init__()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.__init__ (   self)

Initialise class using SAMDriver.__init__ and augment with custom parameters.

additionalParameterList is a list of extra parameters to preserve between training and interaction.

Definition at line 32 of file SAMDriver_interaction.py.

Member Function Documentation

◆ formatGeneratedData()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.formatGeneratedData (   self,
  instance 
)

Method to transform a generated instance from the model into a Yarp formatted output.

Parameters
instanceFeature vector returned during generation of a label.
Returns
Yarp formatted output for instance.

Definition at line 264 of file SAMDriver_interaction.py.

◆ loadParameters()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.loadParameters (   self,
  parser,
  trainName 
)

Function to load parameters from the model config.ini file.

Method to load parameters from file loaded in parser from within section trainName and store these parameters in self.paramsDict.

Parameters
parserSafeConfigParser with pre-read config file.
trainNameSection from which parameters are to be read.
Returns
None

Definition at line 49 of file SAMDriver_interaction.py.

◆ processLiveData()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.processLiveData (   self,
  dataList,
  thisModel,
  verbose,
  additionalData = dict() 
)

Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not.

Parameters
dataListList of dataFrames collected. Length of list is variable.
thisModelList of models required for testing.
verboseBoolean turning logging to stdout on or off.
additionalDataDictionary containing additional data required for classification to occur.
Returns
String with result of classification, likelihood of the classification, and list of frames with the latest x number of frames popped where x is the window length of the model. Classification result can be string 'None' if the classification is unknown or message is invalid or None if a different error occurs.

Definition at line 213 of file SAMDriver_interaction.py.

◆ readData()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.readData (   self,
  root_data_dir,
  participant_index,
  args,
  kw 
)

Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n.

This method reads .ppm images from disk, converts the images to grayscale and serialises the data into a feature vector.

Parameters
root_data_dirData directory.
participant_indexList of subfolders to consider. Can be left as an empty list.
Returns

Definition at line 104 of file SAMDriver_interaction.py.

◆ saveParameters()

def SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.saveParameters (   self)

Executes SAMDriver.saveParameters to save default parameters.

Definition at line 88 of file SAMDriver_interaction.py.

Member Data Documentation

◆ additionalParametersList

SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.additionalParametersList

Definition at line 34 of file SAMDriver_interaction.py.

◆ L

SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.L

Definition at line 199 of file SAMDriver_interaction.py.

◆ Y

SAM.SAM_Drivers.SAMDriver_interaction.SAMDriver_interaction.Y

Definition at line 198 of file SAMDriver_interaction.py.

Function Documentation

◆ __init__()

def SAM.SAM_Core.SAMDriver.SAMDriver.__init__ (   self)

Initialisation for SAMDriver.

Definition at line 40 of file SAMDriver.py.

◆ formatGeneratedData()

def SAM.SAM_Core.SAMDriver.SAMDriver.formatGeneratedData (   self,
  instance 
)

Method which receives an instance generated from a model via a label and formats the received vector by reshaping it or adding crucial data with it for it to be deciphered at the receiving end.

Parameters
instanceA vector of generated data.
Returns
NotImplementedError if not implemented by the inheriting child. Otherwise returns a Yarp Bottle or Yarp Image with the formatted generated data.

Definition at line 373 of file SAMDriver.py.

◆ loadParameters()

def SAM.SAM_Core.SAMDriver.SAMDriver.loadParameters (   self,
  parser,
  trainName 
)

Function to load parameters from the model config.ini file.

Method to load parameters from file loaded in parser from within section trainName and store these parameters in self.paramsDict,

Parameters
parserSafeConfigParser with pre-read config file.
trainNameSection from which parameters are to be read.
Returns
NotImplementedError if this function is not implemented by the inheriting child.

Definition at line 105 of file SAMDriver.py.

◆ prepareData()

def SAM.SAM_Core.SAMDriver.SAMDriver.prepareData (   self,
  model = 'mrd',
  Ntr = 50,
  randSeed = 0,
  normalise = True 
)

Method for randomly splitting data and preparing Y dictionary.

This method splits the data in the model randomly between training and testing. Currently does not take equal number of samples from different classes.

Parameters
modelString with type of model to be trained. Accepted values are 'mrd' and 'bgplvm'.
NtrFloat percentage for the training/testing division of data.
randSeedInteger random seed.
normaliseBoolean turning normalisation of data on or off.
Returns
None

Definition at line 271 of file SAMDriver.py.

◆ processLiveData()

def SAM.SAM_Core.SAMDriver.SAMDriver.processLiveData (   self,
  dataList,
  thisModel,
  verbose = False 
)

Method which receives a list of data frames and outputs a classification if available or 'no_classification' if it is not.

Parameters
dataListList of dataFrames collected. Length of list is variable.
thisModelList of models required for testing.
verboseBoolean turning logging to stdout on or off.
Returns
NotImplementedError if not implemented by the inheriting child. Otherwise returns a string classification label.

Definition at line 361 of file SAMDriver.py.

◆ readData()

def SAM.SAM_Core.SAMDriver.SAMDriver.readData (   self,
  root_data_dir,
  participant_index,
  args,
  kw 
)

Method which accepts a data directory, reads all the data in and outputs self.Y which is a numpy array with n instances of m length feature vectors and self.L which is a list of text Labels of length n.

Parameters
root_data_dirData directory.
participant_indexList of subfolders to consider. Can be left as an empty list.
Returns
NotImplementedError if not implemented by the inheriting child. Otherwise returns self.Y and self.L which contain the formatted data and labels read from the data directory.

Definition at line 347 of file SAMDriver.py.

◆ saveParameters()

def SAM.SAM_Core.SAMDriver.SAMDriver.saveParameters (   self)

Method to store variables generated during training which are required during interaction in self.paramsDict.

Parameters
None
Returns
None

Definition at line 117 of file SAMDriver.py.

◆ testPerformance()

def SAM.SAM_Core.SAMDriver.SAMDriver.testPerformance (   self,
  testModel,
  Yall,
  Lall,
  YtestAll,
  LtestAll,
  verbose 
)

Method for testing the whole dataset for overall performance.

Returns a confusion matrix.

   This implementation is a standard performance testing method that can be overridden by an inheriting child.
Parameters
testModelSAMObject Model to be tested.
YallNumpy array with training data vectors to be tested.
LallList with corresponding training data labels.
YtestAllNumpy array with testing data vectors to be tested.
LtestAllList with corresponding testing data labels.
verboseBoolean turning logging to stdout on or off.
Returns
Square numpy array confusion matrix.

Definition at line 142 of file SAMDriver.py.

◆ training()

def SAM.SAM_Core.SAMDriver.SAMDriver.training (   self,
  modelNumInducing,
  modelNumIterations,
  modelInitIterations,
  fname,
  save_model,
  economy_save,
  keepIfPresent = True,
  kernelStr = None 
)

Method to train, store and load the learned model.

This method tries reloading the model in fname. If unsuccessful or loaded model has mismatching parameters, trains a new model from scratch.

Parameters
modelNumInducingInteger number of inducing parameters.
modelNumIterationsInteger number of training iterations.
modelInitIterationsInteger number of initialisation iterations.
fnameFilename to save model to.
save_modelBoolean to turn saving of the model on or off.
economy_saveBoolean to turn economy saving on or off. Economy save saves smaller models by not storing data inside the model but keeping it stored in the data path.
keepIfPresentBoolean to enable or disable loading of a model when one is available.
kernelStrKernel string with the requested kernel. If None the default kernel is used.
Returns
None

Definition at line 172 of file SAMDriver.py.

Variable Documentation

◆ additionalParametersList

SAM.SAM_Core.SAMDriver.SAMDriver.additionalParametersList

Definition at line 90 of file SAMDriver.py.

◆ calibrated

SAM.SAM_Core.SAMDriver.SAMDriver.calibrated

Definition at line 74 of file SAMDriver.py.

◆ classif_thresh

SAM.SAM_Core.SAMDriver.SAMDriver.classif_thresh

Definition at line 84 of file SAMDriver.py.

◆ classifiers

SAM.SAM_Core.SAMDriver.SAMDriver.classifiers

Definition at line 83 of file SAMDriver.py.

◆ data_labels

SAM.SAM_Core.SAMDriver.SAMDriver.data_labels

Definition at line 59 of file SAMDriver.py.

◆ fname

SAM.SAM_Core.SAMDriver.SAMDriver.fname

Definition at line 70 of file SAMDriver.py.

◆ L

SAM.SAM_Core.SAMDriver.SAMDriver.L

Definition at line 45 of file SAMDriver.py.

◆ Lall

SAM.SAM_Core.SAMDriver.SAMDriver.Lall

Definition at line 79 of file SAMDriver.py.

◆ listOfModels

SAM.SAM_Core.SAMDriver.SAMDriver.listOfModels

Definition at line 64 of file SAMDriver.py.

◆ Ln

SAM.SAM_Core.SAMDriver.SAMDriver.Ln

Definition at line 54 of file SAMDriver.py.

◆ Ltest

SAM.SAM_Core.SAMDriver.SAMDriver.Ltest

Definition at line 48 of file SAMDriver.py.

◆ LtestAll

SAM.SAM_Core.SAMDriver.SAMDriver.LtestAll

Definition at line 81 of file SAMDriver.py.

◆ Ltestn

SAM.SAM_Core.SAMDriver.SAMDriver.Ltestn

Definition at line 50 of file SAMDriver.py.

◆ model_init_iterations

SAM.SAM_Core.SAMDriver.SAMDriver.model_init_iterations

Definition at line 88 of file SAMDriver.py.

◆ model_mode

SAM.SAM_Core.SAMDriver.SAMDriver.model_mode

Definition at line 62 of file SAMDriver.py.

◆ model_num_inducing

SAM.SAM_Core.SAMDriver.SAMDriver.model_num_inducing

Definition at line 86 of file SAMDriver.py.

◆ model_num_iterations

SAM.SAM_Core.SAMDriver.SAMDriver.model_num_iterations

Definition at line 87 of file SAMDriver.py.

◆ model_type

SAM.SAM_Core.SAMDriver.SAMDriver.model_type

Definition at line 65 of file SAMDriver.py.

◆ modelLabel

SAM.SAM_Core.SAMDriver.SAMDriver.modelLabel

Definition at line 66 of file SAMDriver.py.

◆ modelLoaded

SAM.SAM_Core.SAMDriver.SAMDriver.modelLoaded

Definition at line 72 of file SAMDriver.py.

◆ optimiseRecall

SAM.SAM_Core.SAMDriver.SAMDriver.optimiseRecall

Definition at line 71 of file SAMDriver.py.

◆ parallelOperation

SAM.SAM_Core.SAMDriver.SAMDriver.parallelOperation

Definition at line 73 of file SAMDriver.py.

◆ paramsDict

SAM.SAM_Core.SAMDriver.SAMDriver.paramsDict

Definition at line 60 of file SAMDriver.py.

◆ participantList

SAM.SAM_Core.SAMDriver.SAMDriver.participantList

Definition at line 68 of file SAMDriver.py.

◆ Quser

SAM.SAM_Core.SAMDriver.SAMDriver.Quser

Definition at line 63 of file SAMDriver.py.

◆ rawData

SAM.SAM_Core.SAMDriver.SAMDriver.rawData

Definition at line 76 of file SAMDriver.py.

◆ rawTextData

SAM.SAM_Core.SAMDriver.SAMDriver.rawTextData

Definition at line 75 of file SAMDriver.py.

◆ SAMObject

SAM.SAM_Core.SAMDriver.SAMDriver.SAMObject

Definition at line 42 of file SAMDriver.py.

◆ segTestConf

SAM.SAM_Core.SAMDriver.SAMDriver.segTestConf

Definition at line 57 of file SAMDriver.py.

◆ segTestPerc

SAM.SAM_Core.SAMDriver.SAMDriver.segTestPerc

Definition at line 58 of file SAMDriver.py.

◆ segTrainConf

SAM.SAM_Core.SAMDriver.SAMDriver.segTrainConf

Definition at line 55 of file SAMDriver.py.

◆ segTrainPerc

SAM.SAM_Core.SAMDriver.SAMDriver.segTrainPerc

Definition at line 56 of file SAMDriver.py.

◆ textLabels

SAM.SAM_Core.SAMDriver.SAMDriver.textLabels

Definition at line 67 of file SAMDriver.py.

◆ varianceThreshold

SAM.SAM_Core.SAMDriver.SAMDriver.varianceThreshold

Definition at line 69 of file SAMDriver.py.

◆ verbose

SAM.SAM_Core.SAMDriver.SAMDriver.verbose

Definition at line 61 of file SAMDriver.py.

◆ X

SAM.SAM_Core.SAMDriver.SAMDriver.X

Definition at line 46 of file SAMDriver.py.

◆ Y

SAM.SAM_Core.SAMDriver.SAMDriver.Y

Definition at line 44 of file SAMDriver.py.

◆ Yall

SAM.SAM_Core.SAMDriver.SAMDriver.Yall

Definition at line 78 of file SAMDriver.py.

◆ Ymean

SAM.SAM_Core.SAMDriver.SAMDriver.Ymean

Definition at line 51 of file SAMDriver.py.

◆ Yn

SAM.SAM_Core.SAMDriver.SAMDriver.Yn

Definition at line 53 of file SAMDriver.py.

◆ Ystd

SAM.SAM_Core.SAMDriver.SAMDriver.Ystd

Definition at line 52 of file SAMDriver.py.

◆ Ytest

SAM.SAM_Core.SAMDriver.SAMDriver.Ytest

Definition at line 47 of file SAMDriver.py.

◆ YtestAll

SAM.SAM_Core.SAMDriver.SAMDriver.YtestAll

Definition at line 80 of file SAMDriver.py.

◆ Ytestn

SAM.SAM_Core.SAMDriver.SAMDriver.Ytestn

Definition at line 49 of file SAMDriver.py.