models.columns#
Module: models.columns#
Inheritance diagram for ISLP.models.columns:
Column#
- class ISLP.models.columns.Column(idx: Any, name: str, is_categorical: bool = False, is_ordinal: bool = False, columns: tuple = (), encoder: Any = None)#
- Bases: - NamedTuple- A column extractor with a possible encoder (following sklearn fit/transform template). - Methods - count(value, /)- Return number of occurrences of value. - fit_encoder(X)- Fit self.encoder. - get_columns(X[, fit])- Extract associated column from X, encoding it with self.encoder if not None. - index(value[, start, stop])- Return first index of value. - __init__(*args, **kwargs)#
 - count(value, /)#
- Return number of occurrences of value. 
 - fit_encoder(X)#
- Fit self.encoder. - Parameters:
- Xarray-like
- X on which encoder will be fit. 
 
- Returns:
- None
 
 
 - get_columns(X, fit=False)#
- Extract associated column from X, encoding it with self.encoder if not None. - Parameters:
- Xarray-like
- X on which model matrix will be evaluated. If a pd.DataFrame or pd.Series, variables that are of categorical dtype will be treated as categorical. 
- fitbool
- If True, fit self.encoder on corresponding column. 
 
- Returns:
- colsnp.ndarray
- Evaluated columns – if an encoder is used, several columns may be produced. 
- names(str,)
- Column names 
 
 
 - index(value, start=0, stop=sys.maxsize, /)#
- Return first index of value. - Raises ValueError if the value is not present. 
 
