Before You Begin

This 15-minute tutorial shows you how to use a CART predictive model, inspect the results of running the data flow to create the CART model, apply a predictive model to your dataset, and visualize the impact in a workbook.

Background

You can create a different predictive model using a classification and regression tree (CART) for numeric prediction with the random sample donation dataset. The CART predictive model classifies all the records in the dataset based on inputs and assigns an expected record for each class. In this tutorial, you use the CART model to predict the total donations.

You also score a dataset using the trained model by applying the predictive model. You run analysis and create visualizations using the predictive measure along with other metrics, dimensions, or dataset mash-ups.

This is the third tutorial in Train and Apply Predictive Models in Oracle Analytics. Read the tutorials in the order listed.

What Do You Need?

  • Oracle Analytics

    When using Oracle Analytics Desktop, you must install machine learning (DVML) to use Diagnostics Analytics (Explain), Machine Learning Studio, or advanced analytics.

  • Access to the following:
    • elastic_train_df data flow
    • sample_donation_data dataset
    • donations_random_sample workbook

Modify the Predictive Model

  1. On the Home page, click Data, enter elastic_train_df in the Search bar, and then click Search.
  2. In the elastic_train_df, click the Actions Actions menu icon, and then select Open.


    Description of donations_elast1_n2.png follows
    Description of the illustration donations_elast1_n2.png
  3. In the data flow, click the Train Numeric Prediction step.
  4. In Train Numeric Prediction, click Elastic Net Linear Regression for model training in the Model Training Script row.
  5. In Select Train Numeric Prediction Model Script, click CART for Numeric Prediction training, and then click OK.
  6. In Train Numeric Prediction, click Select a column in the Target row, and then select TOTAL_DONATIONS from Available Data.
  7. Click the Save Model step. In Save Model, enter cart_model_1. Click Save.
  8. Click Run Data Flow Run Data Flow icon.

Review the CART Model Related Datasets

  1. Click Go back Back icon. On the Home page, click Machine Learning.
  2. In the cart_model_1, click the Actions Actions menu icon, and then select Inspect.
  3. In cart_model_1, click Quality to see the distribution of residual values and overall statistics.


    Description of cart_model_quality.png follows
    Description of the illustration cart_model_quality.png
  4. Click Related to view the generated datasets.
  5. Click Close.

Add the CART Scenario to the Workbook

  1. On the Home page, enter donations_random_sample workbook, and then click Search.
  2. In the donations_random_sample workbook, click the Actions Actions menu icon, and then select Open.
  3. If the visualization contains multiple TOTAL_DONATIONS lines, right-click elastic_model_1 in the Data panel, and then select Remove From Workbook. In Remove Scenario, click Yes.


    The TOTAL_DONATIONS by POSTED_DATE line visualization refreshes to remove the prediction line related to the scenario.

    Description of elastic_model1_removed.png follows
    Description of the illustration elastic_model1_removed.png
  4. In the Data panel, click Add Add icon, and then select Create Scenario.
  5. In Create Scenario, select cart_model_1, and then click OK.
  6. In the Data panel, expand the cart_model_1 node. Select TOTAL_DONATIONS, and then drag it to Values (Y-Axis) in the Grammar panel.


    The CART numeric prediction model produces results similar to the elastic model.

    Description of cart_model_total_donations.png follows
    Description of the illustration cart_model_total_donations.png
  7. Click Save.

Review CART Numeric Model Segments

  1. Click Add Canvas Add Canvas icon. In the Data panel under the cart_model_1 node, select and drag Segments to Canvas 2.


    The CART model segment objects show the leaf branches of the tree.

    Description of cart_model_segments.png follows
    Description of the illustration cart_model_segments.png
  2. In the Data panel under the cart_model_1 node, select and drag TOTAL_DONATIONS to Rows in the Grammar panel.


    The table shows the distribution of donations to the CART branches.

    Description of segments_total_donations.png follows
    Description of the illustration segments_total_donations.png

Modify the CART Model

  1. Click Go back Back icon. In Save Changes, click Don't Save.
  2. On the Home page, enter elastic_train_df, and then click Search.
  3. In the elastic_train_df, click the Actions, and then select Open.
  4. In the data flow, click the Train Numeric Prediction step.
  5. In Maximum Depth, click the up arrow to increase the value to 7.
  6. Click the Save Model step. In Save Model, enter cart_model_2.


    Description of elastic_train_df.png follows
    Description of the illustration elastic_train_df.png
  7. Click Run Data Flow.
  8. On the Home page, enter donations_random_sample workbook, and then click Search. In the donations_random_sample workbook, click the Actions Actions menu icon, and then select Open.
  9. In the Data panel, click Add Add icon, and then select Create Scenario. In Create Scenario, select cart_model_2, and then click OK.
  10. Click Canvas 1, in the Data panel expand the cart_model_2 node. Select TOTAL_DONATIONS and drag it to Values (Y-Axis) in the Grammar panel.


    The results are similar to the other prediction models.

    Description of cart_model2_donations.png follows
    Description of the illustration cart_model2_donations.png
  11. Click Add Canvas Add Canvas icon. In the Data panel under the cart_model_2 node, select and drag Segments to Canvas 2.
  12. In the Data panel under the cart_model_2 node, select and drag TOTAL_DONATIONS to Rows in the Grammar panel.


    Increasing the maximum depth in cart_model_2 provides more granular leaf levels in the tree.

    Description of cart_model_2_segments.png follows
    Description of the illustration cart_model_2_segments.png

Score a Dataset

  1. Click Go back Back icon. On the Home page, click Create, and then select Data Flow. In Add Dataset, select sample_donation_data, and then click Add.
  2. Double-click Apply Model in the Data Flow Steps panel. In Select Model, click cart_model_1, and then click OK.
  3. Double-click Save Dataset to add it to the data flow. In Save Dataset, enter scored_donation_dataset in Name.
  4. Click Save, and select Save As. In Save Data Flow As, enter scored_donation_dataset_df, and then click OK.
  5. Click Run Data Flow Run Data Flow icon.

Create a Workbook with the Scored Dataset

  1. Click Go back Back icon. On the Home page, click Create and click Workbook.
  2. In Add Dataset, click scored_donation_dataset, and then click Add to Workbook.
  3. In the Data panel, hold down the Ctrl key select PredictedValue and TOTAL_DONATIONS and DATE_POSTED. Right-click, select Pick Visualization, and then select Line.
  4. Select TOTAL_DONATIONS and move it to Values (Y-Axis) in the Grammar panel.


    Description of predictivevalue_viz.png follows
    Description of the illustration predictivevalue_viz.png
  5. Right-click DATE_POSTED in the Grammar panel, select Show by, and then select Quarter.


    Description of predictive_viz_by_qtr.png follows
    Description of the illustration predictive_viz_by_qtr.png
  6. Select SCH_METRO in the Data panel and drag it to Trellis Columns in the Grammar panel.


    Description of predictive_sch_metro.png follows
    Description of the illustration predictive_sch_metro.png

Learn More