SG++
python.learner.LearnerBuilder.LearnerBuilder Class Reference

Implement mechanisms to create customized learning system. More...

Inheritance diagram for python.learner.LearnerBuilder.LearnerBuilder:

Classes

class  CGSolverDescriptor
 CGSolver Descriptor helps to implement fluid interface patter on python it encapsulates functionality concerning creation of the CG-Solver. More...
 
class  FoldingDescriptor
 Folding Descriptor helps to implement fluid interface patter on python it encapsulates functionality concerning the usage for N-fold cross-validation. More...
 
class  GridDescriptor
 Grid Descriptor helps to implement fluid interface patter on python it encapsulates functionality concerning creation of the grid. More...
 
class  SpecificationDescriptor
 TrainingSpecification Descriptor helps to implement fluid interface patter on python it encapsulates functionality concerning creation of the training specification. More...
 
class  StopPolicyDescriptor
 TrainingStopPolicy Descriptor helps to implement fluid interface patter on python it encapsulates functionality concerning creation of the training stop policy. More...
 

Public Member Functions

def __init__ (self)
 Default constuctor. More...
 
def andGetResult (self)
 Returns the builded learner (regressor or classifier), should be called in the and of construction. More...
 
def buildClassifier (self)
 Start building Classifier. More...
 
def buildRegressor (self)
 Start building Regressor. More...
 
def getCheckpointController (self)
 Returns the checkpoint controller. More...
 
def getLearner (self)
 Returns the object of learner subclass, that is currently beeing constructed. More...
 
def withCGSolver (self)
 Start description of parameters of CG-Solver for learner. More...
 
def withCheckpointController (self, controller)
 Attaches checkpoint controller to the learner. More...
 
def withFilesFoldingPolicy (self)
 Signals to use N-fold cross validation from a set of files. More...
 
def withGrid (self)
 Start description of parameters of CG-Solver for learner. More...
 
def withInitialAlphaFromARFFFile (self, filename)
 Signals to use initial data for alpha vector from ARFF file. More...
 
def withProgressPresenter (self, presentor)
 Attaches progress presentor to the learner. More...
 
def withRandomFoldingPolicy (self)
 Signals to use N-fold cross validation with random folding rule. More...
 
def withSequentialFoldingPolicy (self)
 Signals to use N-fold cross validation with sequential folding rule. More...
 
def withSpecification (self)
 Start description of specification parameters for learner. More...
 
def withStartingIterationNumber (self, iteration)
 Set the starting iteration number ane return the builder object. More...
 
def withStopPolicy (self)
 Start description of parameters of stop-policy for learner. More...
 
def withStratifiedFoldingPolicy (self)
 Signals to use N-fold cross validation with stratified folding rule. More...
 
def withTestingDataFromARFFFile (self, filename)
 Signals to use data from ARFF file for testing dataset. More...
 
def withTestingDataFromCSVFile (self, filename)
 Signals to use data from CSV file for testing dataset. More...
 
def withTestingDataFromNumPyArray (self, points, values, name="test")
 
def withTrainingDataFromARFFFile (self, filename, name="train")
 Signals to use data from ARFF file for training dataset. More...
 
def withTrainingDataFromCSVFile (self, filename, name="train")
 Signals to use data from CSV file for training dataset. More...
 
def withTrainingDataFromNumPyArray (self, points, values, name="train")
 

Detailed Description

Implement mechanisms to create customized learning system.

Usage examples

To create a learning system first define if it should be for classification

1 import from pysgpp.extensions.datadriven.learner.LearnerBuilder as LearnerBuilder
2 builder = LearnerBuilder()
3 builder = builder.buildClassifier()

or regression

1 builder = builder.buildRegressor()

LearnerBuilder is implementing Fluent Interface design pattern it means it operates as an automata, switching in some state where you can set all parameters associated with some category. For example to define the grid parameters you switch the builder into GridDescriptor set with

1 builder = builder.withGrid()...

and then defines corresponding parameters:

1 builder = builder.withGrid().withLevel(5).withBorder(Types.BorderTypes.TRAPEZOIDBOUNDARY)

Builder can automatically switches to the next state

1 builder.withGrid()...withCGSolver().withAccuracy(0.00000001)...

After all parameters are set you can return the constructed learning system with

1 builder.andGetResult()

The complete construction could look like following:

1 classifier = builder.buildClassifier()\
2  .withTrainingDataFromARFFFile("./datasets/classifier.train.arff")\
3  .withTestingDataFromARFFFile("./datasets/classifier.test.arff")\
4  .withGrid().withLevel(2)\
5  .withSpecification().withLambda(0.00001).withAdaptPoints(2)\
6  .withStopPolicy().withAdaptiveItarationLimit(1)\
7  .withCGSolver().withImax(500)\
8  .withProgressPresenter(InfoToFile("./presentor.test"))\
9  .andGetResult()

Parameters and where I can set them?

Constructor & Destructor Documentation

def python.learner.LearnerBuilder.LearnerBuilder.__init__ (   self)

Default constuctor.

References python.learner.LearnerBuilder.LearnerBuilder.__gridDescriptor, python.learner.LearnerBuilder.LearnerBuilder.__learner, python.learner.LearnerBuilder.LearnerBuilder.__specificationDescriptor, and python.learner.LearnerBuilder.LearnerBuilder.__stopPolicyDescriptor.

Member Function Documentation

def python.learner.LearnerBuilder.LearnerBuilder.andGetResult (   self)

Returns the builded learner (regressor or classifier), should be called in the and of construction.

Returns
: Learner (Classifier of Regressor)

References python.learner.LearnerBuilder.LearnerBuilder.__gridDescriptor, python.learner.LearnerBuilder.LearnerBuilder.__learner, python.learner.LearnerBuilder.LearnerBuilder.__specificationDescriptor, and sgpp::op_factory.createOperationMultipleEval().

def python.learner.LearnerBuilder.LearnerBuilder.buildClassifier (   self)

Start building Classifier.

Returns
: LearnerBuilder itself

References python.learner.LearnerBuilder.LearnerBuilder.__buildCommonLearner(), and python.learner.LearnerBuilder.LearnerBuilder.__learner.

def python.learner.LearnerBuilder.LearnerBuilder.buildRegressor (   self)

Start building Regressor.

Returns
: LearnerBuilder itself

References python.learner.LearnerBuilder.LearnerBuilder.__buildCommonLearner(), and python.learner.LearnerBuilder.LearnerBuilder.__learner.

def python.learner.LearnerBuilder.LearnerBuilder.getCheckpointController (   self)

Returns the checkpoint controller.

Returns
the checkpoint controller

References python.learner.LearnerBuilder.LearnerBuilder.__checkpointController.

def python.learner.LearnerBuilder.LearnerBuilder.getLearner (   self)

Returns the object of learner subclass, that is currently beeing constructed.

Returns
the object of learner subclass, that is currently beeing constructed

References python.learner.LearnerBuilder.LearnerBuilder.__learner.

def python.learner.LearnerBuilder.LearnerBuilder.withCGSolver (   self)

Start description of parameters of CG-Solver for learner.

Returns
: CGSolverDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__solverDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withCheckpointController (   self,
  controller 
)

Attaches checkpoint controller to the learner.

Parameters
controllerCheckpoint controller which implements LearnerEventController
Returns
: LearnerBuilder

References python.learner.LearnerBuilder.LearnerBuilder.__checkpointController, and python.learner.LearnerBuilder.LearnerBuilder.__learner.

def python.learner.LearnerBuilder.LearnerBuilder.withFilesFoldingPolicy (   self)

Signals to use N-fold cross validation from a set of files.

Returns
: FoldingDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__foldingPolicyDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withGrid (   self)

Start description of parameters of CG-Solver for learner.

Returns
: GridDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__gridDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withInitialAlphaFromARFFFile (   self,
  filename 
)

Signals to use initial data for alpha vector from ARFF file.

Parameters
filenameFilename where to read the data from
Returns
: LearnerBuilder object itself
def python.learner.LearnerBuilder.LearnerBuilder.withProgressPresenter (   self,
  presentor 
)

Attaches progress presentor to the learner.

Parameters
presentorprogress presentor which implements LearnerEventController
Returns
: LearnerBuilder
def python.learner.LearnerBuilder.LearnerBuilder.withRandomFoldingPolicy (   self)

Signals to use N-fold cross validation with random folding rule.

Returns
: FoldingDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__foldingPolicyDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withSequentialFoldingPolicy (   self)

Signals to use N-fold cross validation with sequential folding rule.

Returns
: FoldingDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__foldingPolicyDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withSpecification (   self)

Start description of specification parameters for learner.

Returns
: SpecificationDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__specificationDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withStartingIterationNumber (   self,
  iteration 
)

Set the starting iteration number ane return the builder object.

Parameters
iterationinteger starting iteration number
Returns
: LeanreBuilder
def python.learner.LearnerBuilder.LearnerBuilder.withStopPolicy (   self)

Start description of parameters of stop-policy for learner.

Returns
: StopPolicyDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__stopPolicyDescriptor.

Referenced by python.uq.learner.builder.RegressorSpecificationDescriptor.RegressorSpecificationDescriptor.create().

def python.learner.LearnerBuilder.LearnerBuilder.withStratifiedFoldingPolicy (   self)

Signals to use N-fold cross validation with stratified folding rule.

Returns
: FoldingDescriptor

References python.learner.LearnerBuilder.LearnerBuilder.__foldingPolicyDescriptor.

def python.learner.LearnerBuilder.LearnerBuilder.withTestingDataFromARFFFile (   self,
  filename 
)

Signals to use data from ARFF file for testing dataset.

Parameters
filenameFilename where to read the data from
Returns
: LearnerBuilder object itself
def python.learner.LearnerBuilder.LearnerBuilder.withTestingDataFromCSVFile (   self,
  filename 
)

Signals to use data from CSV file for testing dataset.

Parameters
filenameFilename where to read the data from
Returns
: LearnerBuilder object itself
def python.learner.LearnerBuilder.LearnerBuilder.withTestingDataFromNumPyArray (   self,
  points,
  values,
  name = "test" 
)
def python.learner.LearnerBuilder.LearnerBuilder.withTrainingDataFromARFFFile (   self,
  filename,
  name = "train" 
)

Signals to use data from ARFF file for training dataset.

Parameters
filenameFilename where to read the data from
nameCategory name, default: "train"
Returns
: LearnerBuilder
def python.learner.LearnerBuilder.LearnerBuilder.withTrainingDataFromCSVFile (   self,
  filename,
  name = "train" 
)

Signals to use data from CSV file for training dataset.

Parameters
filenameFilename where to read the data from
nameCategory name, default: "train"
Returns
: LearnerBuilder
def python.learner.LearnerBuilder.LearnerBuilder.withTrainingDataFromNumPyArray (   self,
  points,
  values,
  name = "train" 
)

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