Kubernetes with OpenShift World Tour: Get hands-on experience and build applications fast! Find a workshop!

Predict home value using Golang and in-memory database machine learning functions

This blog is part of the Db2 for AI learning path.

Summary

Predictive analytics uses historical data to predict future events. Typically, historical data is used to build a mathematical model that captures important trends. That predictive model is then used on current data to predict what will happen next or to suggest actions to take for optimal outcomes. This code pattern uses the same approach to predict home values using historical data. We’ll create a model using the historical data using different statistical algorithms and use that model to predict home values for new home data. Real estate agents and home buyers can utilize this functionality to easily get the ideal price for a home they’re trying to sell. This code pattern also uses built-in analytical stored procedures to create a model and predict a home price based on that model.

Description

This code pattern creates an AI application using Golang, which uses IBM Db2 Warehouse on Cloud built-in stored procedures to train and run models on data residing in IBM Db2 Warehouse on Cloud. This specific application runs the built-in linear regression stored procedure to predict the home sales price based on the provided property details.

IBM Db2 Warehouse on Cloud has built-in stored procedures to help you analyze data. Operations and computations are performed by the IBM Db2 Warehouse on Cloud engine itself without having to move the data. This helps you achieve greater performance in terms of computations and retrieval of the results. You can read more about the different algorithm that IBM Db2 Warehouse on Cloud supports in the form of stored procedures here.

After you’ve completed this code pattern, you’ll understand how to:

  • Load housing data into IBM Db2 Warehouse on Cloud
  • Enrich data using the IBM Db2 Warehouse on Cloud built-in function
  • Create a linear regression model using the IBM Db2 Warehouse on Cloud built-in function
  • Predict the sales price of a new home

Flow

flow

  1. Load training data to IBM Db2 Warehouse on Cloud.
  2. IBM Db2 Warehouse stores training and test data in a table.
  3. Train the model by running the built-in stored procedure in IBM Db2 Warehouse on Cloud.
  4. An application written in golang to predict home sale price.
  5. The prediction logic is exposed through an API.
  6. Frontend application calls the API to get the prediction results.

Instructions

Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.

Conclusion

This code pattern showed you how to create an AI application using Golang–with IBM Db2 Warehouse on Cloud built-in stored procedures to train and run models on data residing in IBM Db2 Warehouse on Cloud. The code pattern is part of the Learning Path: Db2 for AI series. To continue the series and learn about Db2 for AI features, take a look at the next code pattern, Predict home value using Python and machine learning.

Vinayak Agrawal
Sanjeev Ghimire