File size: 673 Bytes
8ea8e7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from datasets import load_dataset

# Load your dataset from Hugging Face Hub
dataset = load_dataset("hoaj/fb-housing-posts")

# Prepare labels
seeking_tenant_label = "søger lejer / seeking tenant"
not_seeking_tenant_label = "søger ikke lejer / does not seek tenant"


# Function to map boolean to a categorical label
def label_mapping(example):
    if example["is_seeking_tenant"]:
        return {"target": seeking_tenant_label}
    else:
        return {"target": not_seeking_tenant_label}


# Map the label_mapping function to all splits
dataset = dataset.map(label_mapping)

# Push the updated dataset to Hugging Face Hub
dataset.push_to_hub("hoaj/fb-housing-posts")