SG++
python.learner.Learner.Learner Class Reference

The class implements the routines common for classifier and regressor. More...

Inheritance diagram for python.learner.Learner.Learner:

Public Member Functions

def __init__ (self)
 Constructor. More...
 
def applyData (self, points)
 Calculate the value of the function for given points. More...
 
def attachEventController (self, observer)
 Add observer to the list. More...
 
def createMemento (self)
 Creates a new memento to hold the current state. More...
 
def detachEventController (self, observer)
 Remove observer from the list. More...
 
def doLearningIteration (self, set)
 Perform one learning step. More...
 
def evalError (self, dataContainer, alpha)
 Evaluate accuracy this method is not implemented! More...
 
def fromJson (self, jsonObject)
 Restores the attributes of a subclass of Learner from the json object with attributes. More...
 
def getCurrentIterationNumber (self)
 Returns the number of current iteration. More...
 
def learnData (self)
 Simple data learning. More...
 
def learnDataWithFolding (self)
 Learn data with cross-fold validation. More...
 
def learnDataWithTest (self, dataset=None)
 Learn data from training data set and use validation data set to prevent overfitting. More...
 
def notifyEventControllers (self, event)
 Notify all observers about the new event. More...
 
def refineGrid (self)
 Refines Grid the function is not implemented here. More...
 
def setCurrentIterationNumber (self, value)
 Sets the number of current iteration. More...
 
def setDataContainer (self, container)
 Setter for data container. More...
 
def setFoldingPolicy (self, policy)
 Setter for folding policy. More...
 
def setGrid (self, grid)
 Setter for grid. More...
 
def setLearnedKnowledge (self, knowledge)
 Setter for learned knowledge. More...
 
def setMemento (self, memento)
 Restores the state which is saved in the given memento. More...
 
def setSolver (self, solver)
 Setter for linear solver. More...
 
def setSpecification (self, specification)
 Setter for training specification. More...
 
def setStopPolicy (self, policy)
 Setter for training stop policy. More...
 
def toString (self)
 Returns a string that represents the object. More...
 
def updateResults (self, alpha, trainSubset, testSubset=None)
 Update different statistics about training progress this method is not implemented! More...
 

Static Public Attributes

 alpha = None
 DataVector with current alpha vector. More...
 
 dataContainer = None
 DataContainer object with training (and maybe test) data. More...
 
 eventControllers = None
 list of object listening to the learning events More...
 
 foldingPolicy = None
 Implementation of folding policy if training with folding is used. More...
 
 grid = None
 Grid of the Learner. More...
 
 iteration = None
 Number of current iterations. More...
 
 knowledge = None
 LearnedKnowledge where alpha is stored. More...
 
 linearSystem = None
 DMSystemMatrix object associated with this Learner. More...
 
 numberPoints = None
 List of numbers of point on grid for different refinement iterations. More...
 
 solver = None
 LinearSolver object associated with this Learner. More...
 
 specification = None
 TrainingSpecification object associated with this Learner. More...
 
 stopPolicy = None
 TrainingStopPolicy object associated with this Learner. More...
 
 testAccuracy = None
 list of test accuracy values measured in refinement iteration More...
 
 testingOverall = None
 List of average training accuracy data over all refinement iterations. More...
 
 trainAccuracy = None
 list of train accuracy values measured in refinement iteration More...
 
 trainingOverall = None
 List of average training accuracy data over all refinement iterations. More...
 

Detailed Description

The class implements the routines common for classifier and regressor.

However, since some methods are defined and note implemented, this class is abstract and cannot be instantiated.

The class also implements the subject of the observer design pattern.

design pattern

To customize the processing of progress information in SGPP the observer pattern is used. The classes that want to be informed about events should implement LearnerEvenController and subscribe by the instance of Learner subclass with attachEventController(). After some event of LearnerEvents arise, the Learner subclass object calls method handleLearningEvent() by all subscribers. As subscribers get a reference to the Learner object, they can retrieve the attributes of the learner and process the information.

Roles

  • Subject: Learner
  • Concrete subject: e.g. Classifier or Regressor
  • Observer: LernerEventController
  • Concrete Observer: e.g. InfoToScreen

Observer can also want to retrieve the process information from LinearSolver. See documentation ofLinearSolver for more information.

Constructor & Destructor Documentation

Member Function Documentation

def python.learner.Learner.Learner.attachEventController (   self,
  observer 
)

Add observer to the list.

Parameters
observerLearnerEventController object

References python.learner.Learner.Learner.eventControllers.

def python.learner.Learner.Learner.detachEventController (   self,
  observer 
)

Remove observer from the list.

Parameters
observerLearnerEventController object

References python.learner.Learner.Learner.eventControllers.

def python.learner.Learner.Learner.evalError (   self,
  dataContainer,
  alpha 
)

Evaluate accuracy this method is not implemented!

Parameters
dataContainerDataContainer data set
alphaDataVector alpha-vector

Referenced by python.learner.Regressor.Regressor.updateResults(), python.uq.learner.Interpolant.Interpolant.updateResults(), and python.uq.learner.Regressor.Regressor.updateResults().

def python.learner.Learner.Learner.getCurrentIterationNumber (   self)

Returns the number of current iteration.

Returns
: integer iteration number

References python.learner.Learner.Learner.iteration.

def python.learner.Learner.Learner.learnData (   self)

Simple data learning.

Returns
: DataVector of alpha

References sgpp::base::SurplusRefinementFunctor.alpha, sgpp::base::SurplusCoarseningFunctor.alpha, sgpp::base::SurplusVolumeCoarseningFunctor.alpha, sgpp::base::SurplusVolumeRefinementFunctor.alpha, python.learner.Learner.Learner.alpha, sgpp::op_factory.createOperationMultipleEval(), python.learner.Learner.Learner.dataContainer, python.learner.Learner.Learner.doLearningIteration(), sgpp::base::OperationMultipleEval.grid, sgpp::base::OperationHierarchisationFundamentalSpline.grid, sgpp::base::OperationHierarchisationModFundamentalSpline.grid, python.learner.Learner.Learner.grid, sgpp::base::DehierarchisationFundamentalSpline.grid, sgpp::base::HierarchisationModFundamentalSpline.grid, sgpp::base::HierarchisationFundamentalSpline.grid, sgpp::base::DehierarchisationModFundamentalSpline.grid, sgpp::base::OperationQuadratureMC.grid, python.controller.CheckpointController.CheckpointController.grid, sgpp::combigrid::LTwoScalarProductHashMapNakBsplineBoundaryCombigrid.grid, sgpp::base::ImpurityRefinementIndicator.grid, sgpp::base::ForwardSelectorRefinementIndicator.grid, python.learner.Learner.Learner.iteration, python.learner.Learner.Learner.notifyEventControllers(), python.learner.Classifier.Classifier.refineGrid(), python.learner.Learner.Learner.refineGrid(), python.learner.Classifier.Classifier.updateResults(), and python.learner.Learner.Learner.updateResults().

Referenced by python.uq.manager.ASGCUQManager.ASGCUQManager.runNextSamples().

def python.learner.Learner.Learner.learnDataWithTest (   self,
  dataset = None 
)

Learn data from training data set and use validation data set to prevent overfitting.

Parameters
datasetDataContainer object with data sets, default value None (initialized data set used)
Returns
: DataVector of alpha

References sgpp::base::SurplusRefinementFunctor.alpha, sgpp::base::SurplusCoarseningFunctor.alpha, sgpp::base::SurplusVolumeCoarseningFunctor.alpha, sgpp::base::SurplusVolumeRefinementFunctor.alpha, python.learner.Learner.Learner.alpha, sgpp::op_factory.createOperationMultipleEval(), python.learner.Learner.Learner.dataContainer, python.learner.Learner.Learner.doLearningIteration(), sgpp::base::OperationMultipleEval.grid, sgpp::base::OperationHierarchisationFundamentalSpline.grid, sgpp::base::OperationHierarchisationModFundamentalSpline.grid, python.learner.Learner.Learner.grid, sgpp::base::DehierarchisationFundamentalSpline.grid, sgpp::base::HierarchisationModFundamentalSpline.grid, sgpp::base::HierarchisationFundamentalSpline.grid, sgpp::base::DehierarchisationModFundamentalSpline.grid, sgpp::base::OperationQuadratureMC.grid, python.controller.CheckpointController.CheckpointController.grid, sgpp::combigrid::LTwoScalarProductHashMapNakBsplineBoundaryCombigrid.grid, sgpp::base::ImpurityRefinementIndicator.grid, sgpp::base::ForwardSelectorRefinementIndicator.grid, python.learner.Learner.Learner.iteration, python.learner.Learner.Learner.notifyEventControllers(), python.learner.Classifier.Classifier.refineGrid(), python.learner.Learner.Learner.refineGrid(), python.learner.Classifier.Classifier.updateResults(), and python.learner.Learner.Learner.updateResults().

Referenced by python.uq.manager.ASGCUQManager.ASGCUQManager.learnData(), python.uq.learner.Regressor.Regressor.learnDataWithFolding(), and python.learner.Learner.Learner.learnDataWithFolding().

def python.learner.Learner.Learner.refineGrid (   self)
def python.learner.Learner.Learner.setCurrentIterationNumber (   self,
  value 
)

Sets the number of current iteration.

Parameters
valueinteger new iteration number

References python.learner.Learner.Learner.iteration.

def python.learner.Learner.Learner.setDataContainer (   self,
  container 
)

Setter for data container.

Parameters
containerthe data container object
Returns
: leaner itself

References python.learner.Learner.Learner.dataContainer.

def python.learner.Learner.Learner.setFoldingPolicy (   self,
  policy 
)

Setter for folding policy.

Parameters
policythe folding policy object
Returns
: leaner itself

References python.learner.Learner.Learner.foldingPolicy.

def python.learner.Learner.Learner.setLearnedKnowledge (   self,
  knowledge 
)

Setter for learned knowledge.

Parameters
knowledgethe learned knowledge object
Returns
: leaner itself

References python.learner.Learner.Learner.knowledge, and python.controller.CheckpointController.CheckpointController.knowledge.

def python.learner.Learner.Learner.setMemento (   self,
  memento 
)

Restores the state which is saved in the given memento.

Parameters
mementothe memento object

References python.learner.Learner.Learner.fromJson(), and python.data.DataContainer.DataContainer.fromJson().

def python.learner.Learner.Learner.setSolver (   self,
  solver 
)

Setter for linear solver.

Parameters
solverthe linear solver object
Returns
: leaner itself

References python.learner.Learner.Learner.solver.

def python.learner.Learner.Learner.setSpecification (   self,
  specification 
)

Setter for training specification.

Parameters
specificationthe training specification object
Returns
: leaner itself

References python.learner.Learner.Learner.specification.

def python.learner.Learner.Learner.setStopPolicy (   self,
  policy 
)

Setter for training stop policy.

Parameters
policythe training stop policy object
Returns
: leaner itself

References python.learner.Learner.Learner.stopPolicy.

def python.learner.Learner.Learner.toString (   self)

Returns a string that represents the object.

Returns
A string that represents the object.

References python.learner.Learner.Learner.__listOfFloatsToString(), and python.learner.Learner.Learner.__SERIALIZABLE_ATTRIBUTES.

Referenced by python.uq.learner.Learner.Learner.createMemento(), and python.learner.Learner.Learner.createMemento().

def python.learner.Learner.Learner.updateResults (   self,
  alpha,
  trainSubset,
  testSubset = None 
)

Member Data Documentation

python.learner.Learner.Learner.linearSystem = None
static

DMSystemMatrix object associated with this Learner.

Referenced by python.learner.Learner.Learner.doLearningIteration().

python.learner.Learner.Learner.testingOverall = None
static
python.learner.Learner.Learner.trainingOverall = None
static

The documentation for this class was generated from the following file: