Andrea Martorana Tusa: Failure Prediction For Manufacturing Industry
Andrea Martorana Tusa: Failure Prediction For Manufacturing Industry
Andrea Martorana Tusa: Failure Prediction For Manufacturing Industry
#sqlsat
@script=N'OutputDataSet<-InputDataSet', R script
GO
The above R script generates the following outcome
R in SQL Server
EXEC sp_execute_external_script
@language =N'R',
@script=N'OutputDataSet<-InputDataSet',
@input_data_1 =N'SELECT 1 AS hello'
WITH RESULT SETS (([hello] int not null));
N.B.! All the output from R to SQL Server, must return the data as
a data.frame!
Any other type of object that you generate in your script must be converted to
a data frame if you want to output it as part of the stored procedure outputs.
Predictive maintenance for manufacturing
industry
”Predictive modeling is the process of using advanced statistics
and probability algorithms to predict outcomes, based on a
pretrained and built model or function.”*
Predictive maintenance solutions can provide key performance
indicators about health state and lifecycle for products in
manifacturing industries. Some use cases could be:
• Aircraft component failure
• Wind turbine failure
• Circuit breaker failure
• And, of course ……………….. Hearing aids
* Tomaz Kastrun, Julie Koesmarno. SQL Server 2017 Machine Learning Services with R. Packt Publisher
Predictive maintenance for manufacturing
industry
R & SQL Server can be used together for building a predictive model to
address your business needs.
For example, we want to predict the probability of failure for a bicycle
component produced by the company Adventure Works.
A predictive maintenance solution helps
reducing repair costs and increasing the
lifecycle of our cycles. These models also give
insights on correlations among data, helping
to reveal patterns or outliers in the
production process.
Predictive maintenance for manufacturing
industry
Tipical problems addressed by a predictive
maintenance solution:
Prepare a
Data Data model Train the Perform scoring
collection preparation (for example model and predictions
for regression)
Visualization
output
Data collection
The common data elements for failure and predictive maintenance
calculations are:
• Failure data history
• Maintenance history
• Device conditions and usage, for example data collected by sensors
• Device technical specifications
• …
Data preparation
A good practice is to test more than one model and analyze the returned values to
choose the one that performs best. Once the model is set up and trained, it’s
convenient to save it as stored procedure and store the data in a table for further
reuse.
Prediction and scoring
Once the model is set up it’s possible to start with predictions.
Call a stored procedure passing parameters and get predicted values.
Values are numbers which can be expressed as score, a real number between 0 and 1.
By default, scoring values above 0.5 are labelled positive and below negative.
But the threshold can be modified according to our needs, experience, sensibility …
Demo
Linear regression model in R studio
Descriptive statistics with R in SSMS
Linear regression model with R in SSMS
Multivariate analysis
Analysis of Variance
Binary and multi class models
Plotting output in Reporting Services
Models and output in Power BI
Q&A
Thanks
References
Tomaz Kastrun, Julie Koesmarno. ”SQL Server 2017 Machine Learning Services
with R”. Packt
https://docs.microsoft.com/en-us/sql/advanced-analytics/what-is-sql-server-
machine-learning?view=sql-server-2017
https://docs.microsoft.com/en-us/azure/machine-learning/team-data-science-
process/cortana-analytics-playbook-predictive-maintenance
https://gallery.azure.ai/Tutorial/Predictive-Maintenance-Template-with-SQL-
Server-R-Services-1
https://github.com/Microsoft/SQL-Server-R-Services-
Samples/blob/master/PredictiveMaintenance/SQLR/README.md