models.columns#

Module: models.columns#

Inheritance diagram for ISLP.models.columns:

digraph inheritanceb805e81f93 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "models.columns.Column" [URL="#ISLP.models.columns.Column",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A column extractor with a possible"]; }

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)#
columns: tuple#

Alias for field number 4

count(value, /)#

Return number of occurrences of value.

encoder: Any#

Alias for field number 5

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

idx: Any#

Alias for field number 0

index(value, start=0, stop=sys.maxsize, /)#

Return first index of value.

Raises ValueError if the value is not present.

is_categorical: bool#

Alias for field number 2

is_ordinal: bool#

Alias for field number 3

name: str#

Alias for field number 1