pyPhenology.models.Ensemble¶
-
class
pyPhenology.models.
Ensemble
(core_models)[source]¶ Fit an ensemble of different models.
This model can fit multiple models into an ensemble where the weights are equal among all ensemble members.
Note that the core models must be passed initialized. They will be fit within the Ensemble model:
from pyPhenology import models, utils observations, predictors = utils.load_test_data(name='vaccinium') m1 = models.Thermaltime(parameters={'T':0}) m2 = models.Thermaltime(parameters={'T':5}) m3 = models.Uniforc(parameters={'t1':1}) m4 = models.Uniforc(parameters={'t1':30}) ensemble = models.Ensemble(core_models=[m1,m2,m3,m4]) ensemble.fit(observations, predictors)
-
__init__
(core_models)[source]¶ Ensemble model
core_models : list of pyPhenology models, or a saved model file
Methods
__init__
(core_models)Ensemble model ensemble_shape
([shape])Returns a tuple signifying the layers of submodels ie. fit
(observations, predictors[, n_jobs, …])Fit the underlying core models Parameters: observations : dataframe pandas dataframe of phenology observations get_params
()This returns list of dictionaries with parameters of each model in the ensemble predict
([to_predict, predictors, …])Make predictions.. save_params
(filename[, overwrite])Save model parameters score
([metric, doy_observed, to_predict, …])Get the scoring metric for fitted data Get the score on the dataset used for fitting (if fitting was done), otherwise set to_predict
, andpredictors
as used inmodel.predict()
.-
fit
(observations, predictors, n_jobs=1, verbose=False, debug=False, **kwargs)[source]¶ Fit the underlying core models Parameters:
- observations : dataframe
- pandas dataframe of phenology observations
- predictors : dataframe
- pandas dataframe of associated predictors
- n_jobs : int
- number of parallel processes to use
- kwargs :
- Other arguments passed to core model fitting (eg. optimzer methods)
-
get_params
()[source]¶ This returns list of dictionaries with parameters of each model in the ensemble
-
predict
(to_predict=None, predictors=None, aggregation='mean', n_jobs=1, **kwargs)[source]¶ Make predictions..
Predictions will be made using each core models, then a final prediction for each observation using the specified aggregation method.
- Parameters:
see core model description
- aggregation : str
- Either ‘mean’, ‘median’, or ‘none’. If using ‘none’ this returns an array of tuple of size (number of members, predictions).
- n_jobs : int
- number of parallel processes to use
-