Create a Visual Application

Create Your Project

From the Dataiku DSS homepage, choose +New Project > DSS Tutorials > Advanced Designer > Dataiku Applications (Tutorial). This project has a fully built-out Flow that:

  • Downloads data from the UCI Machine Learning Repository.

  • Lightly processes the data in a Prepare recipe, then branches into two sub-Flows:

    • The Monthly Forecasting sub-Flow models the monthly sales and produces forecasts from the for_predictions dataset.

    • The One Customer’s Invoices sub-Flow contains a filter to look at historical data for a given customer.

../../../_images/flow-starting1.png
  • Select the Download recipe and Build Flow outputs reachable from here.

  • Look at the two dashboards, one for each sub-Flow.

../../../_images/dashboard-forecasts.png ../../../_images/dashboard-one-customer.png
  • We’re going to turn this project into a Dataiku Application so that colleagues can make use of the project without needing to understand the details of the project.

    • First we’ll make the scoring available.

    • Then we’ll add the historical order data for a single customer.

Convert to a Dataiku App

  • From the menus, select … > Application Designer, and select Convert into a visual application

../../../_images/app-designer.png

Optionally give the application a description, make it available to to other users, and give it tags.

../../../_images/app-designer-main-page.png

Generate Forecasts

Now let’s define the application UI for generating forecasts.

  • Click Add Section.

  • Name it Monthly sales forecast.

  • Give it a description like Generate predictive sales by month for the total sales of goods.

  • Click Add Tile and select View dashboard.

  • Give it a title like See results in dashboard.

  • Choose the Monthly sales forecast dashboard.

  • Click Save, then click Test.

This gives us a view of what the app currently looks like to the end user. If you click on the link, it takes you to the dashboard. This is a good first step, but offers no interactivity for the user. Next, let’s add the ability to specify your own forecast horizon.

../../../_images/app-designer-test-01.png
  • Click the Back button in your browser to return to the Application Designer.

  • Click Add Tile > Upload file in dataset.

  • Give it a title like Optionally, upload a CSV containing the months to predict.

  • Click Add help and make the help text The format of the CSV should be: year,month.

  • Select for_predictions as the dataset.

  • Select Only upload file as the tile’s behavior.

  • Reorganize the tiles so that the file upload comes first.

../../../_images/app-designer-upload-file.png

This allows the application user to specify their own forecast horizon, but now we need to add a mechanism to score this dataset and update the dashboard. We can do this with a scenario.

  • Go to Jobs > Scenarios.

  • Click +Create Your First Scenario.

  • Name it Generate predictions and click Create.

  • Go to the Steps tab.

  • Click Add Step and select Build/Train.

  • Click Add Dataset to Build and select for_predictions_scored.

  • Select Build only this dataset as the build mode.

  • Click Save.

Now that we have a scenario to build the dataset, we can add a button to the application that runs the scenario.

../../../_images/scenario-generate-predictions.png
  • Return to the Application Designer.

  • Add a Tile of type Run scenario.

  • Give it a title of Run.

  • Select Generate predictions as the scenario.

  • Reorganize the tiles so that Run comes second.

Lastly, we need to make the model and the dataset available to the application.

  • In the included content section, add for_predictions as an included dataset.

  • Add Prediction sales_by_month as a saved model.

As a final addition to the forecasting functionality of the application, let’s allow app users to download the scored dataset.

  • Add a Tile of type Download dataset.

  • Give it the title Download forecasts.

  • Select for_predictions_scored as the dataset to download.

  • Click Save and then click Test > Create or update test instance (full).

../../../_images/app-designer-test-02.png

Historical Order Data for a Single Customer

Now that we’ve made it possible for application users to generate forecasts, let’s enable them to pull the order data for a single customer.

  • Return to the Application Designer.

  • Add a new section and call it Sales history of one customer.

  • Give it a description like You can generate a dashboard with the detailed sales of one given customer.

Much of what we want to accomplish here is similar to what we did with generating predictions; we want to allow the application user to trigger a scenario that builds the items_of_one_customer dataset and updates the dashboard, and we want to allow them to download that dataset. The new wrinkle is that we want to allow the application user to specify any customer they want.

Right now, that value is hard-coded in the Filter recipe, but we can change that with custom variables.

  • Go to … > Variables

  • Under Local variables, specify

{
  "customer_id": "13758"
}
  • Click Save.

  • Go to the Filter recipe, and update the formula to val('Customer ID') == "${customer_id}".

../../../_images/filter-recipe.png

Now we’ll create the scenario to build this dataset.

  • Go to Jobs > Scenarios.

  • Click +New Scenario.

  • Name it Build dashboard of one customer and click Create.

  • Go to the Steps tab.

  • Click Add Step and select Build/Train.

  • Click Add Dataset to Build and select items_of_one_customer.

  • Select Build only this dataset as the build mode

  • Add a second Build/Train step with invoices_of_one_customer as the dataset to build.

  • Click Save.

Now that we have a custom variable and a scenario, we can build out the app.

../../../_images/scenario-one-customer.png
  • Return to the Application Designer.

  • In the included content section, add the items dataset so that it’s available to the application.

  • Click Add Tile and select Edit project variables.

  • Give it a title of Define.

  • Click Add help and give it help text like For example, you can use 17191 or 13758.

  • We only need the app user to set a single custom variable, so for behavior, select Edit inline with auto-save.

  • Now we need to specify the settings for the custom variable. This can be done with the following JSON

[
   {
      "name": "customer_id",
      "type": "INT",
      "label": "The dashboard will be for this customer",
      "mandatory": false,
      "canSelectForeign": false,
      "markCreatedAsBuilt": false,
      "allowDuplicates": true,
      "getChoicesFromPython": false,
      "canCreateDataset": false
   }
]
../../../_images/app-designer-project-vars.png
  • Click Add Tile > Run scenario.

  • Give it a title of Run.

  • Select Build dashboard of one customer as the scenario to run.

  • Click Add Tile > View dashboard.

  • Give it a title of See results in dashboard.

  • Select Sales history of one customer as the dashboard.

  • Click Add Tile > Download dataset.

  • Give it a title of Download all the sales of this customer (XLSX format).

  • Select items_of_one_customer as the dataset to download.

  • Select Excel (*.xlsx) as the format.

  • Click Save.

The app is now available for everyone’s use from the Dataiku DSS homepage.