categ_analysis: Profiling analysis of categorical vs. target variable

Description Usage Arguments Value Examples

View source: R/target_profiling.R

Description

Retrieves a complete summary of the grouped input variable against the target variable. Type of target variable must be binary for now. A positive case will be the less representative one. It returns the total positive cases (sum_target)); pecentage of total positive cases (perc_target) that fell in that category (this column sums 1); likelihood or mean of positive cases (mean_target) measured by the total positive cases over total cases in that category; quantity of rows of that category (q_rows) and in percentage (perc_rows) -this column sums 1.

Usage

1
categ_analysis(data, input, target)

Arguments

data

input data containing the variable to describe

input

string input variable (if empty, it runs for all categorical variable), it can take a single character value or a character vector.

target

string target variable. Binary or two class is only supported by now.

Value

if input has 1 variable, it retrurns a data frame indicating all the metrics, otherwise prints in console all variable results.

Examples

1
categ_analysis(data_country, "country", "has_flu")

Example output

Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, round.POSIXt, trunc.POSIXt, units

sh: 1: cannot create /dev/null: Permission denied
funModeling v.1.6.5 :)
Examples and tutorials at livebook.datascienceheroes.com

                     country mean_target sum_target perc_target q_rows
1                   Malaysia       1.000          1       0.012      1
2                     Mexico       0.667          2       0.024      3
3                   Portugal       0.200          1       0.012      5
4             United Kingdom       0.178          8       0.096     45
5                    Uruguay       0.175         11       0.133     63
6                     Israel       0.167          1       0.012      6
7                Switzerland       0.167          1       0.012      6
8                     Canada       0.158          3       0.036     19
9                     France       0.142         41       0.494    288
10                 Argentina       0.111          1       0.012      9
11                   Germany       0.100          3       0.036     30
12                 Australia       0.098          4       0.048     41
13                   Romania       0.091          1       0.012     11
14                     Spain       0.091          1       0.012     11
15                    Sweden       0.083          1       0.012     12
16               Netherlands       0.053          1       0.012     19
17                    Turkey       0.030          2       0.024     67
18       Asia/Pacific Region       0.000          0       0.000      1
19                   Austria       0.000          0       0.000      1
20                Bangladesh       0.000          0       0.000      3
21                   Belgium       0.000          0       0.000     15
22    Bosnia and Herzegovina       0.000          0       0.000      1
23                    Brazil       0.000          0       0.000     13
24                  Bulgaria       0.000          0       0.000      9
25                  Cambodia       0.000          0       0.000      3
26                     Chile       0.000          0       0.000      2
27                     China       0.000          0       0.000     65
28                Costa Rica       0.000          0       0.000      2
29                   Croatia       0.000          0       0.000      2
30                    Cyprus       0.000          0       0.000      1
31            Czech Republic       0.000          0       0.000      1
32                   Denmark       0.000          0       0.000      6
33        Dominican Republic       0.000          0       0.000      1
34                     Egypt       0.000          0       0.000      2
35                   Finland       0.000          0       0.000      4
36                     Ghana       0.000          0       0.000      1
37                    Greece       0.000          0       0.000      1
38                  Honduras       0.000          0       0.000      4
39                 Hong Kong       0.000          0       0.000      9
40                 Indonesia       0.000          0       0.000      6
41 Iran, Islamic Republic of       0.000          0       0.000      1
42                   Ireland       0.000          0       0.000      1
43               Isle of Man       0.000          0       0.000      1
44                     Italy       0.000          0       0.000     10
45                     Japan       0.000          0       0.000     18
46        Korea, Republic of       0.000          0       0.000      4
47                    Latvia       0.000          0       0.000      1
48                 Lithuania       0.000          0       0.000      1
49                Luxembourg       0.000          0       0.000      1
50                     Malta       0.000          0       0.000      2
51      Moldova, Republic of       0.000          0       0.000      1
52                Montenegro       0.000          0       0.000      1
53                   Morocco       0.000          0       0.000      5
54               New Zealand       0.000          0       0.000      4
55                    Norway       0.000          0       0.000      6
56                  Pakistan       0.000          0       0.000      3
57     Palestinian Territory       0.000          0       0.000      1
58                      Peru       0.000          0       0.000      2
59               Philippines       0.000          0       0.000      7
60                    Poland       0.000          0       0.000     13
61        Russian Federation       0.000          0       0.000      5
62              Saudi Arabia       0.000          0       0.000      3
63                   Senegal       0.000          0       0.000      1
64                 Singapore       0.000          0       0.000      8
65                  Slovenia       0.000          0       0.000      1
66              South Africa       0.000          0       0.000      8
67                    Taiwan       0.000          0       0.000      3
68                  Thailand       0.000          0       0.000      2
69                   Ukraine       0.000          0       0.000      6
70                   Vietnam       0.000          0       0.000      1
   perc_rows
1      0.001
2      0.003
3      0.005
4      0.049
5      0.069
6      0.007
7      0.007
8      0.021
9      0.316
10     0.010
11     0.033
12     0.045
13     0.012
14     0.012
15     0.013
16     0.021
17     0.074
18     0.001
19     0.001
20     0.003
21     0.016
22     0.001
23     0.014
24     0.010
25     0.003
26     0.002
27     0.071
28     0.002
29     0.002
30     0.001
31     0.001
32     0.007
33     0.001
34     0.002
35     0.004
36     0.001
37     0.001
38     0.004
39     0.010
40     0.007
41     0.001
42     0.001
43     0.001
44     0.011
45     0.020
46     0.004
47     0.001
48     0.001
49     0.001
50     0.002
51     0.001
52     0.001
53     0.005
54     0.004
55     0.007
56     0.003
57     0.001
58     0.002
59     0.008
60     0.014
61     0.005
62     0.003
63     0.001
64     0.009
65     0.001
66     0.009
67     0.003
68     0.002
69     0.007
70     0.001

funModeling documentation built on July 1, 2020, 5:40 p.m.