{"id":20767483,"url":"https://github.com/vvaldesc/tfc_api_stats","last_synced_at":"2026-02-10T00:04:22.047Z","repository":{"id":239582321,"uuid":"798906442","full_name":"vvaldesc/TFC_api_stats","owner":"vvaldesc","description":"Advanced Statistics and Predictions API for My Final Project","archived":false,"fork":false,"pushed_at":"2025-02-10T09:19:48.000Z","size":4674,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T10:27:07.494Z","etag":null,"topics":["api","flask","joblib","json","model-training","numpy","pandas-dataframe","pipeline","python","regression-testing","regression-tree","sklearn-library","tree-regressor"],"latest_commit_sha":null,"homepage":"https://delaypredict.onrender.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vvaldesc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T18:18:51.000Z","updated_at":"2025-02-10T09:19:51.000Z","dependencies_parsed_at":"2024-11-17T23:50:24.537Z","dependency_job_id":null,"html_url":"https://github.com/vvaldesc/TFC_api_stats","commit_stats":null,"previous_names":["vvaldesc/tfc_api_py","vvaldesc/tfc_api_stats"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaldesc%2FTFC_api_stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaldesc%2FTFC_api_stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaldesc%2FTFC_api_stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvaldesc%2FTFC_api_stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvaldesc","download_url":"https://codeload.github.com/vvaldesc/TFC_api_stats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239311980,"owners_count":19618118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","flask","joblib","json","model-training","numpy","pandas-dataframe","pipeline","python","regression-testing","regression-tree","sklearn-library","tree-regressor"],"created_at":"2024-11-17T11:31:56.524Z","updated_at":"2025-11-01T18:30:24.852Z","avatar_url":"https://github.com/vvaldesc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Service Time Estimation API\n\nWelcome to the Service Time Estimation API! This API uses a regression model based on a Regression Tree to predict the estimated service time in a hairdressing and aesthetics academy. This project was created as part of my TFC.\n\nThis API is designed to deliver complex statistics for my TFC, offering significantly improved scalability and is ready for immediate use.\n\n![License](https://img.shields.io/github/license/vvaldesc/TFC_gestor_academia)\n![Stars](https://img.shields.io/github/stars/vvaldesc/TFC_gestor_academia)\n![Issues](https://img.shields.io/github/issues/vvaldesc/TFC_gestor_academia)\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Running](#running)\n- [Data](#data)\n- [Model](#model)\n- [Training](#training)\n- [Developing](#developing)\n- [Environment](#environment)\n- [Testing](#testing)\n\n## Requirements\n\nThis API is developed with 3.12 Python\nTo install the required packages, run the following command:\n\n```sh\npip install -r requirements.txt\n```\n\n## Usage\n\nThe API offers several endpoints:\n\n- **`/api/estimatedtime`**: Accepts a POST request with the service details and returns the estimated service time using a previously trained model.\n- **`/api/estimatedtime/noTrain`**: Similar to the above, but trains the model with each request instead of using a previously trained model.\n- **`/api/estimatedtime/train`**: Trains the model with the data provided in the POST request and returns the ROC curve of the model, which is a measure of its reliability.\n- **`/`**: Returns the message \"Hello world\" to check that the API is working correctly.\n\n## Running\n\nTo run the API, execute the following command:\n\n```sh\npython main.py\n```\n\nIf this fails, use a custom environment by running `.\\flask_start.ps1` with PowerShell and installig dependencies to this envoirment.\n\nThis will start the API on port 5000 by default.\n\n## Data\n\nAn example of the data used to train the model is provided in `sampleData.json` file\nPrevious file is used by default to provide data to the client\n\nThe data used to train the model should be provided in the body of the POST request in JSON format. The required fields are:\n\n- `price`: The price of the service.\n- `employee_salary`: The salary of the employee providing the service.\n- `rating`: The rating of the service.\n- `service_id`: The ID of the service.\n- `client_id`: The ID of the client.\n- `teacher_id`: The ID of the teacher.\n- `weather`: The weather during the service.\n\nAn example POST body:\n```json\n\n            {\n                \"id\": 1,\n                \"client_id\": 1,\n                \"teacher_id\": 2,\n                \"student_id\": null,\n                \"delay\": null,\n                \"service_id\": 1,\n                \"created_at\": \"2022-07-16T22:00:00.000Z\",\n                \"updated_at\": null,\n                \"reserved_at\": \"2024-05-28T17:10:09.133Z\",\n                \"rating\": null,\n                \"price\": 5,\n                \"weather\": \"Snowy\",\n                \"client_name\": \"John Doe\",\n                \"teacher_name\": \"Emily Johnson\",\n                \"student_name\": null,\n                \"client_surname\": \"Doe\",\n                \"teacher_surname\": \"Johnson\",\n                \"student_surname\": null,\n                \"client_address\": \"123 Main St\",\n                \"teacher_address\": \"321 Pine St\",\n                \"student_address\": null,\n                \"client_phone_number\": \"123456789\",\n                \"teacher_phone_number\": \"222222222\",\n                \"student_phone_number\": null,\n                \"client_email\": \"example@example.com\",\n                \"teacher_email\": \"example@example.com\",\n                \"student_email\": null,\n                \"employee_salary\": 400\n            }\n\n```\n\n## Model\n\nThe regression model used is a Regression Tree from the `sklearn` package. It is trained with the provided data and then used to make predictions about the service time.\nThe model provided in the repository is not trained with real data, in fact it is trained with more than 2000 fake registers with certain sense, it would only be valid if it is trained with real data.\n\n## Training\n\nThrough an http request, the model expects a JSON array with a certain structure, the structure that the model expects can be edited in the code.\nThe expected structure in the array is similar to the previously mentioned.\n\nWhen training, the new model name will end in 'test', so you have to rename it to 'model' if you really want to use it\n\n## Developing\n\nTo correctly develop this app, would suggest to turn Flask debug mode on.\n\n## Environment\n\nIt's important to watch out this variables.\n\n- `FLASK_APP`: main.py.\n- `FLASK_ENV`: (development/False) development to develop.\n- `PORT`: (X.X.X.X).\n- `USE_SAMPLE_DATA`: (True/False) switch that decides if the API uses the example dataset or an external API HTTP request.\n\n## Testing\n\nTests can be performed using the `regression_model_test.py` script, which calculates various performance metrics of the model, such as:\n\n- Mean Squared Error (MSE)\n- Root Mean Squared Error (RMSE)\n- Mean Absolute Error (MAE)\n- Coefficient of Determination (R²)\n\nThis are the default testing results:\n\n- `mse`: 27.058695750000002,\n- `rmse`: 5.201797357644759,\n- `mae`: 3.995375,\n- `r2`: 0.2489379443577333\n\n## Contact\n\nDeploy with pythonAnyWhere\n\nFor any inquiries, please reach out to me via [email](mailto:vvaldescobos@gmail.com).\n\n---\n\n\u003cp align=\"center\"\u003e\n  Made with ❤️ by \u003ca href=\"https://github.com/vvaldesc\"\u003evvaldesc\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvaldesc%2Ftfc_api_stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvaldesc%2Ftfc_api_stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvaldesc%2Ftfc_api_stats/lists"}