# Using Scikit-Learn within Larch¶

class larch.prelearning.Prelearner(dataframes, ca_columns=None, co_columns=None, classifier=None, fit=True, cache_file=None, output_name='prelearned_utility', appname='larch', **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.

Parameters: 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 (bool, default True) – Whether to fit this prelearner automatically on construction. 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. **kwargs – Any other keyword arguments are passed through to the classifier’s constructor.
class larch.prelearning.XGBoostPrelearner(dataframes, ca_columns=None, co_columns=None, cache_file=None, fit=True, output_name='prelearned_utility', **kwargs)