pyerrormetrics is a library designed to calculate different error metrics (Error Quotient, Repeated Error Density, Watwin Algorithm, RR Algorithm) for a given set of code executions.
Project description
pyerrormetrics
pyerrormetrics is a library designed to calculate different error metrics (Error Quotient, Repeated Error Density, Watwin Algorithm) for a given set of python code executions.
The calculation can take place at different levels:
- user: data is aggregated per user
- user task: data is aggregated across all tasks of a user
- user session: data is aggregated across all sessions of a user
- user task session: data is aggregated across all tasks and sessions of a user
A session is defined as any sequence of consecutive events occurring within a 20-minute interval.
IMPORTANT: A user always refers to one course. Therefore, if a user appears in several courses, it is considered separately for each course. The calculation is therefore always carried out at course level.
Installation
Via PyPi
pip install pyerrormetrics
Without PyPi
- Clone repository
- Open Terminal and change directory to the cloned repository
- Generate distribution archives on local machine:
python setup.py sdist bdist_wheel - Install the package on local machine:
pip install .
Alternatively, you can also install it in development mode:pip install -e .
Usage of pyerrormetrics
To use the methods from pyerrormetrics, you can either hand over a pandas DataFrame or a dictionary to the methods error_quotient, repeated_error_density and watwin.
Handing over a pandas DataFrame
The pandas DataFrame should have at least the columns:
- course_id: str
- user_id: str
- task_id: str
- timestamp: str
- input_code: str
- success: bool
- error_name: str
- error_line: int
Furthermore, you can have more column to presort your data for yourself, e.g.:
- output
- environment
- language
- version
import pyerrormetrics
# data is a pandas Dataframe with columns "course_id", "user_id", "task_id", "environment", "language", "version", "timestamp", "input_code", "output", "success", "error_name", "error_line"
eq = pyerrormetrics.error_quotient(data, "user session")
red = pyerrormetrics.repeated_error_density(data, "user session")
watwin, rr = pyerrormetrics.watwin(data, "user session")
Handing over a dictionary
The dictionary structure to be handed over depends on the analysis level:
- user level & user task level:
- Structure:
{key_group_1: [{'user_id': str, 'course_id': str, 'task_id': str, 'timestamp': str, 'input_code': str, 'success': bool, 'error_name': str, 'error_line': int}, ...], ...} - Example:
{('C001', 'U001', 1): [{'user_id': 'U001', 'course_id': 'C001', 'task_id': 'T001', 'timestamp': '2024-04-01 10:00:00', 'input_code': 'print("Hello, world!")', 'success': False, 'error_name': 'a', 'error_line': 1}]}
- Structure:
- user session level & user task session level:
- Structure:
{key_group_1: [{'user_id': str, 'course_id': str, 'task_id': str, 'timestamp': str, 'input_code': str, 'success': bool, 'error_name': str, 'error_line': int, 'session': int}, ...], ...} - Example:
{('C001', 'U001', 1): [{'user_id': 'U001', 'course_id': 'C001', 'task_id': 'T001', 'timestamp': '2024-04-01 10:00:00', 'input_code': 'print("Hello, world!")', 'success': False, 'error_name': 'a', 'error_line': 1, 'session': 1}]}
- Structure:
Similar to the dataframe you can have more keys for each event, e.g. output, environment, language or version, to presort your data beforehand.
The dictionary needs to be already correctly formatted, e.g. in terms of the analysis level.
Due to time performance you can prepare and turn your pandas DataFrame into a dict beforehand only once, e.g. if you want to calculate more than one error metric:
import pyerrormetrics
# data is a pandas Dataframe with columns "course_id", "user_id", "task_id", "environment", "language", "version", "timestamp", "input_code", "output", "success", "error_name", "error_line"
prepared_df_dict_user_session = pyerrormetrics.convert_dataframe_groups_into_dict(pyerrormetrics.prepare_dataframes(data, "user session"))
# prepared_df_dict_user_session is a dict with {key_group_1: [{event1}, {event2}, {event3}], key_group_2: [{event1}, {event2}], ...}
eq = pyerrormetrics.error_quotient(prepared_df_dict_user_session, "user session")
red = pyerrormetrics.repeated_error_density(prepared_df_dict_user_session, "user session")
watwin, rr = pyerrormetrics.watwin(prepared_df_dict_user_session, "user session")
Available functions:
error_quotientrepeated_error_densitywatwinprepare_dataframesconvert_dataframe_groups_into_dict
Testing
Unittests
python -m unittest discover tests "*_test.py"
Performance
python -m cProfile -o <xyz>.txt <file>.py
python -m snakeviz <xyz>.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyerrormetrics-0.0.1.tar.gz.
File metadata
- Download URL: pyerrormetrics-0.0.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42100887fb3283c94f581783170da5f84a2de3bb89eecb6953dacf18cf2974a4
|
|
| MD5 |
56825f89d46d2ee0f113b0b08be6ce44
|
|
| BLAKE2b-256 |
89a252288f2e3b6f81b51d5205623111709dcac4176a7e2e9d77e2a48579195e
|
File details
Details for the file pyerrormetrics-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyerrormetrics-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae0603b7450a7a57a00e3207c1b30a2e16212a529ebad9201ac9f22ff2160ba3
|
|
| MD5 |
add539a00b2df15b713cad9a0a7d6133
|
|
| BLAKE2b-256 |
50d082ec38b63a482e34fcd5a40ea4c8ace89ea230658564ba0fa78a6201ee79
|