![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
operational-decision-tree
Advanced tools
A Decision Tree executor that uses decision modules to decide pathways. Can accept binary or arbitrary decision modules.
This package is brand new. I have yet to use it for the project I built it for. Consequently, this project may change soon.
ODT is a decision tree executor designed to run decision trees that are human-built and managed. You give it a tree object and a subject object. It then runs the tree against the subject and passes back the leaf node along with any data generated along the way.
Usage looks like this:
var ODT = require('operational-decision-tree')
var treeData = require('./binary-tree.json')
var person = {
name: "Bob",
age: 37,
nationality: 'US'
}
var DecisionTree = new ODT({
makeDecision: {},
runOnHit: {}
})
DecisionTree.run(treeData, person, function (err, resultBranchNode) {
if (err) console.error(err)
console.log("Result", resultBranchNode)
})
Each node can have the following properties:
var node = {
"decisions": [], // the decisions that will be run for this node in order to produce an output branch
"branches": [], // each branch is another node
"runOnHit": [], // a list of function names to run when this node is hit.
"makeDecision": "" // the name of a function to run instead of the built in comparison function
}
For each node:
Once we hit a branch node that doesn't have either the 'decisions' property or the 'makeDecision' property, then the callback is triggered with the branch node as the result.
For each comparison, ODT compares the subject data to the tree data based on the "operation" parameter you pass in the tree. Supported operations are:
subject value is greater than tree comparison value
= subject value is greater than or equal to tree comparison value
The number of decisions should always be one less than the number of branches. In the event that all decisions come back false, the last branch is chosen.
binary-tree.json
{
"decisions": [
[{
"property": "age",
"operation": ">",
"value": 40
}]
],
"branches": [
{
"runOnHit": [
"howOld"
],
"decisions": [
[{
"property": "random",
"operation": "<",
"value": 30
}],
[{
"property": "random",
"operation": "<",
"value": 50
}],
[{
"property": "random",
"operation": "<",
"value": 90
}]
],
"branches": [
{"result": "Leaf A: Aged under 40 and random less than 30"},
{"result": "Leaf B: Aged under 40 and random between 30 and 49"},
{"result": "Leaf C: Aged under 40 and random between 50 and 89"},
{"result": "Leaf D: Aged under 40 and random between 90 and 99"}
]
},
{
"decisions": [
[{
"property": "nationality",
"operation": "in",
"value": ["US", "CA"]
}]
],
"branches": [
{
"decisions": [
[
{
"property": "age",
"operation": "<",
"value": 60
},
{
"property": "gender",
"operation": "==",
"value": "male"
}
]
],
"branches": [
{"result": "Leaf E: Over 60 or female, and not from US"},
{"result": "Leaf F: Male under 60 and not from US"}
]
},
{
"makeDecision": "decideFinalBranch",
"decisions": [
[{
"property": "percentage"
}]
],
"branches": [
{"result": "Leaf G"},
{"result": "Leaf H"},
{"result": "Leaf I"}
]
}
]
}
]
}
FAQs
A Decision Tree executor that uses decision modules to decide pathways. Can accept binary or arbitrary decision modules.
The npm package operational-decision-tree receives a total of 1 weekly downloads. As such, operational-decision-tree popularity was classified as not popular.
We found that operational-decision-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.