Hi, and welcome to unit six of the SAP Data Intelligence for Enterprise AI course.
In this unit, we will dive deeper into the ML Scenario Manager, and show you a
demo of an ML scenario. ML Scenario Manager is developed with the idea
of providing the tools which a data scientist or machine learning engineer needs, to perform their tasks.
Typical personas that can benefit from ML Scenario Manager can be data scientists,
or Machine Learning experts, or whoever is interested in developing a data-driven scenario.
ML Scenario Manager can be used in experimentation, development, productization, improvements, or bug fixing.
For instance, using the Jupyter Notebook, data enthusiasts can run some experiments,
or using the data pipelines, they can develop their algorithms, using pre-defined or custom operators.
They can also productize their scenario, using the pipeline workflows,
and manage all the artifacts from the ML Scenario Manager. We also provide monitoring and tracing capabilities,
which could be used for improvements and bug fixing. As you saw in the demo in the previous unit,
you can manage your data science assets in one single scenario,
and also create versions for them. As a data scientist, you run multiple experiments,
making quick changes in your datasets, and run different models to find the best solution,
as fast as possible. Having one single place
that can bind the relevant dataset to its model is very helpful, because then you don't confuse
which version of your data actually produces the best result.
You can also use the ML Scenario Manager to create some pipelines, and train
and deploy your model, with the click of a button. Let's see a whole scenario management story
in the next example. The example that I want to share with you here
tries to answer the business question of whether we can predict the book returns based on their genre.
Basically, we're trying to understand whether the returning of purchased books
has any correlation with their genre. A similar scenario
can be used, for instance, in your company, if you are trying to solve any binary classification problem.
We broke down the job into three tasks. One is to look at the historical transactions,
the second job is to use these books' content to extract their genre,
and third is to find the correlation between the type of genre, and the return.
We are also going to use three datasets which we'll look at here, the books
and book transaction datasets that are saved in our HANA system.
As you can see, the books dataset has information about the books, such as the ID, the author,
the year, language, and so on. We would also like to enrich this dataset,
by adding a new column to it called genre, but this information is not available,
so using our SAP Data Intelligence, we want to predict this column.
The book transactions table has information about the books, the transaction data, point of sales,
and returned information, whether the sold book is returned or not, and also
the returned prediction column is what we need to fill in. We also have another table, called CMU book summary dataset,
which is saved in our Amazon S3 storage as a .csv file, and includes about 17,000 abstracts
of books, with their labeled genres. Let's look at how we build this solution
using SAP Data Intelligence. By now you're familiar with the SAP Data Intelligence launchpad.
You can click on Data Intelligence ML Scenario Manager, where you can create a scenario,
for instance, in this case, the book return scenario. You can add or register your dataset
that you're working with, and that way you can basically bind your dataset
to the scenario that you're developing, and also you have a technical identifier
for the dataset that you have registered, where you can refer to that dataset
during your development, without really needing to enter a path for it.
Then, for instance, I want to run some experiments, and I say I want to create a Jupyter Notebook
for that, so it takes me to my Jupyter Lab, where I can choose what type of kernel I want to use,
for instance, a kernel two or a kernel three. In this case, I want to use Python 3.
And then I can, for instance, use pip install, TensorFlow, scikit-learn, Boto 3,
whatever library that I need to use, and once I install that, that would be available
as part of my ML Scenario Manager. Then I can copy and paste my code,
or I can write my code, for instance, here, because I'm connected to HANA,
then I have to use, for instance, the HANA connector, and once the connection has been established,
I can see, for instance, the first five rows of the dataset, and also I can come here, and, for instance,
define my tokenizer, and encode my data, do some pre-processing,
in order to make the data ready for the training.
So the idea here is, if I can, based on the dataset, and based on the abstract of the data,
I can predict the genre of the data. So then, for instance, here I use a tokenizer,
I use the keras, and I index the data,
and then I try to train my model, so I split my data into training and test,
and I split the label as well, and run the same processes that I do for the training,
exactly for the test scene, to get the same results.
So here, as you can see, I trained my model,
and now this information can be used for my prediction. And I have defined three epochs here for my training.
So I have to wait a few seconds for the epochs to run.
You can see, for instance, the accuracy result, the loss, and the information like that.
Now, after I'm happy with the experiment that I ran on my Jupyter Notebook,
I can create a pipeline, and productize, basically, whatever I have experimented with
in my Jupyter Notebook. In this case, because I'm running the training,
I use a Python producer pipeline. Like we mentioned, creating a template
as a Python producer will build this pipeline for you, which has all the operators
that it needs to run your Python code, and at the end, submit the result,
which will be, for instance, the model, or will be the KPIs to your ML Scenario Manager.
You can also create a new pipeline, and transfer it here,
using the JSON code of the pipeline, and that is what we did here,
because we made some changes. For instance, here we not only want to save the model,
but also the tokenizer. So I needed two artifact submit operators,
so that's what I did. And so I copy and paste the code
that I developed in the Jupyter Notebook into my Python 3 operator here.
And a little difference here is that you cannot go and install your libraries,
like you did in the Jupyter Notebook, but what you can do
is you can create a Dockerfile, like you see here, so I create a Dockerfile,
and then I, for instance, I want to pip install NumPy, or pandas, or scikit-learn,
and once I do that, I can tag it with the proper libraries,
and I can basically name the whole thing, for instance, here end to end,
this is an end-to-end scenario that I'm developing, and then, once I want to run this code,
I have to group my Python operator, and tag it with the proper libraries,
and, for instance, here I can say end to end, because that's how I refer to that Dockerfile
that has all the libraries needed. And then I will add, for instance,
an artifact producer for my tokenizer, because that is something that I want to be also consumed,
as part of the ML Scenario Manager. Then I come back to my ML Scenario Manager,
and I create a version, a new version, because of the changes that I have made,
and then, I will run the pipeline that I have created through the ML Scenario Manager.
This will allow me to manage all the artifacts from one single place.
So the model name, let's say that I want to call it, for instance, N, I want to find the genre,
and then the tokenizer, I want to call it T, and the dataset, like I mentioned,
I don't need to put in the full path, I can just put in the technical identifier,
and refer to the dataset in that manner. And then after it is done,
I can basically run the pipeline. So as you can see, the status is pending,
until it collects all the resources that it needs in order to run that pipeline,
and then after the execution is completed, I can see the result through the ML Scenario Manager.
So that is very interesting, for instance, if you have different models that you're running,
and you want to see the result in one single place. So now you can see, for instance,
the accuracy is 80%, and so I'll also have the artifacts, which are my models,
and the tokenizer. And after that is completed,
I can actually deploy the model that I have created. So, for instance, here I can say,
okay, so let's create a pipeline, which we call Model Deployment, and this time, instead of Python producer,
I want to use Python consumer. And so again, creating a template
will create all the proper operators that you need in order to execute that pipeline.
For instance, you have the OpenAPI Server here, which allows you to have a REST API
for the model that you're creating, and that REST API can be consumed
in your business application, in order to, for instance,
call your trained model, and get some result out of it.
So here, for instance, you can see, I have copied and pasted my Python code
where I want to, the way I want to run the serving, for instance, for my trained model.
And then, after I'm happy with the Python code that I have created, I can basically come
to my ML Scenario Manager, create a new version, because of the new pipeline
that I have added, and then deploy the model. Deploying the model, I can refer to, for instance, the model
and the tokenizer that I created during the training, and after it is done,
while it is running, you will see that basically there is,
I will show you here. Yes.
So you will see that there is a REST API there, which is available to you,
and you can call it through your business application. And for instance, here I used Postman.
This is just an example of how you can make the call to that service
that you have created, and get the result. For instance, this is a new abstract to be classified,
just a simple text for us to test, and then you see that, for instance,
a result came back, A, as fiction, maybe this is the way
that they write in the fiction abstracts, and that's the closest we predicted for the genre of this book.
And then, this information can be used for predicting the book return.
So then, like I mentioned, we have, for instance, our HANA system,
and we have the book transactions, and we can go there,
and, for instance, push down the execution to PAL, which runs natively on HANA,
and then do a binary classification of whether, based on this genre, the book is going to be returned or not,
after we enrich our data book dataset with the genre as well.
Excellent. Hope you enjoyed this unit.
We learned more about the data science personas that we target for SAP Data Intelligence.
Also, we showed you a demo of how to use ML Scenario Manager to fulfill, build, and manage
your machine learning-related tasks. In the next unit, we will focus more
on how to use the Jupyter Lab. Good luck with your quiz and see you soon.