Data¶
hqnn_forge.data ¶
hqnn_forge.data¶
Dataset loaders.
Exported symbols
load_credit_card_fraud Kaggle Credit Card Fraud Detection (mlg-ulb/creditcardfraud). CreditCardFraud (X, y, feature_names) returned by the loader. DatasetNotFoundError Raised when the CSV is absent and download=False. DatasetDownloadError Raised when download=True but fetching the CSV fails. load_taiwanese_bankruptcy UCI Taiwanese Bankruptcy Prediction (3.2% positive). load_iranian_churn UCI Iranian Churn (15.7% positive). load_cervical_cancer_risk UCI Cervical Cancer (Risk Factors), biopsy label (6.7% positive). BinaryDataset (X, y, feature_names) returned by the UCI loaders.
CreditCardFraud ¶
Bases: NamedTuple
Attributes:
| Name | Type | Description |
|---|---|---|
X |
NDArray[float64]
|
Features, shape |
y |
NDArray[int64]
|
Labels, shape |
feature_names |
tuple[str, ...]
|
Column name for each column of |
DatasetDownloadError ¶
Bases: RuntimeError
Downloading was requested but could not be carried out or did not produce the file.
DatasetNotFoundError ¶
Bases: FileNotFoundError
The dataset file is missing and downloading was not requested.
BinaryDataset ¶
Bases: NamedTuple
Attributes:
| Name | Type | Description |
|---|---|---|
X |
NDArray[float64]
|
Features, shape |
y |
NDArray[int64]
|
Labels, shape |
feature_names |
tuple[str, ...]
|
Column name for each column of |
load_credit_card_fraud ¶
load_credit_card_fraud(path: str | PathLike[str] | None = None, *, download: bool = False, drop_time: bool = False, strict: bool = False) -> CreditCardFraud
Load creditcard.csv as NumPy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str] | None
|
The CSV file, or a directory containing |
None
|
download
|
bool
|
If the file is missing, fetch it with the Kaggle CLI into the file's
directory. Requires |
False
|
drop_time
|
bool
|
Drop the |
False
|
strict
|
bool
|
Also require the published row count (284,807) and fraud count (492). |
False
|
Returns:
| Type | Description |
|---|---|
CreditCardFraud
|
|
Raises:
| Type | Description |
|---|---|
DatasetNotFoundError
|
The file is missing and |
DatasetDownloadError
|
|
ValueError
|
The file does not have the expected columns, has no data rows, has
non-numeric values, labels other than 0/1, or (with |
load_cervical_cancer_risk ¶
load_cervical_cancer_risk(path: str | PathLike[str] | None = None, *, download: bool = False, missing: Literal['drop', 'keep'] = 'drop', strict: bool = False) -> BinaryDataset
Cervical Cancer (Risk Factors): 30 risk factors, biopsy result as label; 668 complete records with 45 positives (6.7%).
Demographics, habits and medical history of 858 patients, collected at the Hospital Universitario de Caracas, Venezuela; patients could decline to answer questions, hence the missing values. UCI dataset 383, CC BY 4.0, doi:10.24432/C5Z310.
Preprocessing, always applied: Biopsy is the label. Left out of the
features are Hinselmann, Schiller and Citology, the outcomes of
the other examinations, which would leak the diagnosis, and the two
STDs: Time since ... diagnosis columns, missing for 787 of 858
patients. That leaves 30 features. STDs:cervical condylomatosis and
STDs:AIDS are 0 for every complete record. The file also repeats 23
of its rows exactly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str] | None
|
|
None
|
download
|
bool
|
If the file is missing, fetch the UCI archive and extract it there. |
False
|
missing
|
Literal['drop', 'keep']
|
The file marks a missing answer with |
'drop'
|
strict
|
bool
|
Also require the published file (SHA-256). |
False
|
Returns:
| Type | Description |
|---|---|
BinaryDataset
|
|
Raises:
| Type | Description |
|---|---|
(DatasetNotFoundError, DatasetDownloadError, ValueError)
|
As for |
load_iranian_churn ¶
load_iranian_churn(path: str | PathLike[str] | None = None, *, download: bool = False, drop_duplicates: bool = False, strict: bool = False) -> BinaryDataset
Iranian Churn: 3,150 telecom customers, 13 features, 495 churned (15.7%).
Customers drawn at random from an Iranian telecom company's database over 12 months; the label says whether the customer churned. UCI dataset 563, CC BY 4.0, doi:10.24432/C5JW3Z.
The file holds 300 rows that repeat an earlier row exactly, so the same
customer record can land in both the training and the test fold.
drop_duplicates=True keeps the first of each, leaving 2,850 rows with
446 churned (15.6%). Age Group is a binned copy of Age, and
Complains, Tariff Plan and Status are codes stored as numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str] | None
|
|
None
|
download
|
bool
|
If the file is missing, fetch the UCI archive and extract it there. |
False
|
drop_duplicates
|
bool
|
Drop rows identical to an earlier one, features and label alike. |
False
|
strict
|
bool
|
Also require the published file (SHA-256). |
False
|
Returns:
| Type | Description |
|---|---|
BinaryDataset
|
|
Raises:
| Type | Description |
|---|---|
(DatasetNotFoundError, DatasetDownloadError, ValueError)
|
As for |
load_taiwanese_bankruptcy ¶
load_taiwanese_bankruptcy(path: str | PathLike[str] | None = None, *, download: bool = False, strict: bool = False) -> BinaryDataset
Taiwanese Bankruptcy Prediction: 6,819 companies, 95 financial ratios, 220 bankrupt (3.2%).
Collected from the Taiwan Economic Journal for 1999-2009, with bankruptcy defined by the business regulations of the Taiwan Stock Exchange. UCI dataset 572, CC BY 4.0, doi:10.24432/C5004D.
The file (data.csv) is used unchanged: no missing values, no duplicate
rows. Most ratios lie in [0, 1], but some reach 1e10, so scale before
PCA; Net Income Flag is constant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str] | None
|
|
None
|
download
|
bool
|
If the file is missing, fetch the UCI archive and extract it there. |
False
|
strict
|
bool
|
Also require the file to be byte-identical to the published one (SHA-256), which fixes the row and positive counts above. |
False
|
Returns:
| Type | Description |
|---|---|
BinaryDataset
|
|
Raises:
| Type | Description |
|---|---|
DatasetNotFoundError
|
The file is missing and |
DatasetDownloadError
|
|
ValueError
|
The file does not have the expected columns, has no data rows, has a
non-numeric value or a label other than 0/1, or (with |