Using Scikit-Learn within Larch¶
Prelearner(dataframes, ca_columns=None, co_columns=None, classifier=None, fit=True, cache_file=None, output_name='prelearned_utility', appname='larch', grid_cv_params=None, grid_cv_kwds=None, validation_dataframes=None, **kwargs)¶
A prelearner for use with Larch.
A prelearner uses a machine learning classifier to make an initial prediction of the result. This initial prediction is then added as an input data column for Larch, effectively creating a chained classifier.
- training_X (pandas.DataFrame) – The exogenous variables.
- training_Y (pandas.DataFrame) – The observed choices in the training data.
- training_W (pandas.DataFrame, optional) – The weights.
- classifier (sklearn Classifier or Regressor) – This is the class object for the selected classifier, not an existing instance. This classifier or Regressor will be instantiated and trained using the data above to generate the prediction.
- fit (dict or False, optional) – A dictionary of arguments to pass to the fit method of the classifier, or set to False to not fit the classifier during the initialization of this object.
- cache_file (str, optional) – A cache file name to store the trained prelearner. If just a filename is given, it will be stored in appdirs.user_cache_file(). If instead an absolute path or a relative path beginning with ‘.’ is given, that location will be used. If the file exists, it will be loaded instead of re-training.
- output_name (str, default 'prelearned_utility') – The name of the output column from this prelearner.
- grid_cv_params (dict or List[dict], optional) – If given, this is used as the param_grid argument
to initialize a
sklearn.model_selection.GridSearchCVwrapped around the classifier, instead of using the classifier directly.
- grid_cv_kwds (dict, optional) – If grid_cv_params is given, this dict gives other keyword
arguments given to
- **kwargs – Any other keyword arguments are passed through to the classifier’s constructor.
XGBoostPrelearner(dataframes, ca_columns=None, co_columns=None, cache_file=None, fit=True, output_name='prelearned_utility', **kwargs)¶