Feynn Labs Internship Project1
I started this project at feynn labs repo and I create this separate repo to continue this project.
Predictive maintenance (PdM) is a maintenance strategy that uses data analysis to predict when a machine or equipment is likely to fail. This allows for preventive maintenance to be performed before the failure occurs, avoiding costly downtime and repairs. By combining PdM with ML, it is possible to develop models that can accurately predict machine failures days, weeks, or even months in advance. This allows organizations to schedule preventive maintenance at the most opportune time, minimizing downtime and maximizing uptime.
git clone --depth 1 https://github.com/Adhiban1/Machine-Predictive-Maintenance.git
cd Machine-Predictive-Maintenance
python -m venv .venv
For windows
.venv/Scripts/activate
For linux
source .venv/bin/activate
pip install -r requirements.txt
Run train.py
this will train the model and save the models into models
folder
python myapp/modules/train.py
Run test.py
to verify saved models work well
python myapp/modules/test.py
Run web app
python manage.py runserver 5000
You can run above commands one by one or you can use setup/setup.sh
for linux or setup/setup.bat
for windows. You should modify the code in setup.sh or setup.bat file for your cases. And then run this one file this will download repository, change directory, creating virtual environment, activating virtual environment, upgrading pip, installing requirements, training the model, testing the model, opening Flask App.
Once you run
setup
file, then don't run again to open flask app. Just runrun/run.bat
for windows or.run/run.sh
for linux or you can activate.venv
manually and runapp.py
.
Download setup
file and modify it according to your needs and run this.
D:\test>dir
setup.bat
D:\test>setup.bat
"Git Cloning..."
Cloning into 'feynn-labs'...
...
...
adhiban@DESKTOP:/test$ ls
setup.sh
adhiban@DESKTOP:/test$ bash setup.sh
Git Cloning...
Cloning into 'feynn-labs'...
...
...
Dark mode:
Light mode:
>>> df = pd.read_csv('predictive_maintenance.csv')
>>> df.head()
UDI Product ID Type Air temperature [K] ... Torque [Nm] Tool wear [min] Target Failure Type
0 1 M14860 M 298.1 ... 42.8 0 0 No Failure
1 2 L47181 L 298.2 ... 46.3 3 0 No Failure
2 3 L47182 L 298.1 ... 49.4 5 0 No Failure
3 4 L47183 L 298.2 ... 39.5 7 0 No Failure
4 5 L47184 L 298.2 ... 40.0 9 0 No Failure
[5 rows x 10 columns]
>>> df.columns
Index(['UDI', 'Product ID', 'Type', 'Air temperature [K]',
'Process temperature [K]', 'Rotational speed [rpm]', 'Torque [Nm]',
'Tool wear [min]', 'Target', 'Failure Type'],
dtype='object')
>>> output = pd.read_csv('output.csv')
>>> output.head()
UDI Product ID Type ... Failure Type is_failure failure_type
0 1 M14860 M ... No Failure 0 No Failure
1 2 L47181 L ... No Failure 0 No Failure
2 3 L47182 L ... No Failure 0 No Failure
3 4 L47183 L ... No Failure 0 No Failure
4 5 L47184 L ... No Failure 0 No Failure
[5 rows x 12 columns]
>>> output.columns
Index(['UDI', 'Product ID', 'Type', 'Air temperature [K]',
'Process temperature [K]', 'Rotational speed [rpm]', 'Torque [Nm]',
'Tool wear [min]', 'Target', 'Failure Type', 'is_failure',
'failure_type'],
dtype='object')
Here failure_type
, is_failure
columns are added in output.csv
I give the same training dataset to the Flask app to check whether it predicts correct or not. Thats why
Target
,Failure Type
and other columns are displayed in the terminal output.
docker pull adhiban/machine-predictive-maintenance
docker run -d -p 5000:5000 adhiban/machine-predictive-maintenance
Open it in browser http://127.0.0.1:5000/
[!NOTE] This Django project is in Debug=True mode