-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_example.py
More file actions
31 lines (23 loc) · 759 Bytes
/
run_example.py
File metadata and controls
31 lines (23 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import pandas as pd
from consent import Config, ConSent
import consent.utils as utils
# Load the example config
with open("examples/configs/L1__train.json", 'r') as f:
config = Config(**json.load(f))
# Initialize
consent = ConSent(config)
# Load some data
data_df = pd.read_csv("tests/test_data/Chats-EN-ConSent_dummy_data.csv",
index_col=0)
# Rename the target column to 'code'
data_df = data_df.rename(columns={"L1": "code"})
# Split train and test sets (for the dummy_data, keep test_size=0.5)
train_data_df, test_data_df = \
utils.train_test_split(data_df, test_size=0.5)
# Train
consent.train(train_data_df)
# Test
print("Testing on unseen data:")
consent.test(test_data_df)
print("Example run successful!")