def __init__(self,
               modelID,
               jobID,
               predictedField,
               experimentDir,
               reportKeyPatterns,
               optimizeKeyPattern,
               jobsDAO,
               modelCheckpointGUID,
               logLevel=None,
               predictionCacheMaxRecords=None):
    """
    Parameters:
    -------------------------------------------------------------------------
    modelID:            ID for this model in the models table

    jobID:              ID for this hypersearch job in the jobs table
    predictedField:     Name of the input field for which this model is being
                        optimized
    experimentDir:      Directory path containing the experiment's
                        description.py script
    reportKeyPatterns:  list of items from the results dict to include in
                        the report. These can be regular expressions.
    optimizeKeyPattern: Which report item, if any, we will be optimizing for.
                        This can also be a regular expression, but is an error
                        if it matches more than one key from the experiment's
                        results.
    jobsDAO:            Jobs data access object - the interface to the
                        jobs database which has the model's table.
    modelCheckpointGUID:
                        A persistent, globally-unique identifier for
                        constructing the model checkpoint key. If None, then
                        don't bother creating a model checkpoint.
    logLevel:           override logging level to this value, if not None
    predictionCacheMaxRecords:
                        Maximum number of records for the prediction output cache.
                        Pass None for default value.
    """

    # -----------------------------------------------------------------------
    # Initialize class constants
    # -----------------------------------------------------------------------
    self._MIN_RECORDS_TO_BE_BEST = int(Configuration.get('nupic.hypersearch.bestModelMinRecords'))
    self._MATURITY_MAX_CHANGE = float(Configuration.get('nupic.hypersearch.maturityPctChange'))
    self._MATURITY_NUM_POINTS = int(Configuration.get('nupic.hypersearch.maturityNumPoints'))

    # -----------------------------------------------------------------------
    # Initialize instance variables
    # -----------------------------------------------------------------------
    self._modelID = modelID
    self._jobID = jobID
    self._predictedField = predictedField
    self._experimentDir = experimentDir
    self._reportKeyPatterns = reportKeyPatterns
    self._optimizeKeyPattern = optimizeKeyPattern
    self._jobsDAO = jobsDAO
    self._modelCheckpointGUID = modelCheckpointGUID
    self._predictionCacheMaxRecords = predictionCacheMaxRecords

    self._isMaturityEnabled = bool(int(Configuration.get('nupic.hypersearch.enableModelMaturity')))

    self._logger = logging.getLogger(".".join( ['com.numenta',
                       self.__class__.__module__, self.__class__.__name__]))

    self._optimizedMetricLabel = None
    self._reportMetricLabels = []


    # Our default completion reason
    self._cmpReason = ClientJobsDAO.CMPL_REASON_EOF

    if logLevel is not None:
      self._logger.setLevel(logLevel)

    # The manager object to compute the metrics for this model
    self.__metricMgr = None

    # Will be set to a new instance of OPFTaskDriver by __runTask()
    #self.__taskDriver = None

    # Current task control parameters. Will be set by __runTask()
    self.__task = None

    # Will be set to a new instance of PeriodicActivityManager by __runTask()
    self._periodic = None

    # Will be set to streamDef string by _runTask()
    self._streamDef = None

    # Will be set to new OpfExperiment instance by run()
    self._model = None

    # Will be set to new InputSource by __runTask()
    self._inputSource = None

    # 0-based index of the record being processed;
    # Initialized and updated by __runTask()
    self._currentRecordIndex = None

    # Interface to write predictions to a persistent storage
    self._predictionLogger = None

    # In-memory cache for predictions. Predictions are written here for speed
    # when they don't need to be written to a persistent store
    self.__predictionCache = deque()

    # Flag to see if this is the best model in the job (as determined by the
    # model chooser logic). This is essentially a cache of the value in the
    # ClientJobsDB
    self._isBestModel = False

    # Flag to see if there is a best model (not necessarily this one)
    # stored in the DB
    self._isBestModelStored = False


    # -----------------------------------------------------------------------
    # Flags for model cancelation/checkpointing
    # -----------------------------------------------------------------------

    # Flag to see if the job that this model is part of
    self._isCanceled = False

    # Flag to see if model was killed, either by the model terminator or by the
    # hypsersearch implementation (ex. the a swarm is killed/matured)
    self._isKilled = False

    # Flag to see if the model is matured. In most cases, this means that we
    # should stop running the model. The only execption is if this model is the
    # best model for the job, in which case it should continue running.
    self._isMature = False

    # Event to see if interrupt signal has been sent
    self._isInterrupted = threading.Event()

    # -----------------------------------------------------------------------
    # Facilities for measuring model maturity
    # -----------------------------------------------------------------------
    # List of tuples, (iteration, metric), used to see if the model has 'matured'
    self._metricRegression = regression.AveragePctChange(windowSize=self._MATURITY_NUM_POINTS)

    self.__loggedMetricPatterns = []
def __init__ ( self , modelID , jobID , predictedField , experimentDir , reportKeyPatterns , optimizeKeyPattern , jobsDAO , modelCheckpointGUID , logLevel = None , predictionCacheMaxRecords = None ) : self . _MIN_RECORDS_TO_BE_BEST = int ( Configuration . get ( 'nupic.hypersearch.bestModelMinRecords' ) ) self . _MATURITY_MAX_CHANGE = float ( Configuration . get ( 'nupic.hypersearch.maturityPctChange' ) ) self . _MATURITY_NUM_POINTS = int ( Configuration . get ( 'nupic.hypersearch.maturityNumPoints' ) ) self . _modelID = modelID self . _jobID = jobID self . _predictedField = predictedField self . _experimentDir = experimentDir self . _reportKeyPatterns = reportKeyPatterns self . _optimizeKeyPattern = optimizeKeyPattern self . _jobsDAO = jobsDAO self . _modelCheckpointGUID = modelCheckpointGUID self . _predictionCacheMaxRecords = predictionCacheMaxRecords self . _isMaturityEnabled = bool ( int ( Configuration . get ( 'nupic.hypersearch.enableModelMaturity' ) ) ) self . _logger = logging . getLogger ( "." . join ( [ 'com.numenta' , self . __class__ . __module__ , self . __class__ . __name__ ] ) ) self . _optimizedMetricLabel = None self . _reportMetricLabels = [ ] self . _cmpReason = ClientJobsDAO . CMPL_REASON_EOF if logLevel is not None : self . _logger . setLevel ( logLevel ) self . __metricMgr = None self . __task = None self . _periodic = None self . _streamDef = None self . _model = None self . _inputSource = None self . _currentRecordIndex = None self . _predictionLogger = None self . __predictionCache = deque ( ) self . _isBestModel = False self . _isBestModelStored = False self . _isCanceled = False self . _isKilled = False self . _isMature = False self . _isInterrupted = threading . Event ( ) self . _metricRegression = regression . AveragePctChange ( windowSize = self . _MATURITY_NUM_POINTS ) self . __loggedMetricPatterns = [ ]
Parameters:
    -------------------------------------------------------------------------
    modelID:            ID for this model in the models table

    jobID:              ID for this hypersearch job in the jobs table
    predictedField:     Name of the input field for which this model is being
                        optimized
    experimentDir:      Directory path containing the experiment's
                        description.py script
    reportKeyPatterns:  list of items from the results dict to include in
                        the report. These can be regular expressions.
    optimizeKeyPattern: Which report item, if any, we will be optimizing for.
                        This can also be a regular expression, but is an error
                        if it matches more than one key from the experiment's
                        results.
    jobsDAO:            Jobs data access object - the interface to the
                        jobs database which has the model's table.
    modelCheckpointGUID:
                        A persistent, globally-unique identifier for
                        constructing the model checkpoint key. If None, then
                        don't bother creating a model checkpoint.
    logLevel:           override logging level to this value, if not None
    predictionCacheMaxRecords:
                        Maximum number of records for the prediction output cache.
                        Pass None for default value.