Using IntegratedML to create a cube dimension
Hi guys.
That time I'll show you a way to use a machine learning model implemented using IntegradeML as source for an IRIS analytics cube dimension.
Creating the ML model:
Execute this SQL in order to create a new ML model using IntegratedML SQL extension:
CREATE MODEL AppointmentsPredection
PREDICTING (Show)
FROM (SELECT
Canal,
CreacionDate,
CreacionHora,
Edad,
Especialidad,
Latencia,
ReservaDate,
ReservaHora,
Sexo,
Tipo
FROM dc_myapp_model.MedicalAppointments
Now, you can train you model:
TRAIN MODEL AppointmentsPredection FROM dc_myapp_model.MedicalAppointmentsTrain
Finally, you can see how good your model is:
VALIDATE MODEL AppointmentsPredection FROM dc_myapp_model.MedicalAppointmentsTest
Creating the cube dimension:
The trick is to use an expression as input for the dimesion. This is done by setting the Expression property of the dimension:
The method expression code uses the PREDICT function of IntegratedML to classifiy an new entry using the ML model created early:
ClassMethod PredictMedicalAppointmentClass(pID As %String) As %String
{
Set modelClass = ##class(dc.myapp.model.MedicalAppointments).ShowGetStored(pID)
If modelClass '= "" {
Return ""
}
&SQL(SELECT PREDICT(AppointmentsPredection) INTO :modelClass FROM dc_myapp_model.MedicalAppointments WHERE ID = :pID)
return $Case(modelClass, 0:"No show", 1:"Show", :"")
}
So, with this aproach you can create a dimension which will show to users a prediction about future appointments.
Using your new cube in a notebook:
As now you has a cube with dimensions that can show past appointments as do predictions about future appointments, you can explore this information in a notebook.
For example, you can create a pivot table showing the history of past appointments:
And ,you can also show the forecast for future appointments using the dimension which uses an IntegratedML prediction model:
You can access this example in my aplication by seaching a notebook called "medical-appointments".