Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python and validating business rules based on a decision tree

Say you have a set of determistic business rules in an admin system that you want to check. The rules can be based on numeric, boolean, categorical, etc. values, e.g.:

if product in ['x','y','z']:
    if age > 30:
        if amount < 100000:
            rule = 'A'
elif product == 'a':
    rule = 'B'
elif ....

Possible checks can be based on a file with possible values or a check that compares the decision tree as a whole provided you have the analysis in a certain format.

You can program these sort of tests, but before starting something from scratch I'm searching if there are some python packages that can help in this sort of work or an approach for such an issue.

like image 638
luck Avatar asked Jun 15 '12 07:06

luck


People also ask

How do you extract rules from the decision tree?

To extract rules from a decision tree, one rule is created for each path from the root to a leaf node. Each splitting criterion along a given path is logically ANDed to form the rule antecedent (“IF” part). The leaf node holds the class prediction, forming the rule consequent (“THEN” part).

How does Python decision tree work?

A decision tree is a flowchart-like tree structure where an internal node represents feature(or attribute), the branch represents a decision rule, and each leaf node represents the outcome. The topmost node in a decision tree is known as the root node. It learns to partition on the basis of the attribute value.

What are rules in a decision tree?

The Decision Tree algorithm, like Naive Bayes, is based on conditional probabilities. Unlike Naive Bayes, decision trees generate rules. A rule is a conditional statement that can easily be understood by humans and easily used within a database to identify a set of records.


1 Answers

DecisionTree is a pure-Python implementation for constructing a decision tree from multidimensional training data and subsequently using the decision tree to classify future data.

like image 137
shihongzhi Avatar answered Sep 28 '22 18:09

shihongzhi