The dataset viewer is not available for this dataset.
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
Dataset Card for Correctional Offender Management Profiling for Alternative Sanctions (COMPAS, scores-two-years)
This dataset is a precise version of compas-scores-two-years.csv as given in the compas-analysis notebook.
There are more "versions" of compas data, e.g., the "main dataset" compas.db that contains criminal history, etc. and COMPAS risk scores for defendants from Broward County. However, those versions are not covered here, and we did not get enough time to check how they are related to the current compas-scores-two-years.csv.
We used the following python script to create this Hugging Face dataset.
# Load the dataset into a pandas DataFrame
import pandas as pd
df_compas = pd.read_csv("https://github.com/propublica/compas-analysis/raw/master/compas-scores-two-years.csv")
from datasets import Dataset, DatasetDict, Features, Value, ClassLabel
# Define continuous (numerical) and categorical columns
categorical_columns = {
"sex", "age_cat", "race", "c_charge_degree", "c_charge_desc", "is_recid",
"r_charge_degree", "violent_recid", "is_violent_recid", "vr_charge_degree",
"type_of_assessment", "score_text", "v_type_of_assessment", "v_score_text",
"event", "two_year_recid"
}
string_columns = {'c_case_number',
'first',
'last',
'name',
'r_case_number',
'r_charge_desc',
'violent_recid',
'vr_case_number',
'vr_charge_desc',
'c_jail_in', 'c_jail_out'
}
date_columns = {'compas_screening_date',
'c_offense_date',
'c_arrest_date',
'r_offense_date',
'vr_offense_date',
'screening_date',
'v_screening_date','dob', 'r_jail_in', 'r_jail_out', 'in_custody', 'out_custody'}
# Convert categorical columns to category type and store mappings
category_mappings = {}
for col in categorical_columns:
category_mappings[col] = list(df_compas[col].astype('category').cat.categories)
# Define Hugging Face dataset schema
hf_features = Features({
col: Value("date32") if col in date_columns else Value("string") if col in string_columns else ClassLabel(names=category_mappings[col]) if col in categorical_columns else Value("int64") for col in df_compas.columns
})
# Create a dataset dictionary
hf_dataset = DatasetDict({
"train": Dataset.from_pandas(df_compas, features=hf_features),
})
# Print dataset structure
print(hf_dataset)
The printed output could look like
DatasetDict({
train: Dataset({
features: ['id', 'name', 'first', 'last', 'compas_screening_date', 'sex', 'dob', 'age', 'age_cat', 'race', 'juv_fel_count', 'decile_score', 'juv_misd_count', 'juv_other_count', 'priors_count', 'days_b_screening_arrest', 'c_jail_in', 'c_jail_out', 'c_case_number', 'c_offense_date', 'c_arrest_date', 'c_days_from_compas', 'c_charge_degree', 'c_charge_desc', 'is_recid', 'r_case_number', 'r_charge_degree', 'r_days_from_arrest', 'r_offense_date', 'r_charge_desc', 'r_jail_in', 'r_jail_out', 'violent_recid', 'is_violent_recid', 'vr_case_number', 'vr_charge_degree', 'vr_offense_date', 'vr_charge_desc', 'type_of_assessment', 'decile_score.1', 'score_text', 'screening_date', 'v_type_of_assessment', 'v_decile_score', 'v_score_text', 'v_screening_date', 'in_custody', 'out_custody', 'priors_count.1', 'start', 'end', 'event', 'two_year_recid'],
num_rows: 7214
})
})
Also, according to the compas-analysis notebook, we also checked the number of "usable" rows as follows.
((df_compas['score_text'] != 'N/A').values & (
df_compas['is_recid'] != -1).values & (
df_compas['c_charge_degree'] != 'O').values & (
df_compas['days_b_screening_arrest'] <= 30).values & (
df_compas['days_b_screening_arrest'] >= -30).values).sum()
which should return 6172 as expected. This number could also serve as a standardised cleaning scheme.
- Downloads last month
- 88