zoo
¶
Classes:
Name | Description |
---|---|
LSTMClassifierInitialized |
A specialized LSTM-based classifier designed for handling rolling or |
LogisticRegressionInitialized |
Logistic Regression model for classification. |
MultiLayerPerceptronInitialized |
Logistic Regression model for classification. |
LSTMClassifierInitialized
¶
LSTMClassifierInitialized(
n_features: int = 10,
loss_fn: Union[
str, Callable
] = "binary_cross_entropy_with_logits",
optimizer_fn: Union[str, Type[Optimizer]] = "sgd",
lr: float = 0.001,
output_is_logit: bool = True,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
**kwargs
)
Bases: RollingClassifierInitialized
A specialized LSTM-based classifier designed for handling rolling or incremental data classification tasks.
This class leverages LSTM (Long Short-Term Memory) modules to process
and classify sequential data. It is built on top of the base
RollingClassifierInitialized
class, inheriting its functionality for
handling incremental learning tasks. Customization options include the
definition of the loss function, optimizer, learning rate, and other
hyperparameters to suit various use cases.
Attributes:
Name | Type | Description |
---|---|---|
n_features |
int
|
Number of features in the input data. It defines the input dimension for the LSTM module. |
loss_fn |
Union[str, Callable]
|
Specifies the loss function to be used for model training. Can either be a predefined string or a callable function. |
optimizer_fn |
Union[str, Type[Optimizer]]
|
Defines the optimizer to be utilized in training. Accepts either a string representing the optimizer name or the optimizer class itself. |
lr |
float
|
Learning rate for the chosen optimizer. |
output_is_logit |
bool
|
Indicates whether the model output is a raw logit (pre-sigmoid/softmax output). |
is_feature_incremental |
bool
|
Specifies if the model supports adding new features incrementally. |
device |
str
|
Designates the device for computation, e.g., 'cpu' or 'cuda'. |
seed |
int
|
Random seed for reproducibility of results. |
kwargs |
dict
|
Additional arguments passed during the initialization. |
Methods:
Name | Description |
---|---|
learn_many |
Learns from multiple examples using the rolling window. |
learn_one |
Learns from one example using the rolling window. |
predict_proba_many |
Predicts probabilities for many examples. |
predict_proba_one |
Predicts class probabilities using the rolling window. |
Source code in deep_river/classification/zoo.py
learn_many
¶
Learns from multiple examples using the rolling window.
Source code in deep_river/classification/rolling_classifier.py
learn_one
¶
Learns from one example using the rolling window.
Source code in deep_river/classification/rolling_classifier.py
predict_proba_many
¶
Predicts probabilities for many examples.
Source code in deep_river/classification/rolling_classifier.py
predict_proba_one
¶
Predicts class probabilities using the rolling window.
Source code in deep_river/classification/rolling_classifier.py
LogisticRegressionInitialized
¶
LogisticRegressionInitialized(
n_features: int = 10,
loss_fn: Union[
str, Callable
] = "binary_cross_entropy_with_logits",
optimizer_fn: Union[str, Type[Optimizer]] = "sgd",
lr: float = 0.001,
output_is_logit: bool = True,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
**kwargs
)
Bases: ClassifierInitialized
Logistic Regression model for classification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loss_fn
|
str or Callable
|
Loss function to be used for training the wrapped model. |
'binary_cross_entropy_with_logits'
|
optimizer_fn
|
str or Callable
|
Optimizer to be used for training the wrapped model. |
'sgd'
|
lr
|
float
|
Learning rate of the optimizer. |
0.001
|
output_is_logit
|
bool
|
Whether the module produces logits as output. If true, either softmax or sigmoid is applied to the outputs when predicting. |
True
|
is_class_incremental
|
bool
|
Whether the classifier should adapt to the appearance of previously unobserved classes by adding an unit to the output layer of the network. |
required |
is_feature_incremental
|
bool
|
Whether the model should adapt to the appearance of previously features by adding units to the input layer of the network. |
False
|
device
|
str
|
Device to run the wrapped model on. Can be "cpu" or "cuda". |
'cpu'
|
seed
|
int
|
Random seed to be used for training the wrapped model. |
42
|
**kwargs
|
Parameters to be passed to the |
{}
|
Methods:
Name | Description |
---|---|
learn_many |
Updates the model with multiple instances for supervised learning. |
learn_one |
Learns from a single example. |
predict_proba_many |
Predicts probabilities for multiple examples. |
predict_proba_one |
Predicts probabilities for a single example. |
Source code in deep_river/classification/zoo.py
learn_many
¶
Updates the model with multiple instances for supervised learning.
The function updates the observed features and targets based on the input data. It converts the data from a pandas DataFrame to a tensor format before learning occurs. The updates to the model are executed through an internal learning mechanism.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
DataFrame
|
The data-frame containing instances to be learned by the model. Each row represents a single instance, and each column represents a feature. |
required |
y
|
Series
|
The target values corresponding to the instances in |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in deep_river/classification/classifier.py
learn_one
¶
Learns from a single example.
predict_proba_many
¶
Predicts probabilities for multiple examples.
Source code in deep_river/classification/classifier.py
predict_proba_one
¶
Predicts probabilities for a single example.
Source code in deep_river/classification/classifier.py
MultiLayerPerceptronInitialized
¶
MultiLayerPerceptronInitialized(
n_features: int = 10,
n_width: int = 5,
n_layers: int = 5,
loss_fn: Union[
str, Callable
] = "binary_cross_entropy_with_logits",
optimizer_fn: Union[str, Type[Optimizer]] = "sgd",
lr: float = 0.001,
output_is_logit: bool = True,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
**kwargs
)
Bases: ClassifierInitialized
Logistic Regression model for classification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loss_fn
|
str or Callable
|
Loss function to be used for training the wrapped model. |
'binary_cross_entropy_with_logits'
|
optimizer_fn
|
str or Callable
|
Optimizer to be used for training the wrapped model. |
'sgd'
|
lr
|
float
|
Learning rate of the optimizer. |
0.001
|
output_is_logit
|
bool
|
Whether the module produces logits as output. If true, either softmax or sigmoid is applied to the outputs when predicting. |
True
|
is_class_incremental
|
bool
|
Whether the classifier should adapt to the appearance of previously unobserved classes by adding an unit to the output layer of the network. |
required |
is_feature_incremental
|
bool
|
Whether the model should adapt to the appearance of previously features by adding units to the input layer of the network. |
False
|
device
|
str
|
Device to run the wrapped model on. Can be "cpu" or "cuda". |
'cpu'
|
seed
|
int
|
Random seed to be used for training the wrapped model. |
42
|
**kwargs
|
Parameters to be passed to the |
{}
|
Methods:
Name | Description |
---|---|
learn_many |
Updates the model with multiple instances for supervised learning. |
learn_one |
Learns from a single example. |
predict_proba_many |
Predicts probabilities for multiple examples. |
predict_proba_one |
Predicts probabilities for a single example. |
Source code in deep_river/classification/zoo.py
learn_many
¶
Updates the model with multiple instances for supervised learning.
The function updates the observed features and targets based on the input data. It converts the data from a pandas DataFrame to a tensor format before learning occurs. The updates to the model are executed through an internal learning mechanism.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
DataFrame
|
The data-frame containing instances to be learned by the model. Each row represents a single instance, and each column represents a feature. |
required |
y
|
Series
|
The target values corresponding to the instances in |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in deep_river/classification/classifier.py
learn_one
¶
Learns from a single example.
predict_proba_many
¶
Predicts probabilities for multiple examples.
Source code in deep_river/classification/classifier.py
predict_proba_one
¶
Predicts probabilities for a single example.