This Shiny application predicts whether a plane can fly based on weather conditions. The prediction is made using the SVM model trained on a dataset of historical weather data and flight outcomes.
Before running the application, ensure you have the following R packages installed:
shinye1071shinythemes
To install these packages, run:
install.packages(c("shiny", "e1071", "shinythemes"))The dataset used in this application includes the following features:
outlook: Weather outlook (Sunny, Overcast, Rainy)temperature: Temperature in Fahrenheithumidity: Humidity percentagewindy: Whether it is windy (TRUE or FALSE)fly: Whether the plane can fly (yes or no)
The dataset is hardcoded within the app and consists of 14 samples.
- Open RStudio or any R environment.
- Ensure all necessary packages are installed.
- Copy the entire code into an R script file (e.g.,
app.R). - Run the script. The Shiny application will launch in your default web browser.
- Outlook: Select the weather outlook (Sunny, Overcast, Rainy).
- Temperature: Use the slider to select the temperature (64°F to 86°F).
- Humidity: Use the slider to select the humidity (65% to 96%).
- Windy: Select whether it is windy (Yes or No).
- Submit Button: Click to submit the input values and get the prediction.
- Status/Output Text Box: Displays the status of the calculation.
- Prediction Results Table: Displays the prediction result (yes or no) indicating whether the plane can fly under the given conditions.
The application builds the SVM model using the e1071 package to predict the flight status. The model is trained on the provided dataset and used to make predictions based on user input.
- UI: Defined in the
uivariable usingfluidPage. It includes input fields, a submit button, and output areas. - Server: Defined in the
serverfunction. It handles the logic for reading inputs, building the model, making predictions, and displaying the results. - Shiny App: The
shinyAppfunction combines the UI and server components to create the Shiny application.
For debugging purposes, the input data is printed to the console before making predictions. This can help ensure that the input values are correctly captured and processed.
- Select "Sunny" for outlook.
- Set the temperature to 70°F.
- Set the humidity to 90%.
- Select "Yes" for windy.
- Click "Submit".
- The prediction result will be displayed in the "Prediction results table".
This Shiny application provides an interactive interface to predict whether a plane can fly based on weather conditions using a machine learning model. It demonstrates the use of Shiny for building web applications in R and the SVM application for classification tasks.
You may reach me through: Email: kassimchambulilo@gmail.com phone: +255 613 048 665