Skip to content
Open
19 changes: 0 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}} # Located in GitHub secrets
heroku_app_name: "web-eye-tracker-1204" # Must be unique in Heroku
heroku_email: "karine.pistili@gmail.com"
67 changes: 18 additions & 49 deletions app/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,18 @@
hyperparameters = {
"Lasso Regression": {
"param_grid": {
"lasso__alpha": [
1e-15,
1e-10,
1e-8,
1e-3,
1e-2,
1e-1,
0.5,
1,
5,
10,
20,
30,
35,
40,
45,
50,
55,
100,
]
"lasso__alpha": [10, 20, 30, 40, 45, 50, 55, 100, 200, 500]
}
},
"Ridge Regression": {
"param_grid": {
"ridge__alpha": [
1e-15,
1e-10,
1e-8,
1e-3,
1e-2,
1e-1,
0.5,
1,
5,
10,
20,
30,
35,
40,
45,
50,
55,
100,
]
"ridge__alpha": [ 1e-3, 0.005, 0.01, 0.1, 0.5, 1.0, 10, 20, 50, 100]
}
},
"Elastic Net": {
"param_grid": {
"elasticnet__alpha": [1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 0.0, 1.0, 10.0, 100.0],
"elasticnet__l1_ratio": [0, 0.01, 0.2, 0.5, 0.8, 1],
"elasticnet__alpha": [0.1, 0.5, 1.0, 2.0, 5.0],
"elasticnet__l1_ratio": [0.5, 0.7, 0.8, 0.9, 1.0],
}
},
"Bayesian Ridge": {
Expand All @@ -62,17 +24,24 @@
},
"SGD Regressor": {
"param_grid": {
"sgdregressor__alpha": [0.0001, 0.001, 0.01, 0.1],
"sgdregressor__l1_ratio": [0, 0.2, 0.5, 0.7, 1],
"sgdregressor__max_iter": [500, 1000],
"sgdregressor__eta0": [0.0001, 0.001, 0.01],
"sgdregressor__alpha": [0.0001, 0.001],
"sgdregressor__l1_ratio": [0.5, 0.7, 0.8, 1],
"sgdregressor__max_iter": [1000],
"sgdregressor__eta0": [0.0001, 0.001],
}
},
"Support Vector Regressor": {
"param_grid": {
"svr__C": [0.1, 1, 10, 100, 1000],
"svr__gamma": [0.0001, 0.001, 0.01, 0.1, 1],
"svr__kernel": ["linear", "rbf", "poly"],
"svr__C": [50, 100, 200, 500, 1000, 2000],
"svr__gamma": [0.1, 0.5, 1, 2, 5],
"svr__kernel": ["rbf"],
}
},
"Random Forest Regressor": {
"param_grid": {
"randomforestregressor__n_estimators": [100],
"randomforestregressor__max_depth": [10],
"randomforestregressor__min_samples_split": [2, 5, 10],
}
},
}
39 changes: 18 additions & 21 deletions app/services/gaze_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sklearn.pipeline import make_pipeline
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import Ridge

import time

# Model imports
from sklearn import linear_model
Expand Down Expand Up @@ -87,13 +87,14 @@ def trian_and_predict(model_name, X_train, y_train, X_test, y_test, label):
"""
if (
model_name == "Linear Regression"
or model_name == "Elastic Net"
or model_name == "Support Vector Regressor"
):
model = models[model_name]
start_time = time.time()
model.fit(X_train, y_train)
end_time = time.time()
y_pred = model.predict(X_test)
print(f"Score {label}: {r2_score(y_test, y_pred)}")
print(f"Time {label}: {end_time - start_time}")
return y_pred
else:
pipeline = models[model_name]
Expand All @@ -106,9 +107,12 @@ def trian_and_predict(model_name, X_train, y_train, X_test, y_test, label):
refit="r2",
return_train_score=True,
)
start_time = time.time()
grid_search.fit(X_train, y_train)
end_time = time.time()
best_model = grid_search.best_estimator_
y_pred = best_model.predict(X_test)
print(f"Time {label}: {end_time - start_time}")
return y_pred


Expand Down Expand Up @@ -202,32 +206,25 @@ def predict(data, k, model_X, model_Y):

# Create a dictionary to store the data
data = {}
grouped = df_data.groupby("True XY")

# Iterate over the dataframe and store the data
for index, row in df_data.iterrows():
for (true_x, true_y), group in grouped:

# Get the outer and inner keys
outer_key = str(row["True X"]).split(".")[0]
inner_key = str(row["True Y"]).split(".")[0]
# keys
outer_key = str(true_x).split(".")[0]
inner_key = str(true_y).split(".")[0]

# If the outer key is not in the dictionary, add it
# create outer key if missing
if outer_key not in data:
data[outer_key] = {}

# Add the data to the dictionary
# fill data
data[outer_key][inner_key] = {
"predicted_x": df_data[
(df_data["True X"] == row["True X"])
& (df_data["True Y"] == row["True Y"])
]["Predicted X"].values.tolist(),
"predicted_y": df_data[
(df_data["True X"] == row["True X"])
& (df_data["True Y"] == row["True Y"])
]["Predicted Y"].values.tolist(),
"PrecisionSD": precision_xy[(row["True X"], row["True Y"])],
"Accuracy": accuracy_xy[(row["True X"], row["True Y"])],
"predicted_x": group["Predicted X"].tolist(),
"predicted_y": group["Predicted Y"].tolist(),
"PrecisionSD": precision_xy[(true_x, true_y)],
"Accuracy": accuracy_xy[(true_x, true_y)],
}

# Centroids of the clusters
data["centroids"] = model.cluster_centers_.tolist()

Expand Down
Loading