{"id":24510056,"url":"https://github.com/arindal1/machine-maintenance-analysis","last_synced_at":"2026-05-14T05:32:34.906Z","repository":{"id":273598344,"uuid":"920199680","full_name":"arindal1/Machine-Maintenance-Analysis","owner":"arindal1","description":"A predictive analysis model for Machine Failure/Downtime with Restful API endpoints [SpearHub]","archived":false,"fork":false,"pushed_at":"2025-01-21T20:33:55.000Z","size":370,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T21:30:47.840Z","etag":null,"topics":["assessment","flask","logistic-regression","machine-learning","postman","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/arindal1.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":"2025-01-21T18:28:01.000Z","updated_at":"2025-01-21T20:33:59.000Z","dependencies_parsed_at":"2025-01-21T21:41:45.380Z","dependency_job_id":null,"html_url":"https://github.com/arindal1/Machine-Maintenance-Analysis","commit_stats":null,"previous_names":["arindal1/machine-maintenance-analysis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2FMachine-Maintenance-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2FMachine-Maintenance-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2FMachine-Maintenance-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arindal1%2FMachine-Maintenance-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arindal1","download_url":"https://codeload.github.com/arindal1/Machine-Maintenance-Analysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243708852,"owners_count":20334912,"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":["assessment","flask","logistic-regression","machine-learning","postman","restful-api"],"created_at":"2025-01-22T00:24:47.247Z","updated_at":"2026-05-14T05:32:34.879Z","avatar_url":"https://github.com/arindal1.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Predictive Maintenance Analysis w/ REST-API\n\nThis project provides a **RESTful API** for predicting machine downtime using a simple **Logistic Regression** model. The model is trained on a manufacturing dataset to predict machine failures or downtime, helping improve maintenance planning and reduce unplanned production disruptions.\n\n## Project Overview\n\nThe Predictive Maintenance API allows users to:\n\n- **Upload** manufacturing data in CSV format.\n- **Train** a predictive model on the uploaded data.\n- **Make predictions** on machine downtime based on new input data.\n\nThis API is built using **Flask** for the backend and uses **scikit-learn** for machine learning. The model is trained on a dataset of machine parameters and downtime status to predict whether a machine will experience downtime, given certain input conditions.\n\n---\n\n## Files\n\n- **Jupyter Code** (with preprocessing, visualisation, prediction): [Jupyter Notebook](defect.md) \u003cbr\u003e\n- **Python Code** (without API): [defect.py](defect.py) \u003cbr\u003e\n- **Flask Code** (with API): [app.py](app.py) \u003cbr\u003e\n- **Dataset**: [predictive_maintenance.csv](data/predictive_maintenance.csv) \u003cbr\u003e\n- **Model** (pickle): [downtime_model.pkl](model/downtime_model.pkl) \u003cbr\u003e\n- **Postman Collection**: [MAC-DOWNTIME.postman_collection.json](MAC-DOWNTIME.postman_collection.json)\n## Features\n\n- **Upload** endpoint: Upload manufacturing data for training.\n- **Train** endpoint: Train the model based on the uploaded dataset.\n- **Predict** endpoint: Predict machine downtime based on input parameters.\n\n## Requirements\n\nTo get the project up and running, you'll need the following:\n\n- Python 3.x\n- Required Python packages (listed below)\n\n### Required Packages\n\n1. Flask\n2. scikit-learn\n3. pandas\n4. imbalanced-learn\n\n## Installation and Setup\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/arindal1/Machine-Maintenance-Analysis\ncd Machine-Maintenance-Analysis\n```\n\n### 2. Install Dependencies\n\nCreate a virtual environment (optional) and install the required dependencies using `pip`:\n\n```bash\n# Install dependencies\npip install -r requirements.txt\n```\n\nThe `requirements.txt` file contains the necessary libraries:\n\n\n### 3. Running the API\n\nOnce the dependencies are installed, you can run the Flask API:\n\n```bash\npython app.py\n```\n\nThe API will start running on `http://127.0.0.1:5000`.\n\n## API Endpoints\n\n### 1. **POST /upload**\n\nThis endpoint allows users to upload a CSV file containing manufacturing data. The file must include machine parameters like temperature, run time, etc.\n\n#### Request\n\n- Method: `POST`\n- URL: `/upload`\n- Content-Type: `multipart/form-data`\n- Body: Upload a CSV file.\n\n#### Example Request\n\n```bash\ncurl -X POST -F \"file=@path/to/data.csv\" http://127.0.0.1:5000/upload\n```\n\n#### Example Response\n\n```json\n{\n  \"message\": \"File uploaded successfully!\"\n}\n```\n\n![upload](assets/screenshot_12.png)\n\n\u003cp align=\"center\"\u003e[ \u003cstrong\u003e/upload\u003c/strong\u003e endpoint in Postman]\u003c/p\u003e\n\n---\n\n### 2. **POST /train**\n\nThis endpoint trains the machine learning model using the uploaded dataset. The model is saved after training and is ready for predictions.\n\n#### Request\n\n- Method: `POST`\n- URL: `/train`\n- Content-Type: `application/json`\n\n#### Example Request\n\n```bash\ncurl -X POST http://127.0.0.1:5000/train\n```\n\n#### Example Response\n\n```json\n{\n    \"accuracy\": 0.82,\n    \"f1_score\": 0.82,\n    \"message\": \"Model trained successfully!\"\n}\n```\n\n![upload](assets/screenshot_13.png)\n\n\u003cp align=\"center\"\u003e[ \u003cstrong\u003e/train\u003c/strong\u003e endpoint  in Postman ]\u003c/p\u003e\n\n---\n\n### 3. **POST /predict**\n\nThis endpoint allows users to make predictions based on input data such as temperature, run time, etc. The model will predict whether there will be machine downtime (Failure or No Failure).\n\n#### Request\n\n- Method: `POST`\n- URL: `/predict`\n- Content-Type: `application/json`\n- Body: A JSON object with machine parameters.\n\n#### Example Request\n\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\n    \"Type\": \"M\",\n    \"Air temperature [K]\": 298.1,\n    \"Process temperature [K]\": 308.6,\n    \"Rotational speed [rpm]\": 1551,\n    \"Torque [Nm]\": 42.8,\n    \"Tool wear [min]\": 0\n}' http://127.0.0.1:5000/predict\n```\n\n#### Example Response\n\n```json\n{\n  \"Downtime\": \"Yes\",\n  \"Confidence\": 0.86\n}\n```\n\n![upload](assets/screenshot_14.png)\n\n\u003cp align=\"center\"\u003e[ \u003cstrong\u003e/predict\u003c/strong\u003e endpoint  in Postman ]\u003c/p\u003e\n\n---\n\n## How the Model Works\n\nThe model uses **Logistic Regression** and is trained on the following machine parameters:\n\n- **Type**: Machine type (categorical)\n- **Air temperature [K]**: Temperature of the machine's environment\n- **Process temperature [K]**: Temperature during the operation\n- **Rotational speed [rpm]**: Speed of the machine's rotation\n- **Torque [Nm]**: Torque applied to the machine\n- **Tool wear [min]**: Amount of wear on the machine tool\n\nThe model predicts whether a machine will experience downtime (Failure = 1) or not (Failure = 0), based on these input parameters.\n\n---\n\n## Example Usage\n\n### Example Request for **/predict**\n\n**Request:**\n\n```json\n{\n  \"Type\": \"M\",\n  \"Air temperature [K]\": 298.1,\n  \"Process temperature [K]\": 308.6,\n  \"Rotational speed [rpm]\": 1551,\n  \"Torque [Nm]\": 42.8,\n  \"Tool wear [min]\": 0\n}\n```\n\n**Response:**\n\n```json\n{\n  \"Downtime\": \"No Failure\",\n  \"Confidence\": 0.87\n}\n```\n\n---\n\n## Model Training and Prediction Flow\n\n1. **Upload CSV**: Upload a CSV file containing manufacturing data.\n2. **Train Model**: Train the model using the uploaded data.\n3. **Predict**: Make predictions for machine downtime using new input data.\n\n---\n\n## External Links\n\nDataset: [link](https://www.kaggle.com/datasets/shivamb/machine-predictive-maintenance-classification) \u003cbr\u003e\nRepository: [link](https://github.com/arindal1/Machine-Maintenance-Analysis) \u003cbr\u003e\nLinkedIn: [link](https://www.linkedin.com/in/arindalchar)\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindal1%2Fmachine-maintenance-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farindal1%2Fmachine-maintenance-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farindal1%2Fmachine-maintenance-analysis/lists"}