DecisionTreeTask
Constructs an LLM-driven symbolic decision tree classifier. Proposes semantic splitting rules using LLMs and validates them against data using Information Gain.
Category: Reasoning
Output: Kotlin Code
Model: GPT-4 Preferred
⚙️ Execution Config
{
"task_type": "DecisionTree",
"data_file": "data/customer_churn.csv",
"target_column": "churn_risk",
"max_depth": 3,
"candidate_rules": 5
}
→
👁️ Generated DecisionTree.kt
fun predict(record: Map<String, String>): String {
// Probability: 0.89 (n=142)
if ((record["usage_hours"]?.toDoubleOrNull() ?: 0.0) > 50.0) {
if (record["support_tickets"] == "0") {
return "Low Risk"
} else {
return "Medium Risk"
}
} else {
return "High Risk"
}
}
Test Workspace Browser
Explore generated decision trees and training logs in the task workspace.
TaskExecutionConfig Parameters
| Field | Type | Description |
|---|---|---|
data_file* |
String |
The data file to analyze (CSV or JSONL). Must exist in the workspace. |
target_column* |
String |
The target column name to predict. |
max_depth |
Int | Maximum depth of the tree. Default: 3. |
candidate_rules |
Int | Number of candidate rules the LLM generates per node. Default: 5. |
Task Lifecycle
- Initialization: Validates
data_fileexistence andtarget_columnpresence in headers. - Rule Proposal: LLM analyzes data samples to propose semantic rules (
==,!=,>,<,contains,matches). - Validation: Calculates Information Gain for each candidate rule against the full dataset.
- Recursive Split: Selects the optimal rule and recurses until
max_depth, purity > 95%, or minimum record count is reached. - Code Generation: Compiles the symbolic tree into a standalone, executable Kotlin function.
Embedded Execution
To invoke this task programmatically using the Cognotik library:
import com.simiacryptus.cognotik.plan.tools.reasoning.DecisionTreeTask
import com.simiacryptus.cognotik.plan.tools.reasoning.DecisionTreeTask.Companion.DecisionTree
fun generateModel(harness: UnifiedHarness, workspace: File) {
val config = DecisionTreeTask.DecisionTreeTaskExecutionConfigData(
data_file = "data/training_set.csv",
target_column = "label",
max_depth = 4,
candidate_rules = 10
)
harness.runTask(
taskType = DecisionTree,
typeConfig = TaskTypeConfig(), // Default static config
executionConfig = config,
workspace = workspace,
autoFix = true
)
}
CLI / CI Integration
Run via the command line by passing the instruction to the orchestrator:
java -jar cognotik-cli.jar \
--instruction "Build a decision tree for 'churn' using 'customers.csv' with depth 3" \
--workspace ./project
Prompt Segment
The following context is injected into the orchestrator to describe this capability:
DecisionTree - Build an LLM-driven symbolic decision tree
** Specify the data file (CSV)
** Specify the target column to predict
** Configure max depth and candidate rules
** Uses LLM to propose semantic splitting rules
** Validates rules using Information Gain
** Generates executable code