title: “Iris Flower Species Predictor” author: “a” output: ioslides_presentation: widescreen: true 1. Introduction Iris Flower Species Predictor
An interactive web application built using R and Shiny.
Predicts iris flower species from four measurements. Uses the built-in R iris dataset. Displays the predicted species and a distance comparison plot. 2. Problem and Purpose
The iris dataset contains measurements for three flower species:
Setosa Versicolor Virginica
The purpose of this application is to help users explore how flower measurements can be used to classify a flower species.
No advanced statistical knowledge is required to use the application.
Enter these four measurements in the Shiny interface:
Sepal length Sepal width Petal length Petal width
Click the Predict button.
The application compares the measurements with the average measurements of each species and displays the predicted species.
The application uses a nearest-centroid classification method.
data(iris)
features <- names(iris)[1:4]
centers <- aggregate( . ~ Species, data = iris, FUN = mean )
scales <- sapply(iris[features], sd)
new_flower <- c(5.1, 3.5, 1.4, 0.2)
distances <- sapply(seq_len(nrow(centers)), function(i) { center <- as.numeric(centers[i, features])
sqrt(sum( ((new_flower - center) / scales)^2 )) })
results <- data.frame( Species = centers$Species, Distance = round(distances, 3) )
print(results)
cat( “Predicted species:”, as.character(centers$Species[which.min(distances)]) )
The flower is assigned to the species with the smallest standardized distance from its average measurements.
The Iris Flower Predictor demonstrates how R and Shiny can make classification accessible through an interactive web application.
Key features:
Four numeric inputs Automatic species prediction A plot comparing distances to species averages