def __init__(self, data, target=None, *args, **kwargs): if data is None and target is None: msg = '{0} must have either data or target' raise ValueError(msg.format(self.__class__.__name__)) elif data is None and not is_list_like(target): msg = 'target must be list-like when data is None' raise ValueError(msg) data, target = skaccessors._maybe_sklearn_data(data, target) data, target = smaccessors._maybe_statsmodels_data(data, target) # retrieve target_name if isinstance(data, ModelFrame): target_name = data.target_name data, target = self._maybe_convert_data(data, target, *args, **kwargs) if target is not None and not is_list_like(target): if target in data.columns: target_name = target df = data else: msg = "Specified target '{0}' is not included in data" raise ValueError(msg.format(target)) self._target_name = target_name else: df, target = self._concat_target(data, target) if isinstance(target, pd.Series): self._target_name = target.name elif isinstance(target, pd.DataFrame): if len(target.columns) > 1: self._target_name = target.columns else: self._target_name = target.columns[0] else: # target may be None self._target_name = self._TARGET_NAME pd.DataFrame.__init__(self, df)