This project predicts machine failures using a K-Nearest Neighbors (KNN) classifier. The frontend application is built using Streamlit, providing an interactive interface for users to train the model and make predictions.
Machine failures can lead to significant downtime and financial loss. This project aims to predict potential machine failures based on various parameters such as air temperature, process temperature, rotational speed, torque, tool wear, and machine type. The model can be trained on historical data, and users can input new machine parameters to predict failures.
The application is deployed and accessible at the following URL: Machine Failure Prediction App
- Model Training: Train the KNN model using historical data.
- Predict Failure: Input new machine parameters to predict if the machine will fail.
- Test Data: Test the model with a custom percentage of data to evaluate its performance.
The dataset is preprocessed by:
- Dropping unnecessary columns (
UDI
andProduct ID
). - Creating a new feature
nf
which is the product ofTool wear [min]
andTorque [Nm]
. - Encoding the categorical
Type
feature usingLabelEncoder
.
The K-Nearest Neighbors (KNN) classifier is used for training. The optimal number of neighbors is determined by testing the accuracy of the model for n_neighbors
ranging from 1 to 199. The best value of n_neighbors
is selected based on the highest accuracy.
The frontend application allows users to:
- Start training the model by pressing the "Start Training My Model" button.
- Input new machine parameters and predict the failure by filling out the form and pressing the "Predict Failure for New Machine" button.
- Test the model with a custom percentage of data by selecting the percentage using a slider and pressing the "Test Data on Certain Percentage" button.
The following Python libraries are used in this project:
streamlit
pandas
scikit-learn
time
Make sure to install the required dependencies using the following command:
pip install -r requirements.txt
- app.py: The main file containing the Streamlit app code.
- modelling.py: Contains the Modelling class used for training and evaluating the models.
- machine_failure_prediction.csv: The dataset used for training the model.
- Clone the repository:
git clone https://github.com/as3hr/machine-failure-prediction.git
- Navigate to the project directory:
cd machine-failure-prediction
- Install the dependencies:
pip install -r requirements.txt
- Run the Streamlit app:
streamlit run app.py
This project demonstrates how to use machine learning to predict machine failures and provides an interactive interface for users to train and test the model. The deployed application offers a user-friendly experience for predicting machine failures based on input parameters.
Feel free to contribute to this project by submitting issues or pull requests.