This page explains how to quickly get started with MADlib® using a sample problem.
One you have MADlib installed, you can use the available Jupyter notebooks for many MADlib algorithms.
Please refer to the Installation Guide for MADlib on how to install from binaries, as well as step-by-step descriptions on how to compile from source.
Please note that a Greenplum database sandbox VM with MADlib pre-installed is also available to get started quickly, as an alternative to installing MADlib yourself.
Sample Problem Using Logistic Regression
- The sample data set and an introduction to logistic regression are described here.
The MADlib function used in this example is described in the MADlib logistic regression documentation.
Suppose that we are working with doctors on a project related to heart failure. The dependent variable in the data set is whether the patient has had a second heart attack within 1 year (yes=1). We have two independent variables: one is whether the patient completed a treatment on anger control (yes=1), and the other is a score on a trait anxiety scale (higher score means more anxious).
The idea is to train a model using labeled data, then use this model to predict second heart attack occurrence for other patients.
To interact with the data using MADlib, use the standard
psqlterminal provided by the database. You could also use a tool like
Call MADlib built-in function to train a classification model using the training data table as input:
View the model that has just been trained:
Now use the model to predict the dependent variable (second heart attack within 1 year) using the logistic regression model. For the purpose of demonstration, we will use the original data table to perform the prediction. Typically a different test dataset with the same features as the original training dataset would be used for prediction.
1 entry in the
ARRAY denotes an additional bias term in the model in the standard way, to allow for a non-zero intercept value.
If the probability is greater than 0.5, the prediction is given as
True. Otherwise it is given as
- For details on all of the machine learning functions provided by MADlib, please refer to User Documentation
- Try out the available Jupyter notebooks for many MADlib algorithms
- To contribute new modules to MADlib, please refer to the Quick Start Guide for Developers