Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
age
int64
17
90
workclass
class label
9 classes
fnlwgt
int64
12.3k
1.48M
education
class label
16 classes
education-num
int64
1
16
marital-status
class label
7 classes
occupation
class label
15 classes
relationship
class label
6 classes
race
class label
5 classes
sex
class label
2 classes
capital-gain
int64
0
100k
capital-loss
int64
0
4.36k
hours-per-week
int64
1
99
native-country
class label
42 classes
income
class label
2 classes
39
7State-gov
77,516
9Bachelors
13
4Never-married
1Adm-clerical
1Not-in-family
4White
1Male
2,174
0
40
39United-States
0<=50K
50
6Self-emp-not-inc
83,311
9Bachelors
13
2Married-civ-spouse
4Exec-managerial
0Husband
4White
1Male
0
0
13
39United-States
0<=50K
38
4Private
215,646
11HS-grad
9
0Divorced
6Handlers-cleaners
1Not-in-family
4White
1Male
0
0
40
39United-States
0<=50K
53
4Private
234,721
111th
7
2Married-civ-spouse
6Handlers-cleaners
0Husband
2Black
1Male
0
0
40
39United-States
0<=50K
28
4Private
338,409
9Bachelors
13
2Married-civ-spouse
10Prof-specialty
5Wife
2Black
0Female
0
0
40
5Cuba
0<=50K
37
4Private
284,582
12Masters
14
2Married-civ-spouse
4Exec-managerial
5Wife
4White
0Female
0
0
40
39United-States
0<=50K
49
4Private
160,187
69th
5
3Married-spouse-absent
8Other-service
1Not-in-family
2Black
0Female
0
0
16
23Jamaica
0<=50K
52
6Self-emp-not-inc
209,642
11HS-grad
9
2Married-civ-spouse
4Exec-managerial
0Husband
4White
1Male
0
0
45
39United-States
1>50K
31
4Private
45,781
12Masters
14
4Never-married
10Prof-specialty
1Not-in-family
4White
0Female
14,084
0
50
39United-States
1>50K
42
4Private
159,449
9Bachelors
13
2Married-civ-spouse
4Exec-managerial
0Husband
4White
1Male
5,178
0
40
39United-States
1>50K
37
4Private
280,464
15Some-college
10
2Married-civ-spouse
4Exec-managerial
0Husband
2Black
1Male
0
0
80
39United-States
1>50K
30
7State-gov
141,297
9Bachelors
13
2Married-civ-spouse
10Prof-specialty
0Husband
1Asian-Pac-Islander
1Male
0
0
40
19India
1>50K
23
4Private
122,272
9Bachelors
13
4Never-married
1Adm-clerical
3Own-child
4White
0Female
0
0
30
39United-States
0<=50K
32
4Private
205,019
7Assoc-acdm
12
4Never-married
12Sales
1Not-in-family
2Black
1Male
0
0
50
39United-States
0<=50K
40
4Private
121,772
8Assoc-voc
11
2Married-civ-spouse
3Craft-repair
0Husband
1Asian-Pac-Islander
1Male
0
0
40
0?
1>50K
34
4Private
245,487
57th-8th
4
2Married-civ-spouse
14Transport-moving
0Husband
0Amer-Indian-Eskimo
1Male
0
0
45
26Mexico
0<=50K
25
6Self-emp-not-inc
176,756
11HS-grad
9
4Never-married
5Farming-fishing
3Own-child
4White
1Male
0
0
35
39United-States
0<=50K
32
4Private
186,824
11HS-grad
9
4Never-married
7Machine-op-inspct
4Unmarried
4White
1Male
0
0
40
39United-States
0<=50K
38
4Private
28,887
111th
7
2Married-civ-spouse
12Sales
0Husband
4White
1Male
0
0
50
39United-States
0<=50K
43
6Self-emp-not-inc
292,175
12Masters
14
0Divorced
4Exec-managerial
4Unmarried
4White
0Female
0
0
45
39United-States
1>50K
40
4Private
193,524
10Doctorate
16
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
60
39United-States
1>50K
54
4Private
302,146
11HS-grad
9
5Separated
8Other-service
4Unmarried
2Black
0Female
0
0
20
39United-States
0<=50K
35
1Federal-gov
76,845
69th
5
2Married-civ-spouse
5Farming-fishing
0Husband
2Black
1Male
0
0
40
39United-States
0<=50K
43
4Private
117,037
111th
7
2Married-civ-spouse
14Transport-moving
0Husband
4White
1Male
0
2,042
40
39United-States
0<=50K
59
4Private
109,015
11HS-grad
9
0Divorced
13Tech-support
4Unmarried
4White
0Female
0
0
40
39United-States
0<=50K
56
2Local-gov
216,851
9Bachelors
13
2Married-civ-spouse
13Tech-support
0Husband
4White
1Male
0
0
40
39United-States
1>50K
19
4Private
168,294
11HS-grad
9
4Never-married
3Craft-repair
3Own-child
4White
1Male
0
0
40
39United-States
0<=50K
54
0?
180,211
15Some-college
10
2Married-civ-spouse
0?
0Husband
1Asian-Pac-Islander
1Male
0
0
60
35South
1>50K
39
4Private
367,260
11HS-grad
9
0Divorced
4Exec-managerial
1Not-in-family
4White
1Male
0
0
80
39United-States
0<=50K
49
4Private
193,366
11HS-grad
9
2Married-civ-spouse
3Craft-repair
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
23
2Local-gov
190,709
7Assoc-acdm
12
4Never-married
11Protective-serv
1Not-in-family
4White
1Male
0
0
52
39United-States
0<=50K
20
4Private
266,015
15Some-college
10
4Never-married
12Sales
3Own-child
2Black
1Male
0
0
44
39United-States
0<=50K
45
4Private
386,940
9Bachelors
13
0Divorced
4Exec-managerial
3Own-child
4White
1Male
0
1,408
40
39United-States
0<=50K
30
1Federal-gov
59,951
15Some-college
10
2Married-civ-spouse
1Adm-clerical
3Own-child
4White
1Male
0
0
40
39United-States
0<=50K
22
7State-gov
311,512
15Some-college
10
2Married-civ-spouse
8Other-service
0Husband
2Black
1Male
0
0
15
39United-States
0<=50K
48
4Private
242,406
111th
7
4Never-married
7Machine-op-inspct
4Unmarried
4White
1Male
0
0
40
33Puerto-Rico
0<=50K
21
4Private
197,200
15Some-college
10
4Never-married
7Machine-op-inspct
3Own-child
4White
1Male
0
0
40
39United-States
0<=50K
19
4Private
544,091
11HS-grad
9
1Married-AF-spouse
1Adm-clerical
5Wife
4White
0Female
0
0
25
39United-States
0<=50K
31
4Private
84,154
15Some-college
10
2Married-civ-spouse
12Sales
0Husband
4White
1Male
0
0
38
0?
1>50K
48
6Self-emp-not-inc
265,477
7Assoc-acdm
12
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
31
4Private
507,875
69th
5
2Married-civ-spouse
7Machine-op-inspct
0Husband
4White
1Male
0
0
43
39United-States
0<=50K
53
6Self-emp-not-inc
88,506
9Bachelors
13
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
24
4Private
172,987
9Bachelors
13
2Married-civ-spouse
13Tech-support
0Husband
4White
1Male
0
0
50
39United-States
0<=50K
49
4Private
94,638
11HS-grad
9
5Separated
1Adm-clerical
4Unmarried
4White
0Female
0
0
40
39United-States
0<=50K
25
4Private
289,980
11HS-grad
9
4Never-married
6Handlers-cleaners
1Not-in-family
4White
1Male
0
0
35
39United-States
0<=50K
57
1Federal-gov
337,895
9Bachelors
13
2Married-civ-spouse
10Prof-specialty
0Husband
2Black
1Male
0
0
40
39United-States
1>50K
53
4Private
144,361
11HS-grad
9
2Married-civ-spouse
7Machine-op-inspct
0Husband
4White
1Male
0
0
38
39United-States
0<=50K
44
4Private
128,354
12Masters
14
0Divorced
4Exec-managerial
4Unmarried
4White
0Female
0
0
40
39United-States
0<=50K
41
7State-gov
101,603
8Assoc-voc
11
2Married-civ-spouse
3Craft-repair
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
29
4Private
271,466
8Assoc-voc
11
4Never-married
10Prof-specialty
1Not-in-family
4White
1Male
0
0
43
39United-States
0<=50K
25
4Private
32,275
15Some-college
10
2Married-civ-spouse
4Exec-managerial
5Wife
3Other
0Female
0
0
40
39United-States
0<=50K
18
4Private
226,956
11HS-grad
9
4Never-married
8Other-service
3Own-child
4White
0Female
0
0
30
0?
0<=50K
47
4Private
51,835
14Prof-school
15
2Married-civ-spouse
10Prof-specialty
5Wife
4White
0Female
0
1,902
60
16Honduras
1>50K
50
1Federal-gov
251,585
9Bachelors
13
0Divorced
4Exec-managerial
1Not-in-family
4White
1Male
0
0
55
39United-States
1>50K
47
5Self-emp-inc
109,832
11HS-grad
9
0Divorced
4Exec-managerial
1Not-in-family
4White
1Male
0
0
60
39United-States
0<=50K
43
4Private
237,993
15Some-college
10
2Married-civ-spouse
13Tech-support
0Husband
4White
1Male
0
0
40
39United-States
1>50K
46
4Private
216,666
45th-6th
3
2Married-civ-spouse
7Machine-op-inspct
0Husband
4White
1Male
0
0
40
26Mexico
0<=50K
35
4Private
56,352
8Assoc-voc
11
2Married-civ-spouse
8Other-service
0Husband
4White
1Male
0
0
40
33Puerto-Rico
0<=50K
41
4Private
147,372
11HS-grad
9
2Married-civ-spouse
1Adm-clerical
0Husband
4White
1Male
0
0
48
39United-States
0<=50K
30
4Private
188,146
11HS-grad
9
2Married-civ-spouse
7Machine-op-inspct
0Husband
4White
1Male
5,013
0
40
39United-States
0<=50K
30
4Private
59,496
9Bachelors
13
2Married-civ-spouse
12Sales
0Husband
4White
1Male
2,407
0
40
39United-States
0<=50K
32
0?
293,936
57th-8th
4
3Married-spouse-absent
0?
1Not-in-family
4White
1Male
0
0
40
0?
0<=50K
48
4Private
149,640
11HS-grad
9
2Married-civ-spouse
14Transport-moving
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
42
4Private
116,632
10Doctorate
16
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
45
39United-States
1>50K
29
4Private
105,598
15Some-college
10
0Divorced
13Tech-support
1Not-in-family
4White
1Male
0
0
58
39United-States
0<=50K
36
4Private
155,537
11HS-grad
9
2Married-civ-spouse
3Craft-repair
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
28
4Private
183,175
15Some-college
10
0Divorced
1Adm-clerical
1Not-in-family
4White
0Female
0
0
40
39United-States
0<=50K
53
4Private
169,846
11HS-grad
9
2Married-civ-spouse
1Adm-clerical
5Wife
4White
0Female
0
0
40
39United-States
1>50K
49
5Self-emp-inc
191,681
15Some-college
10
2Married-civ-spouse
4Exec-managerial
0Husband
4White
1Male
0
0
50
39United-States
1>50K
25
0?
200,681
15Some-college
10
4Never-married
0?
3Own-child
4White
1Male
0
0
40
39United-States
0<=50K
19
4Private
101,509
15Some-college
10
4Never-married
10Prof-specialty
3Own-child
4White
1Male
0
0
32
39United-States
0<=50K
31
4Private
309,974
9Bachelors
13
5Separated
12Sales
3Own-child
2Black
0Female
0
0
40
39United-States
0<=50K
29
6Self-emp-not-inc
162,298
9Bachelors
13
2Married-civ-spouse
12Sales
0Husband
4White
1Male
0
0
70
39United-States
1>50K
23
4Private
211,678
15Some-college
10
4Never-married
7Machine-op-inspct
1Not-in-family
4White
1Male
0
0
40
39United-States
0<=50K
79
4Private
124,744
15Some-college
10
2Married-civ-spouse
10Prof-specialty
2Other-relative
4White
1Male
0
0
20
39United-States
0<=50K
27
4Private
213,921
11HS-grad
9
4Never-married
8Other-service
3Own-child
4White
1Male
0
0
40
26Mexico
0<=50K
40
4Private
32,214
7Assoc-acdm
12
2Married-civ-spouse
1Adm-clerical
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
67
0?
212,759
010th
6
2Married-civ-spouse
0?
0Husband
4White
1Male
0
0
2
39United-States
0<=50K
18
4Private
309,634
111th
7
4Never-married
8Other-service
3Own-child
4White
0Female
0
0
22
39United-States
0<=50K
31
2Local-gov
125,927
57th-8th
4
2Married-civ-spouse
5Farming-fishing
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
18
4Private
446,839
11HS-grad
9
4Never-married
12Sales
1Not-in-family
4White
1Male
0
0
30
39United-States
0<=50K
52
4Private
276,515
9Bachelors
13
2Married-civ-spouse
8Other-service
0Husband
4White
1Male
0
0
40
5Cuba
0<=50K
46
4Private
51,618
11HS-grad
9
2Married-civ-spouse
8Other-service
5Wife
4White
0Female
0
0
40
39United-States
0<=50K
59
4Private
159,937
11HS-grad
9
2Married-civ-spouse
12Sales
0Husband
4White
1Male
0
0
48
39United-States
0<=50K
44
4Private
343,591
11HS-grad
9
0Divorced
3Craft-repair
1Not-in-family
4White
0Female
14,344
0
40
39United-States
1>50K
53
4Private
346,253
11HS-grad
9
0Divorced
12Sales
3Own-child
4White
0Female
0
0
35
39United-States
0<=50K
49
2Local-gov
268,234
11HS-grad
9
2Married-civ-spouse
11Protective-serv
0Husband
4White
1Male
0
0
40
39United-States
1>50K
33
4Private
202,051
12Masters
14
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
50
39United-States
0<=50K
30
4Private
54,334
69th
5
4Never-married
12Sales
1Not-in-family
4White
1Male
0
0
40
39United-States
0<=50K
43
1Federal-gov
410,867
10Doctorate
16
4Never-married
10Prof-specialty
1Not-in-family
4White
0Female
0
0
50
39United-States
1>50K
57
4Private
249,977
8Assoc-voc
11
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
0
40
39United-States
0<=50K
37
4Private
286,730
15Some-college
10
0Divorced
3Craft-repair
4Unmarried
4White
0Female
0
0
40
39United-States
0<=50K
28
4Private
212,563
15Some-college
10
0Divorced
7Machine-op-inspct
4Unmarried
2Black
0Female
0
0
25
39United-States
0<=50K
30
4Private
117,747
11HS-grad
9
2Married-civ-spouse
12Sales
5Wife
1Asian-Pac-Islander
0Female
0
1,573
35
0?
0<=50K
34
2Local-gov
226,296
9Bachelors
13
2Married-civ-spouse
11Protective-serv
0Husband
4White
1Male
0
0
40
39United-States
1>50K
29
2Local-gov
115,585
15Some-college
10
4Never-married
6Handlers-cleaners
1Not-in-family
4White
1Male
0
0
50
39United-States
0<=50K
48
6Self-emp-not-inc
191,277
10Doctorate
16
2Married-civ-spouse
10Prof-specialty
0Husband
4White
1Male
0
1,902
60
39United-States
1>50K
37
4Private
202,683
15Some-college
10
2Married-civ-spouse
12Sales
0Husband
4White
1Male
0
0
48
39United-States
1>50K
48
4Private
171,095
7Assoc-acdm
12
0Divorced
4Exec-managerial
4Unmarried
4White
0Female
0
0
40
9England
0<=50K
32
1Federal-gov
249,409
11HS-grad
9
4Never-married
8Other-service
3Own-child
2Black
1Male
0
0
40
39United-States
0<=50K
End of preview. Expand in Data Studio

Dataset Card for Census Income (Adult)

This dataset is a precise version of Adult or Census Income. This dataset from UCI somehow happens to occupy two links, but we checked and confirm that they are identical.

We used the following python script to create this Hugging Face dataset.

import pandas as pd
from datasets import Dataset, DatasetDict, Features, Value, ClassLabel

# URLs
url1 = "https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data"
url2 = "https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test"

# Column names
columns = [
    "age", "workclass", "fnlwgt", "education", "education-num", "marital-status",
    "occupation", "relationship", "race", "sex", "capital-gain", "capital-loss",
    "hours-per-week", "native-country", "income"
]


# Load datasets
df_train = pd.read_csv(url1, names=columns, skipinitialspace=True)
df_test = pd.read_csv(url2, names=columns, skipinitialspace=True, skiprows=1)

# Convert continuous columns to float
continuous_columns = ["age", "fnlwgt", "education-num", "capital-gain", "capital-loss", "hours-per-week"]
for col in continuous_columns:
    df_train[col] = pd.to_numeric(df_train[col], errors='coerce')
    df_test[col] = pd.to_numeric(df_test[col], errors='coerce')

df_test['income'] = df_test['income'].str.rstrip('.') # This is somewhat critical.

# Define categorical columns
categorical_columns = [
    "workclass", "education", "marital-status", "occupation", "relationship",
    "race", "sex", "native-country", "income"
]

# Dictionary to store category mappings
category_mappings = {}

for col in categorical_columns:
    # Convert train column to category and extract categories
    df_train[col] = df_train[col].astype("category")
    category_mappings[col] = df_train[col].cat.categories.to_list()  # Store category order

    # Apply the same category mapping to test
    df_test[col] = pd.Categorical(df_test[col], categories=category_mappings[col])

    # Convert to integer codes
    df_train[col] = df_train[col].cat.codes
    df_test[col] = df_test[col].cat.codes

# Define Hugging Face dataset schema
hf_features = Features({
    "age": Value("int64"),
    "workclass": ClassLabel(names=category_mappings["workclass"]),
    "fnlwgt": Value("int64"),
    "education": ClassLabel(names=category_mappings["education"]),
    "education-num": Value("int64"),
    "marital-status": ClassLabel(names=category_mappings["marital-status"]),
    "occupation": ClassLabel(names=category_mappings["occupation"]),
    "relationship": ClassLabel(names=category_mappings["relationship"]),
    "race": ClassLabel(names=category_mappings["race"]),
    "sex": ClassLabel(names=category_mappings["sex"]),
    "capital-gain": Value("int64"),
    "capital-loss": Value("int64"),
    "hours-per-week": Value("int64"),
    "native-country": ClassLabel(names=category_mappings["native-country"]),
    "income": ClassLabel(names=category_mappings["income"])
})

# Convert pandas DataFrame to Hugging Face Dataset
hf_train = Dataset.from_pandas(df_train, features=hf_features)
hf_test = Dataset.from_pandas(df_test, features=hf_features)

# Create a dataset dictionary
hf_dataset = DatasetDict({
    "train": hf_train,
    "test": hf_test
})

# Print dataset structure
print(hf_dataset)

The printed output could look like

DatasetDict({
    train: Dataset({
        features: ['age', 'workclass', 'fnlwgt', 'education', 'education-num', 'marital-status', 'occupation', 'relationship', 'race', 'sex', 'capital-gain', 'capital-loss', 'hours-per-week', 'native-country', 'income'],
        num_rows: 32561
    })
    test: Dataset({
        features: ['age', 'workclass', 'fnlwgt', 'education', 'education-num', 'marital-status', 'occupation', 'relationship', 'race', 'sex', 'capital-gain', 'capital-loss', 'hours-per-week', 'native-country', 'income'],
        num_rows: 16281
    })
})
Downloads last month
37