Spaces:
Sleeping
Sleeping
Download scripts/x_sensitive/prepare_data_for_binary_classification.py from HunterNope/AutoCenzurer: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/HunterNope/AutoCenzurer/resolve/main/scripts/x_sensitive/prepare_data_for_binary_classification.py
- Command line
-
hf download hf://spaces/HunterNope/AutoCenzurer/scripts/x_sensitive/prepare_data_for_binary_classification.py
-
curl -L -o prepare_data_for_binary_classification.py https://huggingface.co/spaces/HunterNope/AutoCenzurer/resolve/main/scripts/x_sensitive/prepare_data_for_binary_classification.py
572 Bytes
| import pandas as pd | |
| df = pd.read_csv('x_sensitive_train_v2.csv') | |
| new_df = df[df['label'] == 'CONFLICTUAL'].copy() | |
| new_df['label'] = 1 | |
| negative_size = len(new_df) | |
| unharmful_sample = df[df['label'] == 'UNHARMFUL_PROFANITY'][:int(negative_size/2)] | |
| unharmful_sample['label'] = 0 | |
| none_sample = df[df['label'] == "NONE"][:int(negative_size/2)] | |
| none_sample['label'] = 0 | |
| new_df = pd.concat([new_df, unharmful_sample, none_sample]) | |
| new_df = new_df.rename(columns={"span": "span_text", "original_index": "id"}) | |
| new_df.to_csv('binary_classification.csv', index=False, sep=';') | |