emat/multitarget/frameable.py
def _post_predict(self, X, Yhat, on_error='raise'):
		"""Attach index and/or column labels to predictions."""

		if isinstance(X, pandas.DataFrame):
			idx = X.index
		else:
			idx = None

		cols = None
		if self._Y_columns is not None:
			if isinstance(self._Y_columns, str):
				if len(Yhat.shape) > 1 and Yhat.shape[1] == 1:
					cols = [self._Y_columns]
				elif len(Yhat.shape) == 1:
					cols = self._Y_columns
			else:
				if len(Yhat.shape) > 1 and Yhat.shape[1] == len(self._Y_columns):
					cols = self._Y_columns

		if idx is not None or cols is not None:
			if isinstance(cols, str):
				try:
					Yhat = pandas.Series(
						Yhat,
						index=idx,
						name=self._Y_columns,
					)
				except ValueError:
					if on_error == 'raise':
						raise
			else:
				try:
					Yhat = pandas.DataFrame(
						Yhat,
						index=idx,
						columns=self._Y_columns,
					)
				except ValueError:
					if on_error == 'raise':
						raise
		return Yhat
Attach index and/or column labels to predictions.
Attach index and/or column labels to predictions.
Attach index and / or column labels to predictions .
def _post_predict(self, X, Yhat, on_error='raise'):
		if isinstance(X, pandas.DataFrame):
			idx = X.index
		else:
			idx = None
		cols = None
		if self._Y_columns is not None:
			if isinstance(self._Y_columns, str):
				if len(Yhat.shape) > 1 and Yhat.shape[1] == 1:
					cols = [self._Y_columns]
				elif len(Yhat.shape) == 1:
					cols = self._Y_columns
			else:
				if len(Yhat.shape) > 1 and Yhat.shape[1] == len(self._Y_columns):
					cols = self._Y_columns
		if idx is not None or cols is not None:
			if isinstance(cols, str):
				try:
					Yhat = pandas.Series(
						Yhat,
						index=idx,
						name=self._Y_columns,
					)
				except ValueError:
					if on_error == 'raise':
						raise
			else:
				try:
					Yhat = pandas.DataFrame(
						Yhat,
						index=idx,
						columns=self._Y_columns,
					)
				except ValueError:
					if on_error == 'raise':
						raise
		return Yhat
def _post_predict ( self , X , Yhat , on_error = 'raise' ) : if isinstance ( X , pandas . DataFrame ) : idx = X . index else : idx = None cols = None if self . _Y_columns is not None : if isinstance ( self . _Y_columns , str ) : if len ( Yhat . shape ) > 1 and Yhat . shape [ 1 ] == 1 : cols = [ self . _Y_columns ] elif len ( Yhat . shape ) == 1 : cols = self . _Y_columns else : if len ( Yhat . shape ) > 1 and Yhat . shape [ 1 ] == len ( self . _Y_columns ) : cols = self . _Y_columns if idx is not None or cols is not None : if isinstance ( cols , str ) : try : Yhat = pandas . Series ( Yhat , index = idx , name = self . _Y_columns , ) except ValueError : if on_error == 'raise' : raise else : try : Yhat = pandas . DataFrame ( Yhat , index = idx , columns = self . _Y_columns , ) except ValueError : if on_error == 'raise' : raise return Yhat
Attach index and/or column labels to predictions.
Attach index and / or column labels to predictions .
"""Attach index and/or column labels to predictions."""
self
X
Yhat
on_error