Report 2
datatable(sample_dirty_dataset, options = list(scrollX = TRUE))
# Sprawdzenie typów danych każdej kolumny
str(sample_dirty_dataset)
## 'data.frame': 1000 obs. of 14 variables:
## $ age : chr "48" "68" "31" "84" ...
## $ workclass : chr "Local-gov" NA "State-gov" "Never-worked" ...
## $ education : chr "7th-8th" "Prof-school" "Bachelors" "7th-8th" ...
## $ education_num : int 1 1 2 10 16 12 11 13 10 12 ...
## $ marital_status: chr NA "Divorced" "Married-spouse-absent" "Separated" ...
## $ occupation : chr "Prof-specialty" "Priv-house-serv" "Protective-serv" "Handlers-cleaners" ...
## $ relationship : chr "Other-relative" "Unmarried" "Wife" "Other-relative" ...
## $ race : chr "Black" "Asian-Pac-Islander" "Black" "Asian-Pac-Islander" ...
## $ sex : chr "Male" "Female" "Male" "Male" ...
## $ capital_gain : num 7826 84532 35297 27074 73785 ...
## $ capital_loss : num 77249 60981 15093 40203 2056 ...
## $ hours_per_week: int 60 73 98 NA 4 70 15 96 40 11 ...
## $ native_country: chr "Poland" NA "Hungary" "South" ...
## $ income : chr ">50K" "<=50K" "<=50K" "<=50K" ...
# Identyfikacja brakujących wartości
sample_dirty_dataset %>%
summarise_all(~sum(is.na(.)))
## age workclass education education_num marital_status occupation relationship
## 1 0 50 0 0 50 0 50
## race sex capital_gain capital_loss hours_per_week native_country income
## 1 0 50 0 0 50 50 0
# Wyszukanie nieprawidłowych danych w kolumnie 'age'
sample_dirty_dataset %>%
mutate(age = as.character(age)) %>%
filter(!grepl("^[0-9]+$", age))
## age workclass education education_num
## 1 InvalidAge Federal-gov Some-college 11
## 2 InvalidAge Without-pay Some-college 10
## 3 InvalidAge State-gov Assoc-voc 9
## 4 InvalidAge State-gov Prof-school 14
## 5 InvalidAge Self-emp-inc HS-grad 16
## 6 InvalidAge Self-emp-inc 5th-6th 3
## 7 InvalidAge <NA> 7th-8th 8
## 8 InvalidAge Never-worked Masters 6
## 9 InvalidAge Self-emp-inc Masters 16
## 10 InvalidAge Local-gov 1st-4th 2
## 11 InvalidAge Local-gov Bachelors 6
## 12 InvalidAge Never-worked 12th 11
## 13 InvalidAge Never-worked Doctorate 8
## 14 InvalidAge Without-pay Bachelors 5
## 15 InvalidAge Private Assoc-voc 4
## 16 InvalidAge Self-emp-inc Prof-school 10
## 17 InvalidAge Self-emp-not-inc HS-grad 3
## 18 InvalidAge Self-emp-inc 10th 4
## 19 InvalidAge Self-emp-not-inc 5th-6th 13
## 20 InvalidAge Without-pay Preschool 6
## 21 InvalidAge <NA> Doctorate 8
## 22 InvalidAge Private Some-college 9
## 23 InvalidAge Without-pay Assoc-acdm 4
## 24 InvalidAge Self-emp-inc Preschool 16
## 25 InvalidAge Federal-gov 12th 8
## 26 InvalidAge Never-worked Assoc-voc 13
## 27 InvalidAge Private 10th 16
## 28 InvalidAge Federal-gov Assoc-acdm 4
## 29 InvalidAge Without-pay 9th 16
## 30 InvalidAge <NA> 9th 16
## 31 InvalidAge Private Prof-school 14
## 32 InvalidAge Without-pay 12th 11
## 33 InvalidAge Federal-gov Assoc-voc 2
## 34 InvalidAge Self-emp-not-inc InvalidEducation 1
## 35 InvalidAge Without-pay Bachelors 16
## 36 InvalidAge Self-emp-not-inc InvalidEducation 14
## 37 InvalidAge Never-worked Bachelors 7
## 38 InvalidAge State-gov 10th 15
## 39 InvalidAge Private Assoc-acdm 5
## 40 InvalidAge Self-emp-inc Bachelors 15
## 41 InvalidAge Self-emp-inc 12th 2
## 42 InvalidAge Federal-gov Doctorate 2
## 43 InvalidAge Local-gov 9th 11
## 44 InvalidAge Self-emp-inc Some-college 16
## 45 InvalidAge State-gov Assoc-acdm 8
## 46 InvalidAge Private Assoc-voc 14
## 47 InvalidAge Federal-gov HS-grad 11
## 48 InvalidAge Never-worked Assoc-acdm 11
## 49 InvalidAge Without-pay 10th 12
## 50 InvalidAge Without-pay 5th-6th 14
## marital_status occupation relationship race
## 1 Married-civ-spouse Machine-op-inspct Other-relative Black
## 2 Married-spouse-absent Machine-op-inspct Own-child Black
## 3 Divorced Prof-specialty Own-child Other
## 4 Married-AF-spouse Sales Wife InvalidRace
## 5 Married-civ-spouse Tech-support Own-child InvalidRace
## 6 Married-civ-spouse Craft-repair Husband Amer-Indian-Eskimo
## 7 Separated Machine-op-inspct Other-relative Black
## 8 Married-spouse-absent Tech-support Unmarried Amer-Indian-Eskimo
## 9 Married-AF-spouse Sales Not-in-family White
## 10 Divorced Priv-house-serv Own-child Amer-Indian-Eskimo
## 11 Divorced InvalidOccupation Not-in-family Amer-Indian-Eskimo
## 12 Married-spouse-absent Adm-clerical Wife Other
## 13 Married-civ-spouse Prof-specialty Wife Other
## 14 Separated Protective-serv Husband White
## 15 Married-civ-spouse Tech-support Wife Amer-Indian-Eskimo
## 16 Married-civ-spouse Craft-repair Husband Other
## 17 Married-spouse-absent Prof-specialty <NA> Asian-Pac-Islander
## 18 Married-spouse-absent Craft-repair Husband InvalidRace
## 19 Married-civ-spouse Craft-repair Husband Asian-Pac-Islander
## 20 <NA> Sales Not-in-family Asian-Pac-Islander
## 21 Married-AF-spouse Tech-support Unmarried Other
## 22 Divorced Handlers-cleaners Unmarried Amer-Indian-Eskimo
## 23 Widowed Adm-clerical Own-child Other
## 24 Divorced Prof-specialty Not-in-family White
## 25 Separated Sales Husband Amer-Indian-Eskimo
## 26 Married-spouse-absent Transport-moving Other-relative Black
## 27 Widowed Other-service Unmarried Asian-Pac-Islander
## 28 Divorced Prof-specialty <NA> Other
## 29 Widowed Armed-Forces Unmarried Amer-Indian-Eskimo
## 30 Widowed Priv-house-serv Wife Asian-Pac-Islander
## 31 Never-married Other-service Other-relative Other
## 32 Married-spouse-absent Sales Husband Black
## 33 <NA> Machine-op-inspct Unmarried Asian-Pac-Islander
## 34 Divorced Other-service Wife Black
## 35 Married-civ-spouse Tech-support Unmarried Amer-Indian-Eskimo
## 36 Divorced InvalidOccupation Other-relative White
## 37 Divorced Priv-house-serv Own-child Other
## 38 Divorced Farming-fishing Not-in-family Asian-Pac-Islander
## 39 Separated Tech-support Own-child Black
## 40 Separated Transport-moving Own-child Asian-Pac-Islander
## 41 Widowed Prof-specialty Wife Asian-Pac-Islander
## 42 Separated Craft-repair Own-child Amer-Indian-Eskimo
## 43 Widowed Transport-moving Wife White
## 44 Never-married Prof-specialty Wife Asian-Pac-Islander
## 45 Married-spouse-absent Protective-serv Other-relative InvalidRace
## 46 Divorced Prof-specialty Husband White
## 47 Never-married Exec-managerial Other-relative Amer-Indian-Eskimo
## 48 Never-married Prof-specialty Not-in-family White
## 49 Married-AF-spouse Adm-clerical Other-relative Other
## 50 Divorced Handlers-cleaners Unmarried Amer-Indian-Eskimo
## sex capital_gain capital_loss hours_per_week native_country income
## 1 Male 57895 -999 65 Japan <=50K
## 2 Female -999 16089 93 Philippines <=50K
## 3 Female 95584 19523 49 Cambodia <=50K
## 4 Female 37220 85579 90 Hong <=50K
## 5 Female 97122 75525 33 Jamaica <=50K
## 6 Female 52573 77834 25 Mexico >50K
## 7 Female 62359 63022 95 <NA> <=50K
## 8 Male 61884 49665 88 <NA> >50K
## 9 Male 2941 44283 62 Ireland <=50K
## 10 Male 83334 -999 96 Poland >50K
## 11 Male 82552 73585 42 Ecuador >50K
## 12 Female 16821 65989 74 China <=50K
## 13 Male 1256 90503 61 Taiwan >50K
## 14 Male 57537 96406 12 Hungary <=50K
## 15 Female 12504 16731 54 England >50K
## 16 Male 70055 56743 37 Cambodia <=50K
## 17 Female 2655 96130 23 South <=50K
## 18 Female 66254 4793 20 Jamaica <=50K
## 19 Male 2271 98942 47 Yugoslavia <=50K
## 20 Female 18151 -999 7 <NA> <=50K
## 21 Male 23126 98779 43 Germany <=50K
## 22 Male 24889 65768 6 Haiti <=50K
## 23 Female 51555 96846 76 Vietnam <=50K
## 24 Female -999 19444 51 Iran <=50K
## 25 Female 51520 37548 89 Philippines >50K
## 26 Female 56174 41088 50 France <=50K
## 27 Female 71040 91814 29 Italy <=50K
## 28 Female 89066 10507 13 Nicaragua <=50K
## 29 Female 24356 25577 92 Puerto-Rico <=50K
## 30 Female 6820 36114 15 Cuba <=50K
## 31 Female 38616 98707 18 South <=50K
## 32 Female 32368 64205 57 Hong <=50K
## 33 Male 2136 40701 63 Hungary >50K
## 34 Female 61317 97615 80 Laos <=50K
## 35 Female 29007 86570 NA Thailand >50K
## 36 Female 61253 27584 27 Ireland <=50K
## 37 Male 71879 90157 54 Guatemala <=50K
## 38 Male 92103 24469 83 United-States <=50K
## 39 Female 32494 92252 29 Haiti >50K
## 40 Female 13983 90703 8 Dominican-Republic <=50K
## 41 <NA> 9643 48742 48 Mexico >50K
## 42 Female 76187 42283 87 Puerto-Rico <=50K
## 43 Male 50548 -999 65 Yugoslavia <=50K
## 44 Male 34200 60049 51 Dominican-Republic <=50K
## 45 Male 37704 8745 58 Hong <=50K
## 46 Female 66644 42714 69 Cuba >50K
## 47 Male 85331 90265 20 Mexico <=50K
## 48 Female -999 3936 47 United-States <=50K
## 49 <NA> -999 -999 58 India <=50K
## 50 Female 29550 99089 55 Cambodia <=50K
# Wyszukanie niespójności w kolumnie 'education'
sample_dirty_dataset %>%
filter(education == "InvalidEducation")
## age workclass education education_num
## 1 67 Self-emp-not-inc InvalidEducation 12
## 2 44 Self-emp-inc InvalidEducation 3
## 3 81 Federal-gov InvalidEducation 12
## 4 87 Federal-gov InvalidEducation 4
## 5 59 Local-gov InvalidEducation 16
## 6 26 Without-pay InvalidEducation 4
## 7 43 Self-emp-not-inc InvalidEducation 15
## 8 43 Private InvalidEducation 12
## 9 43 Federal-gov InvalidEducation 14
## 10 42 Self-emp-inc InvalidEducation 10
## 11 40 Never-worked InvalidEducation 7
## 12 59 State-gov InvalidEducation 2
## 13 37 Federal-gov InvalidEducation 2
## 14 28 Self-emp-not-inc InvalidEducation 16
## 15 76 Self-emp-not-inc InvalidEducation 14
## 16 80 Without-pay InvalidEducation 3
## 17 72 Without-pay InvalidEducation 6
## 18 19 Federal-gov InvalidEducation 9
## 19 51 Local-gov InvalidEducation 10
## 20 75 Federal-gov InvalidEducation 4
## 21 34 Never-worked InvalidEducation 1
## 22 25 Local-gov InvalidEducation 4
## 23 36 Self-emp-not-inc InvalidEducation 12
## 24 78 State-gov InvalidEducation 5
## 25 86 Self-emp-not-inc InvalidEducation 11
## 26 78 Never-worked InvalidEducation 10
## 27 41 Without-pay InvalidEducation 8
## 28 38 Local-gov InvalidEducation 8
## 29 80 Private InvalidEducation 7
## 30 InvalidAge Self-emp-not-inc InvalidEducation 1
## 31 InvalidAge Self-emp-not-inc InvalidEducation 14
## 32 35 State-gov InvalidEducation 16
## 33 24 State-gov InvalidEducation 2
## 34 41 Federal-gov InvalidEducation 3
## 35 52 Self-emp-not-inc InvalidEducation 13
## 36 90 Self-emp-not-inc InvalidEducation 13
## 37 27 Local-gov InvalidEducation 3
## 38 66 Private InvalidEducation 2
## 39 63 Local-gov InvalidEducation 8
## 40 72 Never-worked InvalidEducation 3
## 41 85 Self-emp-not-inc InvalidEducation 11
## 42 56 Self-emp-inc InvalidEducation 14
## 43 58 Self-emp-inc InvalidEducation 1
## 44 20 Without-pay InvalidEducation 1
## 45 39 Never-worked InvalidEducation 2
## 46 28 Self-emp-inc InvalidEducation 14
## 47 34 Federal-gov InvalidEducation 7
## 48 29 State-gov InvalidEducation 13
## 49 59 Local-gov InvalidEducation 14
## 50 29 <NA> InvalidEducation 10
## marital_status occupation relationship race
## 1 Married-spouse-absent Adm-clerical Husband Black
## 2 Married-civ-spouse Craft-repair Unmarried Black
## 3 Widowed Sales Husband Black
## 4 Never-married Machine-op-inspct Other-relative Black
## 5 Married-civ-spouse Craft-repair Own-child Amer-Indian-Eskimo
## 6 Never-married Craft-repair Husband Other
## 7 Married-AF-spouse Exec-managerial Other-relative Black
## 8 Married-civ-spouse Other-service Unmarried Other
## 9 Married-spouse-absent Handlers-cleaners Other-relative Asian-Pac-Islander
## 10 Widowed Sales Own-child Other
## 11 Divorced Craft-repair Own-child White
## 12 Married-civ-spouse Tech-support Own-child Other
## 13 Married-AF-spouse Craft-repair Husband Other
## 14 Divorced InvalidOccupation Wife Other
## 15 <NA> Protective-serv Unmarried White
## 16 Separated Prof-specialty Not-in-family Black
## 17 Divorced Handlers-cleaners Own-child White
## 18 Separated Tech-support Husband Amer-Indian-Eskimo
## 19 Separated Priv-house-serv Unmarried Black
## 20 Widowed Exec-managerial Husband Black
## 21 Separated Farming-fishing Own-child Other
## 22 Married-AF-spouse Tech-support Own-child Asian-Pac-Islander
## 23 Separated Exec-managerial Other-relative Asian-Pac-Islander
## 24 Married-civ-spouse Armed-Forces Husband White
## 25 Never-married Priv-house-serv Own-child White
## 26 Widowed Machine-op-inspct Unmarried Amer-Indian-Eskimo
## 27 Married-AF-spouse Armed-Forces Husband Amer-Indian-Eskimo
## 28 Never-married Craft-repair Wife Amer-Indian-Eskimo
## 29 Married-spouse-absent Sales Not-in-family Asian-Pac-Islander
## 30 Divorced Other-service Wife Black
## 31 Divorced InvalidOccupation Other-relative White
## 32 Married-civ-spouse Machine-op-inspct Own-child Amer-Indian-Eskimo
## 33 Married-civ-spouse Exec-managerial Husband White
## 34 Married-civ-spouse Farming-fishing Other-relative Other
## 35 Separated Protective-serv Own-child Black
## 36 Separated Machine-op-inspct Husband Amer-Indian-Eskimo
## 37 Widowed Sales Not-in-family Black
## 38 Widowed Exec-managerial Husband Black
## 39 Married-civ-spouse Machine-op-inspct Not-in-family Asian-Pac-Islander
## 40 Never-married Transport-moving Other-relative InvalidRace
## 41 Widowed InvalidOccupation Unmarried Asian-Pac-Islander
## 42 Married-spouse-absent Protective-serv Other-relative Black
## 43 Divorced Craft-repair Wife Amer-Indian-Eskimo
## 44 Divorced Handlers-cleaners Other-relative Black
## 45 Widowed Transport-moving Husband Asian-Pac-Islander
## 46 Married-civ-spouse Tech-support Unmarried Other
## 47 Married-AF-spouse Adm-clerical Husband Amer-Indian-Eskimo
## 48 Widowed Other-service Not-in-family InvalidRace
## 49 Divorced Armed-Forces Other-relative Amer-Indian-Eskimo
## 50 Married-civ-spouse Prof-specialty Husband Other
## sex capital_gain capital_loss hours_per_week native_country income
## 1 Male 2553 17031 70 Scotland <=50K
## 2 <NA> 54179 88046 91 Puerto-Rico <=50K
## 3 Male 10331 70914 30 Honduras <=50K
## 4 Male 27357 58208 22 Cambodia >50K
## 5 Male 58431 11423 NA Scotland <=50K
## 6 Female 52925 25858 84 Haiti >50K
## 7 Male 30724 45090 70 Peru <=50K
## 8 Female -999 68931 NA Portugal <=50K
## 9 <NA> 8185 49701 82 England <=50K
## 10 Male 57350 53675 93 Vietnam <=50K
## 11 Male 16006 60420 45 Canada <=50K
## 12 Male 29771 82440 60 Germany <=50K
## 13 Male 54396 82558 61 Cuba >50K
## 14 Female 28324 56868 91 South <=50K
## 15 Female 872 79389 21 Columbia <=50K
## 16 Female 7717 14899 11 Philippines <=50K
## 17 Female 94877 47803 54 <NA> <=50K
## 18 Male 74881 -999 36 Yugoslavia <=50K
## 19 Male 8771 33660 81 Canada <=50K
## 20 Female 17355 -999 71 Canada <=50K
## 21 Female 39044 13221 64 Germany >50K
## 22 Male 72948 25995 88 Jamaica <=50K
## 23 Female 89983 8098 10 Taiwan >50K
## 24 Female 3428 56187 69 Greece >50K
## 25 Female 44637 53810 35 India <=50K
## 26 Male 40628 66745 92 Germany <=50K
## 27 Female 53024 15869 9 Italy <=50K
## 28 Male 60624 37313 73 Ireland >50K
## 29 Female 98660 56625 43 Taiwan <=50K
## 30 Female 61317 97615 80 Laos <=50K
## 31 Female 61253 27584 27 Ireland <=50K
## 32 Female 16384 87297 55 France <=50K
## 33 Female 33625 26034 7 Germany <=50K
## 34 Female 32625 62843 48 Trinadad&Tobago <=50K
## 35 Female 52832 82126 NA Jamaica <=50K
## 36 Female 19665 83105 86 Laos >50K
## 37 Female 22871 96240 36 Vietnam <=50K
## 38 Female 47607 43910 NA Poland <=50K
## 39 Male 81671 76204 37 Guatemala <=50K
## 40 Male 28583 -999 32 Ireland <=50K
## 41 Female 73768 23551 75 Vietnam <=50K
## 42 Female 42459 97379 81 Thailand <=50K
## 43 Male 81585 73428 41 China <=50K
## 44 Female 24361 79769 57 Columbia <=50K
## 45 Male 9275 69416 35 Laos <=50K
## 46 Male 80856 78121 3 El-Salvador <=50K
## 47 Male 18019 79241 72 Portugal <=50K
## 48 Female 18123 3200 36 France >50K
## 49 Male 86717 73621 52 Peru <=50K
## 50 Female 87663 58226 53 Canada >50K
# Identyfikacja rekordów z błędami w 'capital_gain' i 'capital_loss'
sample_dirty_dataset %>%
filter(capital_gain < 0 | capital_loss < 0)
## age workclass education education_num
## 1 42 Private Masters 2
## 2 InvalidAge Federal-gov Some-college 11
## 3 InvalidAge Without-pay Some-college 10
## 4 66 Private 11th 5
## 5 83 Never-worked Preschool 9
## 6 62 Private 11th 2
## 7 57 <NA> Preschool 11
## 8 89 Private Prof-school 8
## 9 50 Without-pay 5th-6th 15
## 10 24 Private Some-college 10
## 11 43 Private InvalidEducation 12
## 12 24 Never-worked 12th 4
## 13 48 Never-worked Prof-school 15
## 14 22 State-gov Doctorate 8
## 15 59 <NA> 1st-4th 2
## 16 54 Private Some-college 10
## 17 59 Private 10th 14
## 18 InvalidAge Local-gov 1st-4th 2
## 19 90 Federal-gov Preschool 5
## 20 59 Never-worked 7th-8th 6
## 21 80 State-gov Assoc-acdm 6
## 22 86 Without-pay 12th 7
## 23 67 Never-worked 7th-8th 12
## 24 67 Private 5th-6th 1
## 25 20 State-gov Masters 2
## 26 27 <NA> Prof-school 2
## 27 46 Self-emp-inc Doctorate 5
## 28 85 Self-emp-not-inc 11th 1
## 29 54 Without-pay Prof-school 16
## 30 63 Self-emp-inc 5th-6th 12
## 31 33 Self-emp-inc 5th-6th 16
## 32 78 Self-emp-not-inc 1st-4th 4
## 33 InvalidAge Without-pay Preschool 6
## 34 19 Federal-gov InvalidEducation 9
## 35 80 Local-gov Doctorate 13
## 36 76 Private 7th-8th 9
## 37 51 Self-emp-inc 10th 11
## 38 68 Local-gov Doctorate 9
## 39 65 Self-emp-not-inc Assoc-acdm 10
## 40 75 Federal-gov InvalidEducation 4
## 41 40 State-gov Assoc-voc 14
## 42 40 Federal-gov 9th 9
## 43 InvalidAge Self-emp-inc Preschool 16
## 44 70 Self-emp-not-inc 1st-4th 16
## 45 89 State-gov Preschool 15
## 46 58 Private 9th 16
## 47 88 Private 12th 2
## 48 70 Federal-gov Prof-school 16
## 49 18 State-gov Doctorate 14
## 50 82 Federal-gov Assoc-acdm 14
## 51 20 Local-gov HS-grad 1
## 52 56 Local-gov 1st-4th 1
## 53 87 Self-emp-inc Masters 15
## 54 21 Federal-gov Preschool 6
## 55 34 Never-worked 10th 14
## 56 36 State-gov 1st-4th 4
## 57 31 Never-worked Prof-school 16
## 58 90 Self-emp-inc 5th-6th 4
## 59 89 Without-pay Masters 1
## 60 20 Self-emp-not-inc 1st-4th 9
## 61 82 State-gov Preschool 12
## 62 81 Self-emp-not-inc Preschool 16
## 63 37 Federal-gov 9th 9
## 64 34 Federal-gov 1st-4th 13
## 65 61 Federal-gov 11th 16
## 66 52 Never-worked 9th 3
## 67 52 Never-worked 11th 6
## 68 75 <NA> Bachelors 1
## 69 63 Self-emp-inc Some-college 15
## 70 53 <NA> 11th 12
## 71 InvalidAge Local-gov 9th 11
## 72 33 Private Assoc-voc 12
## 73 22 Federal-gov Assoc-acdm 2
## 74 32 <NA> 10th 7
## 75 47 State-gov 9th 8
## 76 38 Self-emp-inc 5th-6th 7
## 77 72 Never-worked InvalidEducation 3
## 78 58 Self-emp-inc 9th 10
## 79 54 Federal-gov 5th-6th 14
## 80 89 Without-pay Preschool 16
## 81 82 Self-emp-inc Prof-school 14
## 82 48 Self-emp-inc Prof-school 14
## 83 77 Self-emp-not-inc Some-college 14
## 84 25 Private 10th 6
## 85 19 Without-pay HS-grad 14
## 86 69 Without-pay Assoc-acdm 16
## 87 InvalidAge Never-worked Assoc-acdm 11
## 88 77 Self-emp-inc Preschool 7
## 89 90 Federal-gov Prof-school 2
## 90 InvalidAge Without-pay 10th 12
## 91 19 Self-emp-inc 11th 1
## 92 23 Federal-gov Masters 7
## 93 72 Self-emp-not-inc Some-college 15
## 94 85 Self-emp-inc Bachelors 13
## 95 45 Never-worked HS-grad 9
## 96 77 Federal-gov Masters 4
## marital_status occupation relationship race
## 1 <NA> Protective-serv Own-child Other
## 2 Married-civ-spouse Machine-op-inspct Other-relative Black
## 3 Married-spouse-absent Machine-op-inspct Own-child Black
## 4 <NA> Other-service Wife Black
## 5 Widowed Tech-support Wife Amer-Indian-Eskimo
## 6 Divorced Farming-fishing Husband White
## 7 Widowed Craft-repair Wife White
## 8 Separated Other-service Husband Asian-Pac-Islander
## 9 Never-married Priv-house-serv Other-relative Other
## 10 Separated Adm-clerical Not-in-family Asian-Pac-Islander
## 11 Married-civ-spouse Other-service Unmarried Other
## 12 Divorced Exec-managerial Other-relative White
## 13 Separated Exec-managerial Not-in-family Black
## 14 Married-AF-spouse Farming-fishing Other-relative Amer-Indian-Eskimo
## 15 Widowed InvalidOccupation Not-in-family Amer-Indian-Eskimo
## 16 Widowed InvalidOccupation Other-relative Amer-Indian-Eskimo
## 17 Married-spouse-absent Exec-managerial Husband Amer-Indian-Eskimo
## 18 Divorced Priv-house-serv Own-child Amer-Indian-Eskimo
## 19 Married-civ-spouse Priv-house-serv Not-in-family White
## 20 <NA> Craft-repair Other-relative Amer-Indian-Eskimo
## 21 Married-spouse-absent Farming-fishing Own-child Asian-Pac-Islander
## 22 Married-civ-spouse Tech-support <NA> Other
## 23 Divorced Tech-support Other-relative White
## 24 Married-civ-spouse Machine-op-inspct Own-child Asian-Pac-Islander
## 25 Married-civ-spouse Transport-moving Unmarried Asian-Pac-Islander
## 26 Widowed Tech-support Not-in-family Black
## 27 Married-AF-spouse Sales Not-in-family Other
## 28 Never-married Transport-moving Not-in-family Other
## 29 Married-AF-spouse Tech-support Unmarried Black
## 30 Divorced Exec-managerial Wife Black
## 31 Separated Machine-op-inspct Not-in-family Asian-Pac-Islander
## 32 <NA> Other-service Husband Asian-Pac-Islander
## 33 <NA> Sales Not-in-family Asian-Pac-Islander
## 34 Separated Tech-support Husband Amer-Indian-Eskimo
## 35 Never-married Priv-house-serv Own-child Black
## 36 Married-AF-spouse Protective-serv Husband Black
## 37 Divorced Priv-house-serv Not-in-family Black
## 38 Divorced Machine-op-inspct <NA> White
## 39 Widowed Adm-clerical Not-in-family Amer-Indian-Eskimo
## 40 Widowed Exec-managerial Husband Black
## 41 Separated Sales Own-child Asian-Pac-Islander
## 42 Married-spouse-absent Handlers-cleaners Own-child Asian-Pac-Islander
## 43 Divorced Prof-specialty Not-in-family White
## 44 Divorced Armed-Forces Not-in-family Black
## 45 Married-civ-spouse Protective-serv Other-relative Asian-Pac-Islander
## 46 Married-spouse-absent Farming-fishing Other-relative White
## 47 <NA> Adm-clerical Unmarried Other
## 48 Married-civ-spouse Tech-support Own-child Amer-Indian-Eskimo
## 49 Married-AF-spouse Exec-managerial Own-child Asian-Pac-Islander
## 50 Separated Tech-support Not-in-family White
## 51 Widowed Armed-Forces Own-child White
## 52 Married-spouse-absent Tech-support Wife Other
## 53 Widowed Armed-Forces Not-in-family Amer-Indian-Eskimo
## 54 Divorced Transport-moving Unmarried Asian-Pac-Islander
## 55 Married-AF-spouse Machine-op-inspct Husband White
## 56 Separated Armed-Forces Wife Black
## 57 <NA> Farming-fishing Unmarried White
## 58 <NA> Farming-fishing Own-child Black
## 59 Never-married Machine-op-inspct Wife Black
## 60 Married-spouse-absent Tech-support Husband Asian-Pac-Islander
## 61 Widowed Farming-fishing Husband InvalidRace
## 62 Separated Transport-moving <NA> Black
## 63 Widowed Sales Husband White
## 64 Never-married Handlers-cleaners Not-in-family Black
## 65 Separated Transport-moving Not-in-family Asian-Pac-Islander
## 66 Married-civ-spouse Transport-moving Wife Asian-Pac-Islander
## 67 Married-civ-spouse Exec-managerial Not-in-family White
## 68 Married-spouse-absent Prof-specialty Other-relative Asian-Pac-Islander
## 69 Divorced Adm-clerical Own-child Black
## 70 Married-AF-spouse Protective-serv Wife Amer-Indian-Eskimo
## 71 Widowed Transport-moving Wife White
## 72 Divorced Farming-fishing Husband White
## 73 Never-married Priv-house-serv Not-in-family Black
## 74 Married-spouse-absent Handlers-cleaners Wife Amer-Indian-Eskimo
## 75 Married-spouse-absent Other-service Wife White
## 76 Separated Handlers-cleaners Own-child Amer-Indian-Eskimo
## 77 Never-married Transport-moving Other-relative InvalidRace
## 78 Separated Priv-house-serv Not-in-family Amer-Indian-Eskimo
## 79 Married-civ-spouse Tech-support Own-child Amer-Indian-Eskimo
## 80 Married-spouse-absent Handlers-cleaners Not-in-family Amer-Indian-Eskimo
## 81 Married-civ-spouse Prof-specialty Own-child Other
## 82 Married-civ-spouse Priv-house-serv Other-relative Amer-Indian-Eskimo
## 83 Never-married Tech-support <NA> Other
## 84 Divorced Exec-managerial Wife Other
## 85 Widowed Prof-specialty Husband White
## 86 Separated Machine-op-inspct Husband Other
## 87 Never-married Prof-specialty Not-in-family White
## 88 Divorced Armed-Forces <NA> Asian-Pac-Islander
## 89 Married-AF-spouse InvalidOccupation Wife InvalidRace
## 90 Married-AF-spouse Adm-clerical Other-relative Other
## 91 Never-married Craft-repair Husband Asian-Pac-Islander
## 92 Married-AF-spouse Adm-clerical Other-relative Amer-Indian-Eskimo
## 93 Divorced Machine-op-inspct Husband White
## 94 Never-married Machine-op-inspct Wife Asian-Pac-Islander
## 95 Separated Machine-op-inspct Not-in-family White
## 96 Widowed Transport-moving Unmarried Black
## sex capital_gain capital_loss hours_per_week native_country
## 1 Male -999 44813 6 El-Salvador
## 2 Male 57895 -999 65 Japan
## 3 Female -999 16089 93 Philippines
## 4 Male -999 60823 30 Canada
## 5 Male -999 56561 61 Laos
## 6 Female -999 80224 NA Haiti
## 7 Female 12005 -999 9 Thailand
## 8 Female 56485 -999 94 Hong
## 9 Male 3718 -999 35 Columbia
## 10 Female 6581 -999 16 Peru
## 11 Female -999 68931 NA Portugal
## 12 Male 11101 -999 76 Nicaragua
## 13 Female -999 50909 66 Portugal
## 14 Female 2557 -999 32 Germany
## 15 Male -999 77117 79 <NA>
## 16 Female -999 37285 39 Trinadad&Tobago
## 17 <NA> 53438 -999 5 Ireland
## 18 Male 83334 -999 96 Poland
## 19 Female 73618 -999 19 <NA>
## 20 Female 28005 -999 2 <NA>
## 21 Female 79776 -999 39 Hungary
## 22 Female 54951 -999 56 Peru
## 23 Male -999 15252 94 Columbia
## 24 Female -999 63141 51 Hungary
## 25 Male 40650 -999 11 Ecuador
## 26 Female -999 84905 13 Portugal
## 27 Male 41871 -999 76 Holand-Netherlands
## 28 Female 4065 -999 66 Outlying-US(Guam-USVI-etc)
## 29 Female -999 61394 74 Peru
## 30 Female 85791 -999 89 Hungary
## 31 Male 53346 -999 30 Japan
## 32 Female -999 25659 84 Honduras
## 33 Female 18151 -999 7 <NA>
## 34 Male 74881 -999 36 Yugoslavia
## 35 Male 60271 -999 NA Germany
## 36 Male 56489 -999 13 Jamaica
## 37 Male -999 74470 NA India
## 38 Female -999 83269 76 Cambodia
## 39 Male 45403 -999 45 Greece
## 40 Female 17355 -999 71 Canada
## 41 Female -999 7091 8 Germany
## 42 Male -999 83028 37 Canada
## 43 Female -999 19444 51 Iran
## 44 Male -999 99476 62 Hong
## 45 Female -999 39316 24 Cuba
## 46 Male -999 -999 59 Hong
## 47 <NA> -999 74147 56 <NA>
## 48 Male -999 17472 4 Jamaica
## 49 Male 36529 -999 14 United-States
## 50 Female -999 61476 94 China
## 51 Female -999 29222 49 <NA>
## 52 Female 30616 -999 63 Guatemala
## 53 Female -999 37919 52 India
## 54 Female 31607 -999 39 Italy
## 55 Male -999 69413 7 Dominican-Republic
## 56 Female -999 50518 62 <NA>
## 57 Male -999 66586 92 Poland
## 58 Female -999 26666 72 United-States
## 59 Female -999 54948 43 Guatemala
## 60 Male -999 42221 98 Ecuador
## 61 Female 50287 -999 69 Honduras
## 62 Female -999 -999 82 Vietnam
## 63 Male 12320 -999 19 France
## 64 Female 74645 -999 16 Japan
## 65 Male -999 14798 93 Portugal
## 66 <NA> 66955 -999 20 Hong
## 67 Female 64105 -999 51 Hungary
## 68 Male 4436 -999 16 Thailand
## 69 Female 72141 -999 74 England
## 70 <NA> -999 56786 41 Haiti
## 71 Male 50548 -999 65 Yugoslavia
## 72 <NA> -999 64956 35 Guatemala
## 73 Male 45506 -999 51 England
## 74 Female 67291 -999 26 Cambodia
## 75 Female 75689 -999 66 India
## 76 Male -999 93712 46 Taiwan
## 77 Male 28583 -999 32 Ireland
## 78 Female -999 80230 26 Hungary
## 79 Male 75288 -999 94 Holand-Netherlands
## 80 <NA> -999 60611 72 Peru
## 81 Male 23542 -999 78 Nicaragua
## 82 Female -999 40228 76 South
## 83 Female 6921 -999 13 Cambodia
## 84 Male 47295 -999 32 Hungary
## 85 Male 63253 -999 49 Hungary
## 86 Female -999 61462 32 <NA>
## 87 Female -999 3936 47 United-States
## 88 Male -999 20330 75 Greece
## 89 Female 55473 -999 52 Poland
## 90 <NA> -999 -999 58 India
## 91 Female -999 13643 87 <NA>
## 92 Male -999 63909 74 Poland
## 93 Female -999 63773 22 Jamaica
## 94 Male 5268 -999 85 Portugal
## 95 Male -999 7886 89 India
## 96 Female -999 -999 48 Trinadad&Tobago
## income
## 1 <=50K
## 2 <=50K
## 3 <=50K
## 4 <=50K
## 5 <=50K
## 6 <=50K
## 7 <=50K
## 8 <=50K
## 9 <=50K
## 10 <=50K
## 11 <=50K
## 12 >50K
## 13 >50K
## 14 >50K
## 15 <=50K
## 16 <=50K
## 17 >50K
## 18 >50K
## 19 <=50K
## 20 <=50K
## 21 <=50K
## 22 <=50K
## 23 >50K
## 24 <=50K
## 25 <=50K
## 26 <=50K
## 27 <=50K
## 28 <=50K
## 29 <=50K
## 30 <=50K
## 31 <=50K
## 32 <=50K
## 33 <=50K
## 34 <=50K
## 35 <=50K
## 36 <=50K
## 37 <=50K
## 38 <=50K
## 39 <=50K
## 40 <=50K
## 41 <=50K
## 42 <=50K
## 43 <=50K
## 44 >50K
## 45 >50K
## 46 <=50K
## 47 <=50K
## 48 <=50K
## 49 >50K
## 50 <=50K
## 51 <=50K
## 52 <=50K
## 53 <=50K
## 54 >50K
## 55 <=50K
## 56 <=50K
## 57 <=50K
## 58 <=50K
## 59 <=50K
## 60 >50K
## 61 <=50K
## 62 >50K
## 63 <=50K
## 64 <=50K
## 65 <=50K
## 66 <=50K
## 67 <=50K
## 68 <=50K
## 69 <=50K
## 70 <=50K
## 71 <=50K
## 72 <=50K
## 73 <=50K
## 74 <=50K
## 75 <=50K
## 76 >50K
## 77 <=50K
## 78 <=50K
## 79 <=50K
## 80 <=50K
## 81 >50K
## 82 <=50K
## 83 <=50K
## 84 >50K
## 85 <=50K
## 86 <=50K
## 87 <=50K
## 88 >50K
## 89 <=50K
## 90 <=50K
## 91 <=50K
## 92 >50K
## 93 <=50K
## 94 <=50K
## 95 <=50K
## 96 <=50K
# Sprawdzenie unikalnych wartości dla kolumn kategorycznych, aby znaleźć nieprawidłowości
sample_dirty_dataset %>%
select(workclass, education, marital_status, occupation, relationship, race, sex, native_country, income) %>%
map(~unique(.))
## $workclass
## [1] "Local-gov" NA "State-gov" "Never-worked"
## [5] "Private" "Self-emp-not-inc" "Federal-gov" "Self-emp-inc"
## [9] "Without-pay"
##
## $education
## [1] "7th-8th" "Prof-school" "Bachelors" "12th"
## [5] "InvalidEducation" "5th-6th" "10th" "Masters"
## [9] "Preschool" "Doctorate" "1st-4th" "Assoc-voc"
## [13] "9th" "11th" "Some-college" "HS-grad"
## [17] "Assoc-acdm"
##
## $marital_status
## [1] NA "Divorced" "Married-spouse-absent"
## [4] "Separated" "Married-civ-spouse" "Married-AF-spouse"
## [7] "Widowed" "Never-married"
##
## $occupation
## [1] "Prof-specialty" "Priv-house-serv" "Protective-serv"
## [4] "Handlers-cleaners" "Machine-op-inspct" "Adm-clerical"
## [7] "InvalidOccupation" "Tech-support" "Exec-managerial"
## [10] "Craft-repair" "Sales" "Farming-fishing"
## [13] "Armed-Forces" "Transport-moving" "Other-service"
##
## $relationship
## [1] "Other-relative" "Unmarried" "Wife" "Husband"
## [5] "Not-in-family" "Own-child" NA
##
## $race
## [1] "Black" "Asian-Pac-Islander" "White"
## [4] "Other" "Amer-Indian-Eskimo" "InvalidRace"
##
## $sex
## [1] "Male" "Female" NA
##
## $native_country
## [1] "Poland" NA
## [3] "Hungary" "South"
## [5] "Haiti" "Scotland"
## [7] "Cambodia" "Philippines"
## [9] "Honduras" "Thailand"
## [11] "Holand-Netherlands" "United-States"
## [13] "El-Salvador" "Italy"
## [15] "Nicaragua" "Jamaica"
## [17] "Mexico" "Greece"
## [19] "Hong" "China"
## [21] "Taiwan" "Yugoslavia"
## [23] "Puerto-Rico" "India"
## [25] "Japan" "Vietnam"
## [27] "Laos" "Ecuador"
## [29] "Ireland" "Canada"
## [31] "Columbia" "Guatemala"
## [33] "Peru" "France"
## [35] "Iran" "Germany"
## [37] "Cuba" "Trinadad&Tobago"
## [39] "Dominican-Republic" "England"
## [41] "Portugal" "Outlying-US(Guam-USVI-etc)"
##
## $income
## [1] ">50K" "<=50K"