README.md

jofou.lib

The goal of jofou.lib is to regroup all the functions that are useful for me to work efficiently.

Installation

You can install the lastest version of jofou.lib with:

devtools::install_github("jofou/jofou.lib")

EDA Functions

Example

This are basics examples which shows you how use the my_inspect group function:

library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_cat()
Resume et comparaison des variables categoriques Nom de la variable Nombre Commun pourcentage Species 3 setosa 33
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_cor()
Coeficient de correlation pour toutes les variables numeriques Variable 1 Variable 2 Correlation Valeur P N-NA (%) Petal.Width Petal.Length 0.96 0.000 100 Petal.Length Sepal.Length 0.87 0.000 100 Petal.Width Sepal.Length 0.82 0.000 100 Petal.Length Sepal.Width -0.43 0.000 100 Petal.Width Sepal.Width -0.37 0.000 100 Sepal.Width Sepal.Length -0.12 0.154 100
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_imb()
Resume des categories les plus utilisees Nom de la variable Categorie Pourcentage Nombre Species setosa 33 50
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_na()
Nombre de valeur manquante pour chaque variable Nom de la variable NA Pourcentage Sepal.Length 0 0 Sepal.Width 0 0 Petal.Length 0 0 Petal.Width 0 0 Species 0 0
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_num()
Resume et comparaison des variables numeriques Nom de la variable min q1 median moyenne q3 max sd NA (%) Sepal.Length 4 5 6 6 6 8 1 0 Sepal.Width 2 3 3 3 3 4 0 0 Petal.Length 1 2 4 4 5 7 2 0 Petal.Width 0 0 1 1 2 2 1 0
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_inspect_types()
Types de variables disponibles Type Nombre Pourcentage Nom des variables numeric 4 80 Sepal.Length, Sepal.Width , Petal.Length, Petal.Width factor 1 20 Species

I also have a couples of other functions to show distributions of numeric and categorical variables:

library(tidyverse)
library(jofou.lib)

iris %>% 
  my_num_dist()

library(tidyverse)
library(jofou.lib)

iris %>% 
  my_corr_num_graph()

#> NULL
library(tidyverse)
library(jofou.lib)

iris %>% 
  my_cat_dist()

Utilities Functions

Example

These are basic examples that show you how to use my utilities functions:

library(tidyverse)
library(jofou.lib)

iris %>%
  mutate(cat_Sepal.Length=round(Sepal.Length, digits = 0)) %>%
  group_by(cat_Sepal.Length) %>%
  summarise(mode_species=calculate_mode(Species))
#> # A tibble: 5 x 2
#>   cat_Sepal.Length mode_species
#> *            <dbl> <fct>       
#> 1                4 setosa      
#> 2                5 setosa      
#> 3                6 versicolor  
#> 4                7 virginica   
#> 5                8 virginica
library(tidyverse)
library(jofou.lib)

iris %>%
  filter(Species %ni% "setosa") %>%
  group_by(Species) %>%
  summarise(nb=dplyr::n())
#> # A tibble: 2 x 2
#>   Species       nb
#> * <fct>      <int>
#> 1 versicolor    50
#> 2 virginica     50

ML Functions

Example

These are basic examples that show you how to use my machine learning utilities functions:

library(tidyverse)
library(lubridate)
library(timetk)
library(parsnip)
library(rsample)
library(modeltime)

# Data
data_prepared_tbl <- m4_monthly %>% filter(id == "M750")

# Split Data 80/20
splits <- initial_time_split(data_prepared_tbl, prop = 0.9)

# Model: auto_arima
model_fit_arima <- arima_reg() %>%
   set_engine(engine = "auto_arima") %>%
   fit(value ~ date, data = training(splits))

# Calibrate and plot
calibrate_and_plot(model_fit_arima, type="testing")
#> # A tibble: 1 x 9
#>   .model_id .model_desc             .type   mae  mape  mase smape  rmse   rsq
#>       <int> <chr>                   <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1         1 ARIMA(0,1,1)(0,1,1)[12] Test   151.  1.41 0.516  1.43  198. 0.930



Jofou/jofou.lib documentation built on May 22, 2022, 11:42 a.m.