Professional Documents
Culture Documents
How can you convert a Decision Trees into "if-then-else rules". Make up your own small Decision Tree
consisting of 2-3 levels and convert it into a set of rules. There also exist different classifiers that output
the model in the form of rules - one such classifier in Weka is rules. PART, train this model and report the
set of rules obtained. Sometimes just one attribute can be good enough in making the decision, yes, just
one ! Can you predict what attribute that might be in this dataset? OneR classifier uses a single attribute
to make decisions (it chooses the attribute based on minimum error). Report the rule obtained by
training a one R classifier. Rank the performance of j48, PART and oneR.
AIM :
The aim of this experiment is to convert a decision tree model into "if-then-else" rules and compare
them with the rules generated by the PART algorithm. Additionally, the One R classifier will be assessed
for its performance in credit assessment.
Description :
- Decision trees are powerful models for classification tasks, but their structure can be complex and
difficult to interpret. Converting a decision tree into a set of "if-then-else" rules provides a more intuitive
representation of the decision-making process.
- The "if-then-else" rules are derived from the decision tree's structure, where each rule corresponds to
a path from the root node to a leaf node. These rules capture the conditions under which a particular
class label is assigned to an instance.
2. PART Algorithm:
- The PART algorithm is a rule-based classifier that generates rules directly from the dataset without
constructing a decision tree. It employs a separate-and-conquer approach to induce rules by repeatedly
identifying and removing the most significant attribute-value pair.
- By comparing the rules generated by the decision tree model with those produced by the PART
algorithm, we can evaluate the effectiveness of both approaches in capturing the underlying patterns in
the data and producing interpretable classification rules.
3. One R Classifier:
- The One R classifier, also known as the "One Rule" classifier, is a simple and interpretable rule-based
classifier that selects a single attribute as the basis for classification.
- Unlike decision trees, which consider multiple attributes simultaneously, the One R classifier
generates rules based on a single attribute that maximizes classification accuracy.
- Assessing the performance of the One R classifier provides insights into the trade-offs between
simplicity and accuracy in rule-based classification models.
Procedure:
1. Load the credit-g.arff file containing the credit assessment dataset intoWeka.
2. Select all attributes from the dataset to ensure that the decision tree model considers the full range of
available features during training.
3. Navigate to the classification tab and click on the "Classify" button to initiate the classification process.
4. Click on the "Choose" button to select the algorithm for building the decision tree model. Select J48
algorithm, which represents the decision tree algorithm.
5. Configure the cross-validation setup by specifying the number of folds. In this experiment, set the
number of folds to 2.
Output:
Relation: german_credit
Instances: 1000
Attributes: 21
checking_status
duration
credit_history
purpose
credit_amount
savings_status
employment
installment_commitment
personal_status
other_parties
residence_since
property_magnitude
age
other_payment_plans
housing
existing_credits
job
num_dependents
own_telephone
foreign_worker
class
------------------
checking_status = <0
| foreign_worker = yes
| | duration <= 11
| | | existing_credits <= 1
| | duration > 11
| | | | purpose = furniture/equipment
| | | | purpose = radio/tv
| | | job = skilled
| | | | other_parties = none
| | | | | duration <= 30
| | | | | | savings_status = <100
| | | | | | | | own_telephone = none
| | | | | | | | | existing_credits <= 1
| | | | | | | | | | property_magnitude = real estate
| | | | | | | | | | property_magnitude = car
| | | | | | savings_status = 100<=X<500
| | | | | | | existing_credits <= 1
checking_status = 0<=X<200
| | savings_status = <100
| | | other_parties = none
| | | | duration <= 42
| | | | | | purpose = furniture/equipment
| | | | | | | duration > 10
| | | | | | purpose = business
| | | other_parties = guarantor
| | savings_status = 100<=X<500
| | | purpose = business
| | | | housing = rent
1. Load the credit-g.arff file containing the credit assessment dataset intoWeka.
2. Select all attributes from the dataset to ensure that the PART considers the full range of available
features during training.
3. Navigate to the classification tab and click on the "Classify" button to initiate the classification process.
4. Click on the "Choose" button to select the algorithm for building the
5. Configure the cross-validation setup by specifying the number of folds. In this experiment, set the
number of folds to 2.
Relation: german_credit
Instances: 1000
Attributes: 21
checking_status
duration
credit_history
purpose
credit_amount
savings_status
employment
installment_commitment
personal_status
other_parties
residence_since
property_magnitude
age
other_payment_plans
housing
existing_credits
job
num_dependents
own_telephone
foreign_worker
class
------------------
foreign_worker = no AND
personal_status = male single: good (21.0)
: bad (5.0)
Number of Rules : 78
ONE R ALGORITHM :
1. Load the credit-g.arff file containing the credit assessment dataset intoWeka.
2. Select all attributes from the dataset to ensure that the ONE R considers the full range of available
features during training.
3. Navigate to the classification tab and click on the "Classify" button to initiate the classification process.
4. Click on the "Choose" button to select the algorithm for building the
5. Configure the cross-validation setup by specifying the number of folds. In this experiment, set the
number of folds to 2.
Scheme: weka.classifiers.rules.OneR -B 6
Relation: german_credit
Instances: 1000
Attributes: 21
checking_status
duration
credit_history
purpose
credit_amount
savings_status
employment
installment_commitment
personal_status
other_parties
residence_since
property_magnitude
age
other_payment_plans
housing
existing_credits
job
num_dependents
own_telephone
foreign_worker
class
credit_amount:
Result :
Hence, We successfully completed for a set of rules for Descision tree, PART and ONE R with a
comparsion of their Performance.