Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/routes/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
)
Expand Down
49 changes: 46 additions & 3 deletions app/services/gaze_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
# ============================
Expand Down Expand Up @@ -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)
Expand Down