Skip to content

Commit

Permalink
0.26.0 regression-floating-error & flake
Browse files Browse the repository at this point in the history
0.26.0 add regression floating error and abs error in integrated algo
  • Loading branch information
Tomansion authored Mar 22, 2024
2 parents 6a95b61 + 2d75ed7 commit 1dd657d
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 484 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
## Checklist before requesting a review
- [ ] I have performed a self-review of my code
- [ ] I have increased the version number in the `frontend/package.json` and `backend/swagger.yaml` files
- [ ] I have checked that Black, Prettier and Cspell have been run on my code
- [ ] I have checked that Black, Flake8, Prettier and Cspell are passing
22 changes: 22 additions & 0 deletions .github/workflows/pull-request-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ jobs:
pip install black
black --check --diff .
flake8-check: # Check that the backend codebase does not contain linting errors
name: Flake8 check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies and check flake8 format
run: |
cd backend
python -m pip install --upgrade pip
pip install flake8
flake8 .
prettier-check: # Check that the frontend codebase is formatted with prettier
name: Prettier format check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -84,6 +100,12 @@ jobs:
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION"
echo "BRANCH_VERSION=$BRANCH_VERSION"
# If pervious version is beta, ignore test
if [[ $PREVIOUS_VERSION == *"beta"* ]]; then
echo "Beta version detected, skipping version upgrade check."
exit 0
fi
if [ "$BRANCH_VERSION" == "" ]; then
echo "No version found in current branch."
exit 1
Expand Down
8 changes: 4 additions & 4 deletions backend/config/init_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_config_values(section, config_parser):
for key in os.environ.keys():
if key.startswith(ENV_VAR):
# Get the key name without the env var prefix
key_name = key[len(ENV_VAR) :]
key_name = key[len(ENV_VAR) :] # noqa
values[key_name] = str.lower(os.environ[key])

return values
Expand Down Expand Up @@ -184,7 +184,7 @@ def init_config():
continue

# Deal with booleans
if type(config[section][key]) == bool:
if type(config[section][key]) is bool:
if value == "false":
set_config_value(section, key, False)
elif value == "true":
Expand All @@ -199,7 +199,7 @@ def init_config():
continue

# Deal with integers
elif type(config[section][key]) == int:
elif type(config[section][key]) is int:
try:
set_config_value(section, key, int(value))
except ValueError:
Expand All @@ -212,7 +212,7 @@ def init_config():
continue

# Deal with strings
elif type(config[section][key]) == str:
elif type(config[section][key]) is str:
set_config_value(section, key, str(value))

# Deal with list based config elements
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def ping():
return "Online v0.15.1", 200
return "Online", 200


def get_data_providers_project(dataProviderId):
Expand Down
86 changes: 0 additions & 86 deletions backend/controller/requests.py

This file was deleted.

3 changes: 2 additions & 1 deletion backend/modules/algoProviders/AlgoProvider.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Class for AlgoProvider
import requests, json
import requests
import json
from modules.algoProviders.AlgoProviderException import AlgoProviderException


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# Technical details (must respect the algo-api format):
algorithm_description = {
"name": "Classification Metric",
"description": """Calculates the classification error according to the ground truth and the predictions""",
"description": """Calculates the classification error according \
to the ground truth and the predictions""",
"author": "DebiAI",
"version": "1.0.0",
"creationDate": "2023-10-30",
Expand All @@ -26,21 +27,24 @@
},
{
"name": "Predictions",
"description": "List of predictions, must have the same length as the ground truth list",
"description": "List of predictions, must have the same \
length as the ground truth list",
"type": "array",
"arrayType": "text",
},
],
"outputs": [
{
"name": "Binary error",
"description": "Classification metric of the input list, False if GDT == PRED, True otherwise",
"description": "Classification metric of the input list, \
False if GDT == PRED, True otherwise",
"type": "array",
"arrayType": "boolean",
},
{
"name": "Binary success",
"description": "Classification metric of the input list, True if GDT == PRED, False otherwise",
"description": "Classification metric of the input list, \
True if GDT == PRED, False otherwise",
"type": "array",
"arrayType": "boolean",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# Technical details (must respect the algo-api format):
algorithm_description = {
"name": "Regression Metric",
"description": """Calculates the regression error according to the ground truth, the predictions and a ceil value""",
"description": """Calculates the regression error according to the ground truth, \
the predictions and a ceil value""",
"author": "DebiAI",
"version": "1.0.0",
"creationDate": "2023-05-23",
Expand All @@ -26,7 +27,8 @@
},
{
"name": "Predictions",
"description": "List of predictions, must have the same length as the ground truth list",
"description": "List of predictions, must have the same length as the \
ground truth list",
"type": "array",
"arrayType": "number",
},
Expand All @@ -40,16 +42,38 @@
},
],
"outputs": [
{
"name": "Error",
"description": "Difference between the ground truth and the predictions",
"type": "array",
"arrayType": "number",
},
{
"name": "Absolute error",
"description": "Absolute value of the error",
"type": "array",
"arrayType": "number",
},
{
"name": "Binary error",
"description": "Regression metric of the input list, False if abs(GDT - PRED) < ceil, True otherwise",
"description": "True if Absolute error > ceil, False otherwise",
"type": "array",
"arrayType": "boolean",
},
{
"name": "Error percentage",
"type": "number",
},
{
"name": "Binary success",
"description": "True if Absolute error <= ceil, False otherwise",
"type": "array",
"arrayType": "boolean",
},
{
"name": "Success percentage",
"type": "number",
},
],
}

Expand All @@ -72,26 +96,54 @@ def use_algorithm(inputs):
raise TypeError("Ground truth and predictions must have the same length")

# Calculate regression metric
regressionMetric = []
for i in range(len(gdt)):
error = gdt[i] - predictions[i]
nb_values = len(gdt)
error = [None] * nb_values
absolute_error = [None] * nb_values
binary_error = [None] * nb_values
binary_success = [None] * nb_values

if abs(error) < ceil:
regressionMetric.append(False)
for i in range(nb_values):
error_value = gdt[i] - predictions[i]
error[i] = error_value
absolute_error[i] = abs(error_value)

if abs(error_value) > ceil:
binary_error[i] = True
binary_success[i] = False
else:
regressionMetric.append(True)
binary_error[i] = False
binary_success[i] = True

percentage = regressionMetric.count(True) / len(regressionMetric)
percentage = round(percentage * 100, 2)
# Calculate percentages
error_percentage = binary_error.count(True) / nb_values
error_percentage = round(error_percentage * 100, 2)
success_percentage = binary_success.count(True) / nb_values
success_percentage = round(success_percentage * 100, 2)

# Return outputs
return [
{
"name": "Error",
"value": error,
},
{
"name": "Absolute error",
"value": absolute_error,
},
{
"name": "Binary error",
"value": regressionMetric,
"value": binary_error,
},
{
"name": "Error percentage",
"value": percentage,
"value": error_percentage,
},
{
"name": "Binary success",
"value": binary_success,
},
{
"name": "Success percentage",
"value": success_percentage,
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _get_algorithm_python(algorithm_name):


class IntegratedAlgoProvider(AlgoProvider):
### Integrated AlgoProvider
# Integrated AlgoProvider
# Used to expose the algorithms that are integrated
# directly in DebiAI
def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def create_project(projectId, projectName):
os.mkdir(DATA_PATH + projectId)
os.mkdir(DATA_PATH + projectId + "/blocks")
os.mkdir(DATA_PATH + projectId + "/models")
os.mkdir(DATA_PATH + projectId + "/requests")
os.mkdir(DATA_PATH + projectId + "/selections")

now = pythonModuleUtils.timeNow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def clean_filename(filename):


def is_filename_clean(filename):
cleanFilename = "".join(i for i in filename if i not in "\/:*?<>|")
cleanFilename = "".join(i for i in filename if i not in "\/:*?<>|") # noqa
return filename == cleanFilename


Expand Down
Loading

0 comments on commit 1dd657d

Please sign in to comment.