0% found this document useful (0 votes)
24 views2 pages

Ishika - BI Lab - Exp 8

d

Uploaded by

OK BOSS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Ishika - BI Lab - Exp 8

d

Uploaded by

OK BOSS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment: 3.

Aim: Implementation of Classification algorithm in R Programming using Decision tree.


Software Required: RStudio
Description: A decision tree is a flowchart-like tree structure where each internal node denotes the
feature, branches denote the rules and the leaf nodes denote the result of the algorithm. It is a
versatile supervised machine-learning algorithm, which is used for both classification and
regression problems. It is one of the very powerful algorithms. And it is also used in Random Forest
to train on different subsets of training data, which makes random forest one of the most powerful
algorithms in machine learning.
Relevance of the Experiment: The experiment is relevant in the context of Business Intelligence
(BI) as it focuses on the implementation of classification algorithms using R programming.
Classification algorithms are essential tools in BI for analyzing and predicting categorical outcomes
based on historical data. Understanding how to implement classification algorithms in R enables BI
professionals to build predictive models, classify data, and make data-driven decisions in various
business scenarios.

Implementation:
# Install and load the necessary package

library(rpart)

# Load the Iris dataset (a built-in dataset in R)

data(iris)

# Create a decision tree classifier

decision_tree <- rpart(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = iris, method = "class")

# Print the decision tree

print(decision_tree)

Name: Ishika UID: 20BCS9499


# Make predictions on new data

new_data <- data.frame(Sepal.Length = 5.1, Sepal.Width = 3.5, Petal.Length = 1.4, Petal.Width = 0.2)

prediction <- predict(decision_tree, new_data, type = "class")

# Print the prediction

cat("Predicted Species:", prediction, "\n")

Output:

Fig 1: Decision Tree

Fig 2: Prediction on new data

Name: Ishika UID: 20BCS9499

You might also like