SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Machine Learning Primer for the SAP Developer

Build a simple machine learning text classification model to predict "Who said it, Star Wars or Elon Musk?"

Overview

🎓 beginner 60 min. Machine LearningBeginnerArtificial Intelligence

You will learn

  • โœ”How to use Python, Jupyter Notebook, Numpy, and Pandas
  • โœ”How to build a text classification model using Scikit-Learn
  • โœ”How to analyze model accuracy
Ed Herrmann E Ed Herrmann September 12, 2024
Created by December 2, 2020
Contributors

Prerequisites

Prerequisites

  • General understanding of Python helpful, but not required

Steps

Building Blocks

Step 1 Launch Jupyter Notebook
โ€”

The development environment used here is Jupyter Notebook and steps are included to be able to run it on the cloud based service Binder; however, you can also install and run it locally if desired. Local installation is out of the scope of this tutorial, but you can find more information at jupyter.org

For this tutorial, there are two different notebook files to choose from. Both are available on GitHub at https://github.com/SAP-samples/cloud-ml-basic-intro

  • cp-ml-primer.ipynb - preferred notebook with descriptions, but little to no code. Code must be copied and pasted from tutorial directly.
  • cp-ml-primer-solution.ipynb - notebook with both descriptions and code if you are in a hurry or get stuck

Binder is a cloud based service that allows you to pull a notebook from a GitHub repository and launch it in a cloud based Jupyter notebook server.

  1. Launch the notebook by either:
  2. The server will launch and open in your browser.

Jupyter launch in browser
Jupyter launch in browser

IMPORTANT

Binder will timeout and disconnect if left idle for too long, so it is important to frequently use the option to save and load your changes using browser storage.

Binder Browser Storage
Binder Browser Storage

You can also download your notebook .ipynb file and save it locally, which can be used on any Jupyter Notebook server later using menu option File->Download as>Notebook

Download Notebook File
Download Notebook File

Step 2 Getting Familiar with Jupyter
+
Step 3 Install `NumPy` Package
+
Step 4 Using `NumPy`
+
Step 5 Using `Pandas`
+
Step 6 Install Scikit-Learn
+
Step 7 Prepare Musk Data
+
Step 8 Prepare Star Wars Data
+
Step 9 Combine Datasets
+
Step 10 Vectorization - Fit / Train
+
Step 11 Shuffle and Split Data
+
Step 12 Vectorization - Transform Training Data
+
Step 13 Train the Model
+
Step 14 Predict Test Data
+
Step 15 Metrics
+
Step 16 Chart Confusion Matrix
+
Step 17 Build Pipeline
+
Step 18 Ad Hoc Predictions
+
Step 19 BONUS: UI for Fun
+
Step 20 The End: Congrats
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 20
1. Launch Jupyter Notebook 2. Getting Familiar with Jupyter 3. Install `NumPy` Package 4. Using `NumPy` 5. Using `Pandas` 6. Install Scikit-Learn 7. Prepare Musk Data 8. Prepare Star Wars Data 9. Combine Datasets 10. Vectorization - Fit / Train 11. Shuffle and Split Data 12. Vectorization - Transform Training Data 13. Train the Model 14. Predict Test Data 15. Metrics 16. Chart Confusion Matrix 17. Build Pipeline 18. Ad Hoc Predictions 19. BONUS: UI for Fun 20. The End: Congrats

Learn more →