File size: 5,121 Bytes
91fdf7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""Breast Cancer Wisconsin Dataset: African Physiognomy Adjusted"""

import csv
import datasets

_CITATION = """\
@misc{udodi2025breast,
  title={Addressing Representation Bias in Breast Cancer Datasets: A Physiognomy-Informed Approach for African Populations},
  author={Kossiso Udodi Royce},
  year={2025},
  publisher={Electric Sheep Africa},
  url={https://huggingface.co/datasets/ElectricSheepAfrica/breast-cancer-african-adjusted}
}
"""

_DESCRIPTION = """\
This dataset addresses representation bias in medical AI by providing an African physiognomy-adjusted 
version of the classic Wisconsin Breast Cancer Dataset. The adjustment methodology systematically 
modifies cellular morphology features to better reflect documented physiological differences in 
African populations.

Key adjustments include:
- Higher breast density (5-8% increase in size/texture features)
- Enhanced irregularity (12-19% increase in concavity/fractal features)  
- Reduced boundary smoothness (10-12% decrease in smoothness/symmetry)

The dataset contains 569 samples with 30 morphological features from Fine Needle Aspirate (FNA) 
samples, classified as Malignant (M) or Benign (B).
"""

_HOMEPAGE = "https://huggingface.co/datasets/ElectricSheepAfrica/breast-cancer-african-adjusted"

_LICENSE = "CC BY 4.0"

_URLS = {
    "african_adjusted": "breast_cancer_african_adjusted.csv",
    "wisconsin_breast_cancer_dataset": "breast_cancer_original.csv",
}

class BreastCancerAfricanAdjusted(datasets.GeneratorBasedBuilder):
    """Breast Cancer Wisconsin Dataset with African Physiognomy Adjustments"""

    VERSION = datasets.Version("1.1.0")

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name="african_adjusted",
            version=VERSION,
            description="African physiognomy-adjusted breast cancer dataset",
        ),
        datasets.BuilderConfig(
            name="wisconsin_breast_cancer_dataset",
            version=VERSION,
            description="Original Wisconsin breast cancer dataset",
        ),
    ]

    DEFAULT_CONFIG_NAME = "african_adjusted"

    def _info(self):
        features = datasets.Features({
            "id": datasets.Value("float64"),
            "diagnosis": datasets.Value("string"),
            "radius_mean": datasets.Value("float64"),
            "texture_mean": datasets.Value("float64"),
            "perimeter_mean": datasets.Value("float64"),
            "area_mean": datasets.Value("float64"),
            "smoothness_mean": datasets.Value("float64"),
            "compactness_mean": datasets.Value("float64"),
            "concavity_mean": datasets.Value("float64"),
            "concave points_mean": datasets.Value("float64"),
            "symmetry_mean": datasets.Value("float64"),
            "fractal_dimension_mean": datasets.Value("float64"),
            "radius_se": datasets.Value("float64"),
            "texture_se": datasets.Value("float64"),
            "perimeter_se": datasets.Value("float64"),
            "area_se": datasets.Value("float64"),
            "smoothness_se": datasets.Value("float64"),
            "compactness_se": datasets.Value("float64"),
            "concavity_se": datasets.Value("float64"),
            "concave points_se": datasets.Value("float64"),
            "symmetry_se": datasets.Value("float64"),
            "fractal_dimension_se": datasets.Value("float64"),
            "radius_worst": datasets.Value("float64"),
            "texture_worst": datasets.Value("float64"),
            "perimeter_worst": datasets.Value("float64"),
            "area_worst": datasets.Value("float64"),
            "smoothness_worst": datasets.Value("float64"),
            "compactness_worst": datasets.Value("float64"),
            "concavity_worst": datasets.Value("float64"),
            "concave points_worst": datasets.Value("float64"),
            "symmetry_worst": datasets.Value("float64"),
            "fractal_dimension_worst": datasets.Value("float64"),
        })

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        urls = _URLS[self.config.name]
        data_file = dl_manager.download_and_extract(urls)

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": data_file,
                    "split": "train",
                },
            ),
        ]

    def _generate_examples(self, filepath, split):
        with open(filepath, encoding="utf-8") as f:
            reader = csv.DictReader(f)
            for key, row in enumerate(reader):
                # Convert numeric fields
                for field in row:
                    if field != "diagnosis":
                        try:
                            row[field] = float(row[field])
                        except (ValueError, TypeError):
                            row[field] = None
                
                yield key, row