To create a custom gaze-prediction model in EyeTrax, you must subclass BaseModel and implement three internal methods. BaseModel handles feature scaling (using StandardScaler) and provides high-level train, predict, save, and load methods.
When implementing your subclass, you must provide implementations for:
_init_native(**kwargs): Initialize your model's internal state._native_train(X: np.ndarray, y: np.ndarray): The core training logic using scaled features._native_predict(X: np.ndarray) -> np.ndarray: The core prediction logic using scaled features.
Note that the public train and predict methods automatically apply feature scaling before calling your native implementations.
import numpy as np
from eyetrax.models.base import BaseModel
class MyCustomModel(BaseModel):
def _init_native(self, **kwargs):
# Initialize your specific model here
pass
def _native_train(self, X: np.ndarray, y: np.ndarray):
# Implement training logic using scaled X
pass
def _native_predict(self, X: np.ndarray) -> np.ndarray:
# Implement prediction logic using scaled X
return np.zeros((len(X), 2))
# Usage
model = MyCustomModel()
model.train(X_train, y_train)
predictions = model.predict(X_test)