LightningChart PythonEquipment Downtime Analysis in Python
TutorialImplementation of a machinery maintenance and downtime dashboard with LightningChart Python
Written by a human | Updated on April 23rd, 2025
Equipment Downtime Analysis in Python
In the industrial sector, machinery downtime refers to periods when equipment is not operational due to failures or maintenance activities. Monitoring machinery downtime is crucial as it impacts productivity, efficiency, and profitability.
Proper equipment downtime analysis helps identify the causes and patterns of downtime, leading to better maintenance strategies and reduced unplanned outages(Williams, 1995). Periodic maintenance ensures that machines operate smoothly, minimizing the chances of unexpected failures (Igbokwe & Godwin, 2021). We will now initiate the implementation of this equipment downtime analysis charting application.
LightningChart Python
LightningChart is a high-performance charting library designed for creating advanced data visualizations in Python. It offers a wide range of features and chart types, making it ideal for creating complex dashboards and data analysis tools. Key features include high rendering performance, a variety of chart types (e.g., line charts, heatmaps, bar charts), and extensive customization options. (LightningChart Python API Reference, n.d.)
Features and Chart Types to be used in the Project
In this project, we utilize LightningChart to create a dashboard for visualizing equipment downtime data. The key chart types used include box plots, density plots, bar charts, and scatter plots. These visualizations help in understanding the distribution, relationships, and importance of different operational parameters(Optimizing Production Efficiency, n.d.).
- XY and Line Charts to understand the density distribution of different features, explore relationships between multiple features, evaluate the performance of classification models, and analyze the trade-offs between precision and recall for different models.
- Box plots for visualizing the distribution and range of various operational parameters.
- Bar Charts to determine the most significant factors affecting machine failures.
- Scatter plots to compare actual and predicted machine failures for various features.
Performance Characteristics
LightningChart excels in rendering large datasets quickly and efficiently. This is particularly important for real-time data visualization and for handling the extensive data typically involved in predictive maintenance applications.
Setting Up Python Environment
Installing Python and necessary libraries
To get started with the equipment downtime analysis using Python, you need to have Python installed on your system. Additionally, you’ll need to install the necessary libraries, including NumPy, Pandas, LightningChart, and various machine learning libraries like Scikit-learn. Here you can also find the entire GitHub project.
pip install lightningchart==0.7.0
pip install numpy pandas sklearn xgboost lightgbm catboost
Overview of libraries used
- NumPy: Used for numerical operations and handling arrays.
- Pandas: Provides data structures and data analysis tools.
- LightningChart: For creating high-performance data visualizations.
- XGBoost, LightGBM, CatBoost: For advanced machine learning algorithms.
- Scikit-learn: For implementing machine learning models.
Setting up your development environment
1. Set up your development environment by creating a virtual environment and installing the necessary libraries. This ensures that your project dependencies are isolated and manageable.
python -m venv env
source env/bin/activate
pip install -r requirements.txt
2. Using Visual Studio Code (VSCode)
Visual Studio Code (VSCode) is a popular code editor offering rich features to enhance your development workflow.
Loading and Processing Data
How to load the data files
The data file used in this equipment downtime analysis project is ` X_train.csv`, which comprises observations of machine operations, each detailing various operating attributes. These attributes include Rotational Speed (rpm), Torque (Nm), Tool Wear (min), and Machine Failure. The data is well-prepared with no missing or inconsistent values.
import pandas as pd
file_path = 'path/to/X_train.csv'
data = pd.read_csv(file_path)
Handling and processing the data
Separate the features and target variable, handle missing values if any, and scale the numerical features using StandardScaler. Here’s an example:
from sklearn.preprocessing import StandardScaler
from sklearn.compose import ColumnTransformer
x = data.drop(columns=['Machine_failure'])
y = data['Machine_failure']
numerical_features = ['Air_temperature_K', 'Process_temperature_K', 'Rotational_speed_rpm', 'Torque_Nm', 'Tool_wear_min']
preprocessor = ColumnTransformer(
transformers =[
('num', StandardScaler(), numerical_features),
])
Boxplot
LightningChart for Python provides various interactive and high-performance chart types suitable for data analysis and visualization. It allows you to create detailed and informative dashboards to monitor and analyze equipment downtime and predictive maintenance.
Creating the Charts
Here are brief example scripts and diagrams of various charts utilized in this article:
Box Plot: The box plots provided a clear view of the distributions and central tendencies of operational parameters such as air temperature, process temperature, rotational speed, torque, and tool wear. These visualizations highlighted the consistency and variability in the operational parameters, which are crucial for understanding the normal operating ranges and identifying anomalies.
import lightningchart as lc
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
dashboard = lc.Dashboard(rows=2, columns=3, theme=lc.Themes.Dark)
chart = dashboard.ChartXY()
chart.set_title('Box Plot for Air Temperature')
box series = chart.add_box_series()
box_series.set_data(data['Air_temperature_K'].values)
Density Diagrams
The density diagrams offered a deeper insight into the probability distributions of the same operational parameters. The peaks and troughs in these plots revealed the most common operational conditions, aiding in the identification of typical and atypical machine behaviors. Such detailed distribution analysis is essential for developing accurate predictive models.
import lightningchart as lc
import pandas as pd
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
dashboard = 1c.Dashboard (rows=2, columns=3, theme=lc.Themes.Dark)
chart = dashboard.ChartXY()
chart.set_title('Line Chart for Air Temperature')
line_series = chart.add_line_series()
line_series.add(np.arange(len(data['Air temperature [K]'])), data['Air temperature [K]').values)
Pair Plot
The pair plot showcased the relationships between pairs of operational parameters. These scatter plots in this equipment downtime analysis application helped identify correlations and dependencies among the features, providing a comprehensive understanding of how different operational conditions interact with each other. Such interactions are vital for building robust predictive models that can account for the complex nature of industrial machinery operations.
import pandas as pd
file_path = 'path/to/x_train.csv'
data = pd.read_csv(file_path)
import lightningchart as lc
import pandas as pd
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
dashboard = lc.Dashboard(rows=1, columns=1, theme=lc.Themes.Dark)
chart = dashboard.ChartXY()
chart.set_title('Line Chart for Air Temperature')
x_values = data.index.tolist()
y_values = data['Air temperature [K]').values
line_series = chart.add_line_series()
line_series.add(x_values, y_values)
chart.get_default_x_axis().set_title('Index')
chart.get_default_y_axis().set_title('Air temperature [K]')
dashboard.open()
ROC Curves
The ROC curves (Receiver Operating Characteristic curves) plot the true positive rate against the false positive rate for various threshold settings of the models. The area under the curve (AUC) indicates the model’s ability to distinguish between classes. Higher AUC values signify better performance. Each subplot in the equipment downtime analysis dashboard presents the ROC curve for a different model, including Logistic Regression, Random Forest, XGBoost, LightGBM, CatBoost, and an ensemble method.
import lightningchart as lc
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_curve, auc
from sklearn.preprocessing import StandardScaler
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
selected_features = ['Air_temperature_K', 'Process_temperature_K', 'Rotational_speed_rpm', 'Torque_Nm', 'Tool_wear_min']
X = data[selected_features]
y = data['Machine_failure']
preprocessor = ColumnTransformer (transformers=[('num', StandardScaler(), selected_features)])
model = LogisticRegression (max_iter=10000)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)
pipeline = Pipeline (steps=[('preprocessor', preprocessor), ('classifier', model)])
pipeline.fit(x_train, y_train)
y_scores = pipeline.predict_proba(X_test)[:, 1]
fpr, tpr, _ = roc_curve(y_test, y_scores)
roc_auc = auc(fpr, tpr)
dashboard = 1c.Dashboard(rows=1, columns=1, theme=lc.Themes.Dark)
chart = dashboard.ChartXY()
chart.set_title(f'ROC Curve (AUC = {roc_auc:.2f})')
roc_series = chart.add_line_series()
roc_series.add(fpr.tolist(), tpr.tolist()).set_name('ROC Curve')
chart.get_default_x_axis().set_title('False Positive Rate')
chart.get_default_y_axis
dashboard.open()
Feature importance bar charts
The feature importance bar charts for various models, including Logistic Regression, Random Forest, XGBoost, LightGBM, CatBoost, and an ensemble method, underscored the significance of different features in predicting machine failures. For instance, torque and tool wear consistently emerged as crucial predictors across multiple models, suggesting that these parameters are vital indicators of potential machine failures. This insight helps prioritize which parameters should be closely monitored in an equipment downtime analysis system.
import lightningchart as lc
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler
lc.set_license('my-license-key')
file_path = 'x_train.csv'
data = pd.read_csv(file_path)
selected_features = ['Air_temperature_K', 'Process_temperature_K', 'Rotational_speed_rpm', 'Torque_Nm', 'Tool_wear_min']
X = data[selected_features]
y = data['Machine_failure']
preprocessor = ColumnTransformer(transformers=[('num', StandardScaler(), selected_features)])
model = RandomForestClassifier()
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)
pipeline = Pipeline (steps=[('preprocessor', preprocessor), ('classifier', model)])
pipeline.fit(x_train, y_train)
importances = model.feature_importances_
importance_df = pd.DataFrame({'Feature': selected_features, 'Importance': importances}) importance_df = importance_df.sort_values(by='Importance', ascending=False)
dashboard = 1c.Dashboard (rows=1, columns=1, theme=lc.Themes.Dark)
chart = dashboard.BarChart()
chart.set_title('Random Forest Feature Importances')
bar_data = [{'category': row['Feature'], 'value': row['Importance']} for, row in importance_df.iterrows()] chart.set_data(bar_data)
dashboard.open()
Precision-Recall Curves
The precision-recall curves in this equipment downtime analysis dashboard illustrate the trade-off between precision and recall for different classification models, including Logistic Regression, Random Forest, XGBoost, LightGBM, CatBoost, and an ensemble method. The curves help evaluate the performance of models, particularly for imbalanced datasets where precision and recall are more informative metrics than accuracy.
import lightningchart as lc
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import precision_recall_curve, auc
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
selected_features = ['Air_temperature_K', 'Process_temperature_K', 'Rotational_speed_rpm', 'Torque_Nm', 'Tool_wear_min']
X = data[selected_features]
y = data['Machine_failure']
preprocessor ColumnTransformer (transformers=[('num', StandardScaler(), selected_features)])
model = LogisticRegression (max_iter=10000)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)
pipeline = Pipeline(steps=[('preprocessor', preprocessor),('classifier', model)])
pipeline.fit(x_train, y_train)
y_scores = pipeline.predict_proba(x_test)[:, 1]
precision, recall, _ = precision_recall_curve (y_test, y_scores) pr_auc = auc(recall, precision)
dashboard = 1c.Dashboard (rows=1, columns=1, theme-1c.Themes.Dark)
chart = dashboard.ChartXY()
chart.set_title(f'Precision-Recall Curve (AUC = {pr_auc:.2f})')
pr_series = chart.add_line_series()
pr_series.add(recall.tolist(), precision.tolist()).set_name('Precision-Recall Curve')
chart.get_default_x_axis().set_title('Recall')
chart.get_default_y_axis().set_title('Precision')
dashboard.open()
Scatter Plots
In the this equipment downtime analysis dashboard, the scatter plots comparing actual failures to predicted failures offered a visual assessment of the models’ prediction accuracy. The alignment (or misalignment) of red (actual failures) and blue (predicted failures) points revealed the models’ strengths and weaknesses. Models like the ensemble method showed a closer alignment, suggesting higher accuracy and reliability in predictions.
import lightningchart as lc
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import Column Transformer
from sklearn.preprocessing import StandardScaler
lc.set_license('my-license-key')
file_path = 'X_train.csv'
data = pd.read_csv(file_path)
selected_features = ['Air_temperature_K', 'Process_temperature_K']
X = data[selected_features]
y = data['Machine_failure']
preprocessor = ColumnTransformer(transformers=[('num', StandardScaler(), selected_features)])
model = LogisticRegression (max_iter=10000)
x_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42) pipeline = Pipeline(steps=[('preprocessor', preprocessor),('classifier', model)])
pipeline.fit(x_train, y_train)
y_pred = pipeline.predict(x_test)
dashboard = 1c.Dashboard (rows=1, columns=1, theme=lc.Themes.Dark)
def plot_actual_vs_predicted(chart, feature, y_test, y_pred):
actual_failures = x_test[y_test == 1][feature]
predicted_failures = x_test[y_pred == 1] [feature]
actual_series = chart.add_point_series()
actual_series.add(x_test[y_test == 1].index.tolist(), actual_failures.tolist())
actual_series.set_point_color(lc.Color(255, 0, 0))
actual_series.set_name('Actual Failures')
predicted_series = chart.add_point_series()
predicted_series.add(x_test[y_pred == 1].index.tolist(), predicted_failures.tolist())
predicted_series.set_point_color(lc.Color(0, 0, 255))
predicted_series.set_name('Predicted Failures')
chart.set_title(f'Predictions vs Actual ({feature})')
chart.get_default_x_axis().set_title('Index')
chart.get_default_y_axis().set_title(feature)
chart.add_legend()
chart = dashboard. ChartXY()
plot_actual_vs_predicted(chart, 'Air_temperature_K', y_test, y_pred)
dashboard.open()
Conclusion
In this equipment downtime analysis dashboard implementation, we demonstrated the integration of visualizations and machine learning models into a Python-based maintenance dashboard that provides a powerful tool for industrial equipment downtime analysis. The application provides a comprehensive view of machine operational parameters, predicted failures, and model performance metrics. By leveraging advanced visualization techniques and machine learning algorithms, industrial operators can better monitor equipment health, predict potential failures, and optimize maintenance schedules.
The use of LightningChart Python for creating these visualizations proved highly effective, offering robust performance and customization options to meet the specific needs of industrial analytics. This project demonstrates the potential of combining advanced analytics with interactive visualizations to drive informed decision-making in industrial maintenance and operations.
Benefits of Using LightningChart Python for Visualizing Data
- High Performance: LightningChart handles large datasets efficiently, ensuring smooth interactions and quick rendering.
- Interactive Visualizations: Create dynamic and interactive charts that provide deeper insights into the data.
- Customizable: Tailor the visualizations to meet specific requirements and enhance the user experience.
With this approach, businesses can reduce downtime, improve productivity, and ensure the reliability of their machinery.
7 Best Plotly.js Alternatives in 2026: Faster, Lighter, No Context Limits
Plotly.js holds a unique position in the JavaScript charting ecosystem. Data scientists already know it from Python, when Plotly.py generates a chart in a Jupyter notebook, it's Plotly.js rendering it in the browser. That continuity between languages is genuinely...
7 Best Highcharts Alternatives in 2026: Faster, Cheaper, and More Capable
Highcharts has been a reliable workhorse for enterprise JavaScript charts since 2009. Solid documentation, broad chart type coverage, WCAG accessibility that's genuinely best-in-class. A lot of teams have built a lot of dashboards on it over the years. But teams also...
Alternative to SciChart 2026: Why Performance Leaders Choose the Industry Standard
The data visualization market in 2026 is highly fragmented, yet in mission-critical sectors, one name consistently emerges when performance limits are pushed to the edge. While SciChart remains a known player, technical facts and market history favor LightningChart as...
