WineQT <- read.csv(“WineQT.csv”) # Display the first few rows of the dataset head(WineQT) # Display the structure of the dataset str(WineQT) # Display the summary of the dataset summary(WineQT) # Display the number of rows and columns in the dataset dim(WineQT) # Display the column names of the dataset colnames(WineQT) plot(WineQT\(alcohol, WineQT\)quality, main = ‘Regression for Alcohol on Quality’, xlab = ‘Alcohol’, ylab = ‘Quality’) # Display the correlation between alcohol and quality cor(WineQT\(alcohol, WineQT\)quality) abline(lm(quality ~ alcohol, data = WineQT), col = ‘red’) # Display the correltion matrix for all variables cor(WineQT) # Build a logistic regression model to predict quality using all variables logistic_model <- glm(quality ~ ., data = WineQT) # Display the summary of the logistic regression model summary(logistic_model) # Display the coefficients of the logistic regression model coef(logistic_model) # Display the odds ratios of the coefficients exp(coef(logistic_model)) # Display the predicted probabilities of the logistic regression model predicted_probabilities <- predict(logistic_model, type = “response”) # Display the first few predicted probabilities head(predicted_probabilities) # Display the predicted classes based on a threshold of 0.5 predicted_classes <- ifelse(predicted_probabilities > 0.5, 1, 0) # Display the first few predicted classes head(predicted_classes) # Display the confusion matrix confusion_matrix <- table(WineQT$quality, predicted_classes) # Display the confusion matrix confusion_matrix # Calculate the accuracy of the model accuracy <- sum(diag(confusion_matrix)) / sum(confusion_matrix) # Display the accuracy accuracy # Load the required libraries library(caret) library(ggplot2) library(dplyr)