From fdc4dedf867566ed90b832fc11020e3d0b432940 Mon Sep 17 00:00:00 2001 From: Soham Date: Sat, 7 Feb 2026 15:37:02 +0530 Subject: [PATCH 1/2] Create models_gaze_engineered dictionary with models compatible for 5-feature X-axis prediction and enables proper model selection for predict_new_data_simple function --- app/services/gaze_tracker.py | 49 +++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/app/services/gaze_tracker.py b/app/services/gaze_tracker.py index 7d1f7ce..7208881 100644 --- a/app/services/gaze_tracker.py +++ b/app/services/gaze_tracker.py @@ -67,6 +67,46 @@ ) )} +models_gaze_engineered = { + "Linear Regression": make_pipeline( + StandardScaler(), + linear_model.LinearRegression() + ), + "Ridge Regression": make_pipeline( + StandardScaler(), + linear_model.Ridge() + ), + "Lasso Regression": make_pipeline( + StandardScaler(), + linear_model.Lasso() + ), + "Elastic Net": make_pipeline( + StandardScaler(), + linear_model.ElasticNet(alpha=1.0, l1_ratio=0.5) + ), + "Bayesian Ridge": make_pipeline( + StandardScaler(), + linear_model.BayesianRidge() + ), + "SGD Regressor": make_pipeline( + StandardScaler(), + linear_model.SGDRegressor() + ), + "Support Vector Regressor": make_pipeline( + StandardScaler(), + SVR(kernel="linear") + ), + "Random Forest Regressor": make_pipeline( + StandardScaler(), + RandomForestRegressor( + n_estimators=200, + max_depth=10, + min_samples_split=5, + random_state=42 + ) + ) +} + # Set the scoring metrics for GridSearchCV to r2_score and mean_absolute_error scoring = { "r2": make_scorer(r2_score), @@ -255,9 +295,11 @@ def predict_new_data_simple( calib_csv_path, predict_csv_path, iris_data, + model_name_X="Linear Regression", + model_name_Y="Linear Regression", screen_width=None, screen_height=None, -): +): # ============================ # CONFIG (WebGazer-inspired) # ============================ @@ -328,8 +370,9 @@ def predict_new_data_simple( # ============================ # MODELS # ============================ - model_x = make_pipeline(StandardScaler(), Ridge(alpha=1.0)) - model_y = make_pipeline(StandardScaler(), Ridge(alpha=1.0)) + + model_x=models_gaze_engineered.get(model_name_X,models_gaze_engineered['Linear Regression']) + model_y=models.get(model_name_Y,models['Linear Regression']) model_x.fit(X_train_x, y_train_x) model_y.fit(X_train_y, y_train_y) From a5bd9ffdd86deed7999871b55fe7ce8fcd64f1a3 Mon Sep 17 00:00:00 2001 From: Soham Date: Sat, 7 Feb 2026 15:38:27 +0530 Subject: [PATCH 2/2] Fix : use requested model name for gaze estimation with predict_new_data_simple --- app/routes/session.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/routes/session.py b/app/routes/session.py index 1db1859..c7e13a0 100644 --- a/app/routes/session.py +++ b/app/routes/session.py @@ -153,8 +153,8 @@ def batch_predict(): iris_data = data["iris_tracking_data"] screen_width = data.get("screen_width") screen_height = data.get("screen_height") - model_X = data.get("model_X", "Linear Regression") - model_Y = data.get("model_Y", "Linear Regression") + model_name_X = data.get("model_name_X", "Linear Regression") + model_name_Y = data.get("model_name_Y", "Linear Regression") calib_id = data.get("calib_id") if not calib_id: @@ -182,8 +182,8 @@ def batch_predict(): calib_csv_path=calib_csv_path, predict_csv_path=predict_csv_path, iris_data=iris_data, - # model_X="Random Forest Regressor", - # model_Y="Random Forest Regressor", + model_name_X=model_name_X, + model_name_Y=model_name_Y, screen_width=screen_width, screen_height=screen_height, )