2026-11-05

The idea

Identify an iris from four measurements

  • The app accepts sepal length and width, plus petal length and width.
  • A classification decision tree predicts Setosa, Versicolor, or Virginica.
  • The goal is a small, understandable demonstration of interactive data science.

Why iris? R includes the classic 150-row iris dataset, so users do not need to upload data or configure a data source.

The user experience

Simple inputs, immediate feedback

  1. Move four sliders to enter measurements in centimetres.
  2. The app sends those values to the server.
  3. The server calculates a prediction and class probabilities.
  4. The result and probability chart update automatically.

The How to use tab inside the app explains the controls, dataset and limitations for first-time users.

How the prediction works

A reproducible classification tree

The app trains an rpart decision tree on the built-in data. The same core steps are reproduced below.

library(rpart)

iris_tree <- rpart(
  Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
  data = iris,
  method = "class",
  control = rpart.control(cp = 0.01, minsplit = 10)
)

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

predict(iris_tree, newdata = example_flower, type = "class")
##      1 
## setosa 
## Levels: setosa versicolor virginica

The code chunk is evaluated when the presentation is knitted, making the displayed example reproducible.

Value and next steps

A compact, accessible data-science project

  • Interactive: users can experiment with measurements.
  • Reactive: the prediction and probability chart refresh when inputs change.
  • Reproducible: the app uses a built-in dataset and documented R code.
  • Transparent: the app explains the model and its educational limitations.

Try the app: paste your deployed shinyapps.io URL here.

Source code: paste your GitHub repository URL here.

This is an educational prediction tool; its estimated probabilities are not guarantees of correctness.