In this tutorial, learn how to create a Jupyter Notebook that contains Python code for defining linear regression, then use TensorFlow to implement it. The notebook runs on IBM Cloud Pak® for Data as a Service on IBM Cloud®. The IBM Cloud Pak for Data platform provides additional support, such as integration with multiple data sources, built-in analytics, Jupyter Notebooks, and machine learning. It also offers scalability by distributing processes across multiple computing resources.
In simple terms, linear regression is the approximation of a linear model that is used to describe the relationship between two or more variables. In a simple linear regression there are two variables:
- The dependent variable, which can be seen as the “state” or “final goal” that we study and try to predict
- The independent variables, also known as explanatory variables, which can be seen as the “causes” of the “states”
When more than one independent variable is present the process is called multiple linear regression. When multiple dependent variables are predicted, the process is known as multivariate linear regression.
The equation of a simple linear model is:
In this equation, Y is the dependent variable, X is the independent variable, and a and b are the parameters that we adjust. a is known as “slope” or “gradient,” and b is the “intercept.” You can interpret this equation as Y being a function of X, or Y being dependent on X.
- An IBM Cloud account.
- IBM Cloud Pak for Data
- A working knowledge of Python
- A working knowledge of TensorFlow
It should take you approximately 30 minutes to complete this tutorial.
- Create your IBM Cloud account and access IBM Cloud Pak for Data as a Service
- Create a new project
- Associate the Watson Machine Learning Service with the project
- Add the data set to your project (If you’re using IBM Cloud Pak for Data as a Service)
- Add a notebook to your project
- Run the notebook
Create IBM Cloud account and access IBM Cloud Pak for Data as a Service
- Sign in to IBM Cloud.
Search for IBM Watson® Studio.
Create the service by selecting the region and pricing plan, then click Create.
Create a new project
Start the Watson Studio service.
Click Create a project and Create an empty project. Make sure that you name your project and add a storage service, then click Create.
After your project is created, you are directed to a project dashboard.
Associate the Watson Machine Learning Service with the project
- Go to the Settings of the project.
Click Add service in the Associated services, and select Watson in the drop-down menu.
Add the Watson Machine Learning Service.
Mark the service and associate it with the project.
Add the data set to your project
Add the data set to your project by clicking browse on the right, and selecting csv file. You can download the data set from the following URL:
After the data set is uploaded, it appears under the Data Assets.
Add a notebook to your project
Add a Jupyter Notebook to your project by clicking Add to Project, and selecting Notebook in the menu.
Select From URL, and paste the notebook URL from the GitHub repo:
Name your notebook, and click Create.
Run the notebook
After the notebook is loaded, go through the notebook. Click Cell, and Select Run All to run the notebook.
The notebook provides a simple example of a linear function to help you understand the basic mechanism behind TensorFlow.
In this tutorial and associated notebook, you learned the basics of linear regression and how TensorFlow is used to implement machine learning algorithms. You learned how to run a Jupyter Notebook using Watson Studio on IBM Cloud Pak for Data as a Service, and how to use open source frameworks in IBM Cloud Pak for Data as a Service.