Skip to content

Predict Method

Functions

predict(self, X)

Generate output predictions for the input samples.

Parameters:

Name Type Description Default
X ndarray

Input data.

required

Returns:

Type Description

numpy.ndarray: Predictions for the input data.

Example
predictions = model.predict(X_test)
Source code in microkeras/models/sequential/predict.py
def predict(self, X):
    """
    Generate output predictions for the input samples.

    Args:
        X (numpy.ndarray): Input data.

    Returns:
        numpy.ndarray: Predictions for the input data.

    Example:
        ```python
        predictions = model.predict(X_test)
        ```
    """
    # Transpose the input data
    X = X.T

    # Forward pass
    forward(self, X)

    # Return the output of the last layer
    predictions = self.layers[-1].A

    # Transpose the predictions to match the expected output shape
    return predictions.T