Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Given multiple columns of numeric types and one column which has less than 3 distinct values (for labels) it will try to build multiple queries where each query will represent single label type.

Operator Usage in Easy Mode

  1. Click + on the parent node.
  2. Enter the Build Decision Tree operator in the search field and select the operator from the Results to open the operator form.
  3. In the Table drop-down, enter or select the table to create a model.
  4. In the Max Depth field, enter the maximum depth parameter to construct the decision tree.
  5. In the Impurity field, enter the threshold for a node to be counted as decided vs. undecided.
  6. Optional. In the Columns, click Add More to add an additional list of columns. The first column will be treated as label columns, the rest will be used as feature columns.
  7. Click Run to view the result.
  8. Click Save to add the operator to the playbook.
  9. Click Cancel to discard the operator form.

Usage Details

LQL Command

buildDecisionTree(table: TableReference, maxDepth: Long, impurity: Double, columns:String*)

Parameters:
table (TableReference) - The table to create a model
maxDepth (Long) - Max depth parameter to construct decision tree
impurity (Double) - Impurity threshold for a node (e.g. query) to be counted as decided vs undecided. You can think of this as inverse confidence. For example: 0.01 means uncertainty = 0.01, e.g. if it is 99% certain it will create a rule.
columns: List of columns to manually specify label and feature columns, first column will act as a label, rest will be features. If you specify one column, then it will be label, rest numeric columns will be automatically set to be feature columns
**Returns:

Returns one row with one column where the cell contains JSON object with TreeModel and Data objects. TreeModel will contain the array of queries, Data will contain predicted data.

** Example **

`` {sql}df =select rand() as f1, rand() as f2, rand() as f3 from tabledf1 =select *, case when f1 > 0.5 then 1 else case when f2 > 0.5 then 2 else 0 end end as label from df` df2 = buildDecisionTree(df1, 5, 0.05, "label", "f1", "f2", "f3") //buildDecisionTree(df1, 5, 0.5, "label") should also work

** Output **  
Output should be JSON object which will contain `TreeModel` and `Data` objects,  
where TreeModel contains tree nodes, e.g. conditions, and Data will contain addition columns:lhub_decision_tree_node_impurity, lhub_decision_tree_path, lhub_decision_tree_predicted_label, lhub_isDecided, these columns are the output of decisionTreeModel. 


``` {json}"data":{
   "TreeModel":[...],
   "Data":[...]
}

you can extract the data into table as well as follow:

{java}jsonToTable(df2, "RESULT.Data")

This would create an input table back with additional columns mentioned above which is the prediction and path information.

  • No labels