Automating Logistic Regression Workflows

Posted by

Continuing with our series of posts about Logistic Regression in this fifth post we will focus on the point of view of a WhizzML user. WhizzML is BigML’s popular domain specific language for Machine Learning, which provides programmatic support for all the resources you work with in BigML. You can use WhizzML scripts to create a Logistic Regression, or to create a prediction or batch prediction based on a Logistic Regression.  

Let’s begin with the easiest one: If you want to create a Logistic Regression with all the default values you just need to create a script with the following source code:


As BigML’s API is asynchronous, the create call will probably return a response before the Logistic Regression is totally built. Thus, if you want to use the Logistic Regression to make predictions, you should wait until the creation process has been completed. If you want to stop the code from processing until the Logistic Regression is finished you can use the “create-and-wait-logisticregression” directive.


To modify the default value of a Logistic Regression property you can simply add it in the properties map as a pair: “<property_name>” <property_value>. For instance, to calculate a Logistic Regression with a dataset that contains missing values, the normal default behavior in BigML is to replace them by the mean. However, if you want to replace them by zero you should add default_numeric_value and set it to “zero”. The source code will be as follows:


You can modify any configuration option in similar fashion. The BigML API documentation contains detailed information about those properties.

What if you have an existing Logistic Regression, and you want to get the code needed to recreate it with WhizzML? No problem, programmer or not BigML has a solution for you. Say you already tuned a Logistic Regression in BigML and you want to repeat the process on a new source that you just uploaded to the service. You can easily use the scriptify utility. This will generate a script that will run the exact steps needed to reproduce the Logistic Regression. Just navigate to the Logistic Regression you want to replicate and click on the “SCRIPTIFY LOGISTIC REGRESSION” link.


If you want to create a prediction from your Logistic Regression with WhizzML, the code is also short and easy. You just need the ID of the Logistic Regression you want to use and a collection of the new instances that you want to predict for, i.e. your input data. In the input_data collection the field ID is used as key.  Here’s an example:


In case you need to predict not for a single instance but for a set of new instances, you will need to create a batch prediction from your Logistic Regression by using WhizzML.


Once your source code is in place, how do you execute your script?

  • Using the BigML Dashboard, look for the script you just created. Opening the script view will reveal the available inputs, and you will be able to select their new values after which you can start the execution. For instance, the first script on this post looks as follows, and it expects you to select the dataset you want to create the Logistic Regression from.
  • If you want to execute the script through the API, you need to know the ID of the script you previously created. To follow the same example, the dataset you want to create a Logistic prediction for (input “ds1”) should be included in the list of inputs. The corresponding request to the BigML API should be as below:

    curl "$BIGML_AUTH"
           -X POST
           -H 'content-type: application/json'
           -d '{"script": "script/55f007d21f386f5199000003",
                "inputs": [["ds1", "dataset/55f007d21f386f5199000000"]]}'

These Logistic Regressions should execute swiftly, while you reach out for you coffee.

If you have any doubt or you want to learn more about Logistic Regression please check out our release page for documentation on how to use Logistic Regression with the BigML Dashboard and the BigML API. You can also watch the webinar, see the slideshow, and read the other blog posts of this series about Logistic Regression.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s