sega_learn.utils.animator

 
Modules
       
matplotlib.animation
numpy
matplotlib.pyplot
sys

 
Classes
       
abc.ABC(builtins.object)
AnimationBase
ClassificationAnimation
ForcastingAnimation
RegressionAnimation

 
class AnimationBase(abc.ABC)
    AnimationBase(model, train_series, test_series, dynamic_parameter=None, static_parameters=None, keep_previous=None, **kwargs)
 
Base class for creating animations of machine learning models.
 
 
Method resolution order:
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, train_series, test_series, dynamic_parameter=None, static_parameters=None, keep_previous=None, **kwargs)
Initialize the animation base class.
 
Args:
    model: The forecasting model or any machine learning model.
    train_series: Training time series data.
    test_series: Testing time series data.
    dynamic_parameter: The parameter to update dynamically (e.g., 'window', 'alpha', 'beta').
    static_parameters: Static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    **kwargs: Additional customization options (e.g., colors, line styles).
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for the animation.
 
Args:
    title: Title of the plot.
    xlabel: Label for the x-axis.
    ylabel: Label for the y-axis.
    legend_loc: Location of the legend.
    grid: Whether to show grid lines.
    figsize: Size of the figure.
show(self)
Display the animation.
update_model(self, frame)
Abstract method to update the model for a given frame. Must be implemented by subclasses.
update_plot(self, frame)
Abstract method to update the plot for a given frame.Must be implemented by subclasses.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Data and other attributes defined here:
__abstractmethods__ = frozenset({'update_model', 'update_plot'})

 
class ClassificationAnimation(AnimationBase)
    ClassificationAnimation(model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, scaler=None, pca_components=2, plot_step=0.02, **kwargs)
 
Class for creating animations of classification models.
 
 
Method resolution order:
ClassificationAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, scaler=None, pca_components=2, plot_step=0.02, **kwargs)
Initialize the classification animation class.
 
Args:
    model: The classification model.
    X: Feature matrix (input data).
    y: Target vector (output data).
    test_size: Proportion of the dataset to include in the test split.
    dynamic_parameter: The parameter to update dynamically (e.g., 'alpha', 'beta').
    static_parameters: Additional static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    scaler: Optional scaler for preprocessing the data.
    pca_components: Number of components to use for PCA.
    plot_step: Resolution of the decision boundary mesh.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for classification animation.
update_model(self, frame)
Update the classification model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class ForcastingAnimation(AnimationBase)
    ForcastingAnimation(model, train_series, test_series, forecast_steps, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, **kwargs)
 
Class for creating animations of forecasting models.
 
 
Method resolution order:
ForcastingAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, train_series, test_series, forecast_steps, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, **kwargs)
Initialize the forecasting animation class.
 
Args:
    model: The forecasting model.
    train_series: Training time series data.
    test_series: Testing time series data.
    forecast_steps: Number of steps to forecast.
    dynamic_parameter: The parameter to update dynamically (e.g., 'window', 'alpha', 'beta').
    static_parameters: Static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    max_previous: Maximum number of previous lines to keep.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for forecasting animation.
update_model(self, frame)
Update the model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class RegressionAnimation(AnimationBase)
    RegressionAnimation(model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, pca_components=1, **kwargs)
 
Class for creating animations of regression models.
 
 
Method resolution order:
RegressionAnimation
AnimationBase
abc.ABC
builtins.object

Methods defined here:
__init__(self, model, X, y, test_size=0.3, dynamic_parameter=None, static_parameters=None, keep_previous=False, max_previous=None, pca_components=1, **kwargs)
Initialize the regression animation class.
 
Args:
    model: The regression model.
    X: Feature matrix (input data).
    y: Target vector (output data).
    test_size: Proportion of the dataset to include in the test split.
    dynamic_parameter: The parameter to update dynamically (e.g., 'alpha', 'beta').
    static_parameters: Additional static parameters for the model.
        Should be a dictionary with parameter names as keys and their values.
    keep_previous: Whether to keep all previous lines with reduced opacity.
    max_previous: Maximum number of previous lines to keep.
    pca_components: Number of components to use for PCA.
    **kwargs: Additional customization options (e.g., colors, line styles).
setup_plot(self, title, xlabel, ylabel, legend_loc='upper left', grid=True, figsize=(12, 6))
Set up the plot for regression animation.
update_model(self, frame)
Update the regression model for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).
update_plot(self, frame)
Update the plot for the current frame.
 
Args:
    frame: The current frame (e.g., parameter value).

Data and other attributes defined here:
__abstractmethods__ = frozenset()

Methods inherited from AnimationBase:
animate(self, frames, interval=150, blit=True, repeat=False)
Create the animation.
 
Args:
    frames: Range of frames (e.g., window sizes).
    interval: Delay between frames in milliseconds.
    blit: Whether to use blitting for faster rendering.
    repeat: Whether to repeat the animation.
save(self, filename, writer='pillow', fps=5, dpi=100)
Save the animation to a file.
 
Args:
    filename: Path to save the animation.
    writer: Writer to use (e.g., 'pillow' for GIF).
    fps: Frames per second.
    dpi: Dots per inch for the saved figure.
show(self)
Display the animation.

Data descriptors inherited from AnimationBase:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object