This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(modelr)
bike_data <- read_csv('C:/Users/ADMIN/Documents/data set/db1bike.csv')
## Rows: 199 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): Date, Seasons, Holiday, Functioning Day
## dbl (10): Rented_Bike_Count, Hour, Temperature, Humidity, Wind_speed, Visibi...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
glimpse(bike_data)
## Rows: 199
## Columns: 14
## $ Date <chr> "01-12-2017", "01-12-2017", "01-12-2017", "01-…
## $ Rented_Bike_Count <dbl> 254, 204, 173, 107, 78, 100, 181, 460, 930, 49…
## $ Hour <dbl> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, …
## $ Temperature <dbl> -5.2, -5.5, -6.0, -6.2, -6.0, -6.4, -6.6, -7.4…
## $ Humidity <dbl> 37, 38, 39, 40, 36, 37, 35, 38, 37, 27, 24, 21…
## $ Wind_speed <dbl> 2.2, 0.8, 1.0, 0.9, 2.3, 1.5, 1.3, 0.9, 1.1, 0…
## $ Visibility <dbl> 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000…
## $ `Dew point temperature` <dbl> -17.6, -17.6, -17.7, -17.6, -18.6, -18.7, -19.…
## $ `Solar Radiation` <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00…
## $ Rainfall <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Snowfall <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Seasons <chr> "Winter", "Winter", "Winter", "Winter", "Winte…
## $ Holiday <chr> "No Holiday", "No Holiday", "No Holiday", "No …
## $ `Functioning Day` <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes…
bike_data <- bike_data %>%
mutate(HighDemand = if_else(Rented_Bike_Count > median(Rented_Bike_Count), 1, 0))
bikes_logit <- glm(HighDemand ~ Temperature + Humidity + Wind_speed,
data = bike_data, family = "binomial")
summary(bikes_logit)
##
## Call:
## glm(formula = HighDemand ~ Temperature + Humidity + Wind_speed,
## family = "binomial", data = bike_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 3.414948 0.740193 4.614 3.96e-06 ***
## Temperature 0.271873 0.051551 5.274 1.34e-07 ***
## Humidity -0.055154 0.009846 -5.601 2.13e-08 ***
## Wind_speed -0.042782 0.150449 -0.284 0.776
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 275.87 on 198 degrees of freedom
## Residual deviance: 217.36 on 195 degrees of freedom
## AIC: 225.36
##
## Number of Fisher Scoring iterations: 4
ggplot(bike_data, aes(Temperature, Rented_Bike_Count)) +
geom_point()
ggplot(bike_data, aes(Humidity, Rented_Bike_Count)) +
geom_point()
ggplot(bike_data, aes(Wind_speed, Rented_Bike_Count)) +
geom_point()