{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting things up\n", "\n", "## About this notebook\n", "\n", "In this notebook, we embark on a journey to enhance the predictive power of the Titanic Dataset through sophisticated preprocessing using the ``BinaryCarver`` pipeline. Designed to maximize associations in the data, ``BinaryCarver`` is a robust Python tool capable of discretizing any type of data—whether it be quantitative or qualitative. Our specific focus is on preparing the dataset for binary classification tasks, such as predicting survival outcomes.\n", "\n", "The Titanic Dataset, derived from the iconic 1912 Titanic passenger information, provides a diverse set of features ranging from socio-economic status and age to cabin location. Leveraging ``BinaryCarver``, we aim to perform association-maximizing discretization, refining both quantitative and qualitative features to create a finely tuned dataset for our binary classification endeavors.\n", "\n", "Throughout this notebook, we'll delve into the intricacies of ``BinaryCarver``'s discretization pipeline, exploring its capabilities in handling a variety of data types. Whether it's transforming passenger ages or classifying fares, ``BinaryCarver``'s adaptability ensures that every feature is optimally represented for our classification tasks.\n", "\n", "Join us in this exploration as we harness the power of ``BinaryCarver`` to preprocess the Titanic Dataset. Through effective feature engineering and discretization, we strive to create a dataset that not only captures the nuances of the Titanic passenger profiles but also sets the stage for the development of accurate and impactful binary classification models.\n", "\n", "Let's dive in and uncover the potential of ``BinaryCarver`` in transforming the Titanic Dataset for optimal predictive modeling.\n", "\n", "\n", "## Installation" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# %pip install AutoCarver[jupyter]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Titanic Data\n", "\n", "In this example notebook, we will use the Titanic dataset.\n", "\n", "The Titanic dataset is a well-known and frequently used dataset in the field of machine learning and data science. It provides information about the passengers on board the Titanic, the famous ship that sank on its maiden voyage in 1912. The dataset is often used for predictive modeling, classification, and regression tasks.\n", "\n", "The dataset includes various features such as passengers' names, ages, genders, ticket classes, cabin information, and whether they survived or not. The primary goal when working with the Titanic dataset is often to build predictive models that can infer whether a passenger survived or perished based on their individual characteristics (binary classification)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SurvivedPclassNameSexAgeSiblings/Spouses AboardParents/Children AboardFare
003Mr. Owen Harris Braundmale22.0107.2500
111Mrs. John Bradley (Florence Briggs Thayer) Cum...female38.01071.2833
213Miss. Laina Heikkinenfemale26.0007.9250
311Mrs. Jacques Heath (Lily May Peel) Futrellefemale35.01053.1000
403Mr. William Henry Allenmale35.0008.0500
\n", "
" ], "text/plain": [ " Survived Pclass Name \\\n", "0 0 3 Mr. Owen Harris Braund \n", "1 1 1 Mrs. John Bradley (Florence Briggs Thayer) Cum... \n", "2 1 3 Miss. Laina Heikkinen \n", "3 1 1 Mrs. Jacques Heath (Lily May Peel) Futrelle \n", "4 0 3 Mr. William Henry Allen \n", "\n", " Sex Age Siblings/Spouses Aboard Parents/Children Aboard Fare \n", "0 male 22.0 1 0 7.2500 \n", "1 female 38.0 1 0 71.2833 \n", "2 female 26.0 0 0 7.9250 \n", "3 female 35.0 1 0 53.1000 \n", "4 male 35.0 0 0 8.0500 " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "# URL to the Titanic dataset on Kaggle\n", "titanic_url = \"https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv\"\n", "\n", "# Use pandas to read the CSV file directly from the URL\n", "titanic_data = pd.read_csv(titanic_url)\n", "\n", "# Display the first few rows of the dataset\n", "titanic_data.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Target type and Carver selection" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Survived\n", "0 545\n", "1 342\n", "Name: count, dtype: int64" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "target = \"Survived\"\n", "\n", "titanic_data[target].value_counts(dropna=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The target ``\"Survived\"`` is a binary target of type ``int64`` used in a classification task. Hence we will use ``AutoCarver.BinaryCarver`` and ``AutoCarver.selectors.ClassificationSelector`` in following code blocks." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Sampling" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(np.float64(0.38552188552188554), np.float64(0.3856655290102389))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sklearn.model_selection import train_test_split\n", "\n", "# stratified sampling by target\n", "train_set, dev_set = train_test_split(titanic_data, test_size=0.33, random_state=42, stratify=titanic_data[target])\n", "\n", "# checking target rate per dataset\n", "train_set[target].mean(), dev_set[target].mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting up Features to Carver" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SurvivedPclassNameSexAgeSiblings/Spouses AboardParents/Children AboardFare
61703Mr. Antoni Yasbeckmale27.01014.4542
48901Mr. Harry Markland Molsonmale55.00030.5000
87113Miss. Adele Kiamie Najibfemale15.0007.2250
65403Mrs. John (Catherine) Bourkefemale32.01115.5000
65303Mr. Alexander Radeffmale27.0007.8958
\n", "
" ], "text/plain": [ " Survived Pclass Name Sex Age \\\n", "617 0 3 Mr. Antoni Yasbeck male 27.0 \n", "489 0 1 Mr. Harry Markland Molson male 55.0 \n", "871 1 3 Miss. Adele Kiamie Najib female 15.0 \n", "654 0 3 Mrs. John (Catherine) Bourke female 32.0 \n", "653 0 3 Mr. Alexander Radeff male 27.0 \n", "\n", " Siblings/Spouses Aboard Parents/Children Aboard Fare \n", "617 1 0 14.4542 \n", "489 0 0 30.5000 \n", "871 0 0 7.2250 \n", "654 1 1 15.5000 \n", "653 0 0 7.8958 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_set.head()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Survived int64\n", "Pclass int64\n", "Name str\n", "Sex str\n", "Age float64\n", "Siblings/Spouses Aboard int64\n", "Parents/Children Aboard int64\n", "Fare float64\n", "dtype: object" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# column data types\n", "train_set.dtypes" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Parents/Children Aboard\n", "0 438\n", "1 87\n", "2 60\n", "3 3\n", "5 3\n", "4 2\n", "6 1\n", "Name: count, dtype: int64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# values taken by Parents/Children Aboard\n", "train_set[\"Parents/Children Aboard\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Pclass\n", "3 326\n", "1 142\n", "2 126\n", "Name: count, dtype: int64" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# values taken by Pclass\n", "train_set[\"Pclass\"].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The feature ``\"Pclass\"`` is of type ``\"int64\"``, but it can be considered a qualitative ordinal feature rather than a quantitative discrete feature (socio-economic status). Thus we will add it to the list of ``ordinal_features`` and set the ordering of its values in ``values_orders`` (string values). \n", "\n", "``\"Sex\"`` is the only quantitative categorical feature, it's added to the list of ``qualitative_features``.\n", "\n", "``\"Fare\"`` is the only quantitative continuous features, whilst ``\"Age\"``, ``\"Siblings/Spouses Aboard\"`` and ``\"Parents/Children Aboard\"`` can be considered as quantitative discrete features. Those four features will be added to the list of ``quantitative_features``." ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(Ordinal('Pclass'), Categorical('Sex'), Numerical('Age'))" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from AutoCarver import Features\n", "\n", "# initiating Features to carve\n", "features = Features(\n", " categoricals=[\"Sex\"],\n", " numericals=[\"Age\", \"Fare\", \"Siblings/Spouses Aboard\", \"Parents/Children Aboard\"],\n", " ordinals={\"Pclass\": [\"1\", \"2\", \"3\"]}, # user-specified ordering for ordinal features\n", ")\n", "features[\"Pclass\"], features[\"Sex\"], features[\"Age\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Using AutoCarver" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## AutoCarver settings\n", "\n", "### Representativness of modalities\n", "\n", "The attribute ``min_freq`` allows one to choose the minimum frequency per basic modalities. It is used:\n", "\n", "- For quantitative features, to define the number of quantiles to initialy discretize the features with.\n", "\n", "- For qualitative features, to define the threshold under which a modality is grouped to either a default value or its closest modality." ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "min_freq = 0.025" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Tip:** should be set between ``0.01`` (slower, preciser, less robust) and ``0.2`` (faster, more robust)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Optional: Desired number of modalities\n", "\n", "The attribute ``max_n_mod`` allows one to choose the maximum number of modalities per carved feature. It is used by **Carvers** has the upper limit of number of modalities per consecutive combination of modalities." ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "max_n_mod = 5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Tip:** should be set between ``3`` (faster, more robust) and ``7`` (slower, preciser, less robust)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Optional: Grouping NaNs\n", "\n", "The attribute ``dropna`` allows one to choose whether or not ``nan`` should be grouped with another modality. If set to ``True``, **Carvers** will first find the most suitable combination of non-``nan`` values, and then test out all possible combinations with ``nan``." ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "dropna = False # anyway, there are no nan in this dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Fitting AutoCarver" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* First, all qualitative features are discretized:\n", " 1. Using ``StringDiscretizer`` to convert them to ``str`` if not already the case\n", " 2. For qualitative ordinal features: using ``OrdinalDiscretizer`` for under-represented values (less frequent than ``min_freq``) to be grouped with its closest modality\n", " 3. For qualitative categorical features: using ``CategoricalDiscretizer`` for under-represented values (less frequent than ``min_freq``) to be grouped with a default value (``features.default=\"__OTHER__\"``)\n", "\n", "* Second, all quantitative features are discretized:\n", " 1. Using ``ContinuousDiscretizer`` for quantile discretization that keeps track of over-represented values (more frequent than ``min_freq``)\n", " 2. Using ``OrdinalDiscretizer`` for any remaining under-represented values (less frequent than ``min_freq/2``) to be grouped with its closest modality\n", "\n", "* Third, all features are carved following this recipe, for all classes of ``train_set[target]`` (except one):\n", " 1. The raw distribution is printed out on provided ``train_set`` and ``dev_set``. It's the output of the discretization step\n", " 2. Grouping modalities: all consecutive combinations of modalities are applied to ``train_set``\n", " 3. Computing associations: the association metric (Tschruprow's T, by default) is computed with the provided ``train_set[target]``\n", " 4. Combinations are sorted in descending order by association value\n", " 5. Testing robustness: finds the first combination that checks the following:\n", " - Representativness of modalities on ``train_set`` and ``dev_set`` (all should be more frequent than ``min_freq/2``)\n", " - Distinct target rates per consecutive modalities on ``train_set`` and ``dev_set`` \n", " - No inversion of target rates between ``train_set`` and ``dev_set`` (same ordering of modalities by target rate)\n", " 6. (Optional) If requested via ``dropna=True``, and if any, all combinations of modalities with ``nan`` are applied to ``train_set`` and steps 3. and 4. are run\n", " 7. The carved distribution is printed out on provided ``train_set`` and ``dev_set``. It's the output of the carving step" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "------\n", "--- [QuantitativeDiscretizer] Fit Features(['Age', 'Fare', 'Siblings/Spouses Aboard', 'Parents/Children Aboard'])\n", " - [ContinuousDiscretizer] Fit Features(['Age', 'Fare', 'Siblings/Spouses Aboard', 'Parents/Children Aboard'])\n", " - [OrdinalDiscretizer] Fit Features(['Age', 'Fare', 'Siblings/Spouses Aboard', 'Parents/Children Aboard'])\n", "------\n", "\n", "------\n", "--- [QualitativeDiscretizer] Fit Features(['Sex', 'Pclass'])\n", " - [StringDiscretizer] Fit Features(['Pclass'])\n", " - [OrdinalDiscretizer] Fit Features(['Pclass'])\n", " - [CategoricalDiscretizer] Fit Features(['Sex'])\n", "------\n", "\n", "---------\n", "------ [BinaryCarver] Fit Features(['Sex', 'Pclass', 'Age', 'Fare', 'Siblings/Spouses Aboard', 'Parents/Children Aboard'])\n", "--- [BinaryCarver] Fit Categorical('Sex') (1/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
male0.18780.6364378
female0.73150.3636216
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.19490.6655195
0.76530.334598
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
male0.18780.6364378
female0.73150.3636216
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.19490.6655195
0.76530.334598
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "--- [BinaryCarver] Fit Ordinal('Pclass') (2/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
10.61970.2391142
20.46830.2121126
30.25150.5488326
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.64860.252674
0.48280.198058
0.22980.5495161
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
1 to 20.54850.4512268
30.25150.5488326
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.57580.4505132
0.22980.5495161
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "--- [BinaryCarver] Fit Numerical('Age') (3/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 1.00e+000.83330.020212
1.00e+00 < x <= 2.00e+000.50000.00674
2.00e+00 < x <= 4.00e+000.71430.023614
4.00e+00 < x <= 6.00e+000.57140.01187
6.00e+00 < x <= 8.00e+000.28570.01187
8.00e+00 < x <= 1.00e+010.00000.01016
1.00e+01 < x <= 1.40e+010.33330.01529
1.40e+01 < x <= 1.60e+010.50000.030318
1.60e+01 < x <= 1.70e+010.30000.016810
1.70e+01 < x <= 1.80e+010.33330.035421
1.80e+01 < x <= 1.90e+010.39130.038723
1.90e+01 < x <= 2.05e+010.11110.030318
2.05e+01 < x <= 2.10e+010.19050.035421
2.10e+01 < x <= 2.20e+010.42420.055633
2.20e+01 < x <= 2.35e+010.40000.016810
2.35e+01 < x <= 2.40e+010.54170.040424
2.40e+01 < x <= 2.50e+010.13330.025315
2.50e+01 < x <= 2.60e+010.40000.016810
2.60e+01 < x <= 2.70e+010.50000.033720
2.70e+01 < x <= 2.85e+010.25000.033720
2.85e+01 < x <= 2.90e+010.44440.030318
2.90e+01 < x <= 3.05e+010.26920.043826
3.05e+01 < x <= 3.10e+010.45450.018511
3.10e+01 < x <= 3.25e+010.50000.030318
3.25e+01 < x <= 3.30e+010.36360.018511
3.30e+01 < x <= 3.45e+010.28570.023614
3.45e+01 < x <= 3.50e+010.54550.018511
3.50e+01 < x <= 3.60e+010.43750.026916
3.60e+01 < x <= 3.70e+010.22220.01529
3.70e+01 < x <= 3.80e+010.62500.01358
3.80e+01 < x <= 3.90e+010.33330.020212
3.90e+01 < x <= 4.00e+010.46150.021913
4.00e+01 < x <= 4.10e+010.33330.01016
4.10e+01 < x <= 4.20e+010.46150.021913
4.20e+01 < x <= 4.40e+010.33330.020212
4.40e+01 < x <= 4.50e+010.45450.018511
4.50e+01 < x <= 4.60e+010.25000.00674
4.60e+01 < x <= 4.70e+010.25000.01358
4.70e+01 < x <= 4.80e+010.77780.01529
4.80e+01 < x <= 5.00e+010.45450.018511
5.00e+01 < x <= 5.10e+010.20000.00845
5.10e+01 < x <= 5.40e+010.40000.016810
5.40e+01 < x <= 5.60e+010.37500.01358
5.60e+01 < x <= 5.80e+010.33330.01016
5.80e+01 < x <= 6.10e+010.00000.01187
6.10e+01 < x <= 6.50e+010.28570.01187
6.50e+01 < x0.12500.01358
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
1.00000.00682
0.28570.02397
0.75000.01374
1.00000.00682
0.50000.01374
0.50000.01374
0.66670.02056
0.25000.02738
0.50000.02056
0.40000.051215
0.20000.034110
0.33330.02056
0.15380.044413
0.16670.02056
0.18750.054616
0.50000.034110
0.50000.034110
0.27270.037511
0.50000.02056
0.26320.064819
0.42860.02397
0.33330.03079
0.62500.02738
0.40000.01715
0.66670.02056
0.75000.01374
0.60000.034110
0.57140.02397
0.25000.01374
0.25000.01374
0.16670.02056
0.20000.01715
0.20000.01715
0.50000.01374
0.00000.01374
0.33330.01023
0.25000.01374
0.00000.00682
0.66670.01023
0.57140.02397
0.50000.00682
0.50000.02056
nan0.00000
0.50000.00682
0.66670.01023
0.33330.02056
0.00000.00682
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 6.00e+000.70270.062337
6.00e+00 < x <= 5.80e+010.37380.9007535
5.80e+01 < x0.13640.037022
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.60000.051215
0.37450.9113267
0.36360.037511
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "--- [BinaryCarver] Fit Numerical('Fare') (4/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 0.0000e+000.00000.01358
0.0000e+00 < x <= 6.8583e+000.00000.01358
6.8583e+00 < x <= 7.0500e+000.11110.01529
7.0500e+00 < x <= 7.2250e+000.21430.023614
7.2250e+00 < x <= 7.2292e+000.27270.018511
7.2292e+00 < x <= 7.2500e+000.09090.018511
7.2500e+00 < x <= 7.6500e+000.22220.01529
7.6500e+00 < x <= 7.7500e+000.38710.052231
7.7500e+00 < x <= 7.7750e+000.33330.01529
7.7750e+00 < x <= 7.8292e+000.40000.00845
7.8292e+00 < x <= 7.8542e+000.30000.016810
7.8542e+00 < x <= 7.8875e+000.80000.00845
7.8875e+00 < x <= 7.8958e+000.00000.038723
7.8958e+00 < x <= 8.0292e+000.50000.026916
8.0292e+00 < x <= 8.0500e+000.09680.052231
8.0500e+00 < x <= 8.4583e+000.00000.00513
8.4583e+00 < x <= 8.6625e+000.11110.01529
8.6625e+00 < x <= 9.3500e+000.28570.01187
9.3500e+00 < x <= 9.5000e+000.33330.01016
9.5000e+00 < x <= 1.0500e+010.36840.032019
1.0500e+01 < x <= 1.2287e+010.62500.01358
1.2287e+01 < x <= 1.3000e+010.48390.052231
1.3000e+01 < x <= 1.4000e+010.50000.01358
1.4000e+01 < x <= 1.4458e+010.11110.01529
1.4458e+01 < x <= 1.5100e+010.33330.01016
1.5100e+01 < x <= 1.5550e+010.12500.01358
1.5550e+01 < x <= 1.6100e+010.55560.01529
1.6100e+01 < x <= 1.8750e+010.62500.01358
1.8750e+01 < x <= 1.9500e+011.00000.00845
1.9500e+01 < x <= 2.1000e+010.11110.01529
2.1000e+01 < x <= 2.3000e+010.62500.01358
2.3000e+01 < x <= 2.4150e+010.37500.01358
2.4150e+01 < x <= 2.6000e+010.32140.047128
2.6000e+01 < x <= 2.6387e+010.80000.016810
2.6387e+01 < x <= 2.6550e+010.33330.01529
2.6550e+01 < x <= 2.7900e+010.25000.020212
2.7900e+01 < x <= 2.9000e+010.66670.00513
2.9000e+01 < x <= 3.0000e+010.40000.016810
3.0000e+01 < x <= 3.0696e+010.33330.01016
3.0696e+01 < x <= 3.1387e+010.33330.01529
3.1387e+01 < x <= 3.3500e+010.40000.00845
3.3500e+01 < x <= 3.7004e+010.25000.01358
3.7004e+01 < x <= 3.9600e+010.62500.01358
3.9600e+01 < x <= 4.1579e+010.28570.01187
4.1579e+01 < x <= 4.6900e+010.00000.01187
4.6900e+01 < x <= 5.1862e+010.28570.01187
5.1862e+01 < x <= 5.2554e+010.71430.01187
5.2554e+01 < x <= 5.6496e+010.72730.018511
5.6496e+01 < x <= 5.7979e+011.00000.00674
5.7979e+01 < x <= 6.9550e+010.36360.018511
6.9550e+01 < x <= 7.3500e+010.16670.01016
7.3500e+01 < x <= 7.7287e+010.66670.01016
7.7287e+01 < x <= 7.9650e+010.75000.01358
7.9650e+01 < x <= 8.3158e+010.85710.01187
8.3158e+01 < x <= 9.0000e+010.85710.01187
9.0000e+01 < x <= 1.1088e+020.71430.01187
1.1088e+02 < x <= 1.3365e+020.85710.01187
1.3365e+02 < x <= 1.5155e+020.88890.01529
1.5155e+02 < x <= 2.1134e+020.85710.01187
2.1134e+02 < x0.57140.01187
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.14290.02397
0.00000.00682
0.00000.00682
0.20000.01715
0.25000.01374
0.00000.00682
0.20000.01715
0.27270.037511
0.00000.02397
0.40000.01715
0.00000.01023
0.00000.00341
0.07690.044413
0.33330.01023
0.16670.041012
0.20000.01715
0.16670.02056
0.00000.01023
0.00000.01715
0.26670.051215
0.40000.01715
0.38100.071721
1.00000.00341
0.00000.01374
0.00000.01715
1.00000.01715
0.50000.034110
0.33330.01023
0.66670.01023
0.62500.02738
0.40000.01715
0.16670.02056
0.72730.037511
1.00000.00341
0.83330.02056
0.20000.01715
0.00000.00341
0.50000.01374
1.00000.01023
0.40000.01715
1.00000.00341
0.42860.02397
nan0.00000
0.00000.01023
nan0.00000
1.00000.00682
0.33330.01023
0.66670.02056
1.00000.00682
0.42860.02397
0.50000.00682
1.00000.00341
0.66670.02056
1.00000.00341
0.75000.01374
0.80000.01715
1.00000.00682
0.00000.00682
1.00000.00341
0.70000.034110
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 5.2e+010.31840.8249490
5.2e+01 < x0.70190.1751104
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.32780.8225241
0.65380.177552
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "--- [BinaryCarver] Fit Numerical('Siblings/Spouses Aboard') (5/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 0.00e+000.36140.6801404
0.00e+00 < x <= 1.00e+000.50000.2323138
1.00e+00 < x <= 2.00e+000.55000.033720
2.00e+00 < x <= 3.00e+000.11110.01529
3.00e+00 < x <= 4.00e+000.16670.020212
4.00e+00 < x0.00000.018511
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.32000.6826200
0.60560.242371
0.25000.02738
0.42860.02397
0.16670.02056
0.00000.00341
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 0.00e+000.36140.6801404
0.00e+00 < x <= 2.00e+000.50630.2660158
2.00e+00 < x0.09380.053932
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.32000.6826200
0.56960.269679
0.28570.047814
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "--- [BinaryCarver] Fit Numerical('Parents/Children Aboard') (6/6)\n", " [BinaryCarver] Raw distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 0.00e+000.34470.7374438
0.00e+00 < x <= 1.00e+000.50570.146587
1.00e+00 < x <= 2.00e+000.51670.101060
2.00e+00 < x0.33330.01529
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.34750.8055236
0.67740.105831
0.45000.068320
0.16670.02056
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " [BinaryCarver] Carved distribution\n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X distribution
 target_meanfrequencycount
x <= 0.0e+000.34470.7374438
0.0e+00 < x0.50000.2626156
\n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_dev distribution
target_meanfrequencycount
0.34750.8055236
0.54390.194557
\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from AutoCarver import BinaryCarver\n", "from AutoCarver.discretizers.utils.base_discretizer import ProcessingConfig\n", "\n", "# intiating AutoCarver\n", "auto_carver = BinaryCarver(\n", " features=features,\n", " min_freq=min_freq,\n", " max_n_mod=max_n_mod,\n", " config=ProcessingConfig(dropna=dropna, verbose=True, copy=True, ordinal_encoding=True),\n", ")\n", "\n", "# fitting on training sample, a dev sample can be specified to evaluate carving robustness\n", "train_set_processed = auto_carver.fit_transform(train_set, train_set[target], X_dev=dev_set, y_dev=dev_set[target])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## AutoCarver analysis\n", "\n", "### Carving Summary" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
contenttarget_meanfrequencydroppeddropped_reason
featurecounttschuprowtn_modlabel
Categorical('Sex')378.00.53371920male0.1878310.636364FalseNone
216.00.53371921female0.7314810.363636FalseNone
Ordinal('Pclass')268.00.30014420[2, 1]0.5485070.451178FalseNone
326.00.3001442130.2515340.548822FalseNone
Numerical('Age')37.00.16104530x <= 6.00e+000.7027030.062290FalseNone
535.00.161045316.00e+00 < x <= 5.80e+010.3738320.900673FalseNone
22.00.161045325.80e+01 < x0.1363640.037037FalseNone
Numerical('Fare')490.00.29493720x <= 5.2e+010.3183670.824916FalseNone
104.00.294937215.2e+01 < x0.7019230.175084FalseNone
Numerical('Siblings/Spouses Aboard')404.00.16266330x <= 0.00e+000.3613860.680135FalseNone
158.00.162663310.00e+00 < x <= 2.00e+000.5063290.265993FalseNone
32.00.162663322.00e+00 < x0.0937500.053872FalseNone
Numerical('Parents/Children Aboard')438.00.13643920x <= 0.0e+000.3447490.737374FalseNone
156.00.136439210.0e+00 < x0.5000000.262626FalseNone
\n", "
" ], "text/plain": [ " content \\\n", "feature count tschuprowt n_mod label \n", "Categorical('Sex') 378.0 0.533719 2 0 male \n", " 216.0 0.533719 2 1 female \n", "Ordinal('Pclass') 268.0 0.300144 2 0 [2, 1] \n", " 326.0 0.300144 2 1 3 \n", "Numerical('Age') 37.0 0.161045 3 0 x <= 6.00e+00 \n", " 535.0 0.161045 3 1 6.00e+00 < x <= 5.80e+01 \n", " 22.0 0.161045 3 2 5.80e+01 < x \n", "Numerical('Fare') 490.0 0.294937 2 0 x <= 5.2e+01 \n", " 104.0 0.294937 2 1 5.2e+01 < x \n", "Numerical('Siblings/Spouses Aboard') 404.0 0.162663 3 0 x <= 0.00e+00 \n", " 158.0 0.162663 3 1 0.00e+00 < x <= 2.00e+00 \n", " 32.0 0.162663 3 2 2.00e+00 < x \n", "Numerical('Parents/Children Aboard') 438.0 0.136439 2 0 x <= 0.0e+00 \n", " 156.0 0.136439 2 1 0.0e+00 < x \n", "\n", " target_mean \\\n", "feature count tschuprowt n_mod label \n", "Categorical('Sex') 378.0 0.533719 2 0 0.187831 \n", " 216.0 0.533719 2 1 0.731481 \n", "Ordinal('Pclass') 268.0 0.300144 2 0 0.548507 \n", " 326.0 0.300144 2 1 0.251534 \n", "Numerical('Age') 37.0 0.161045 3 0 0.702703 \n", " 535.0 0.161045 3 1 0.373832 \n", " 22.0 0.161045 3 2 0.136364 \n", "Numerical('Fare') 490.0 0.294937 2 0 0.318367 \n", " 104.0 0.294937 2 1 0.701923 \n", "Numerical('Siblings/Spouses Aboard') 404.0 0.162663 3 0 0.361386 \n", " 158.0 0.162663 3 1 0.506329 \n", " 32.0 0.162663 3 2 0.093750 \n", "Numerical('Parents/Children Aboard') 438.0 0.136439 2 0 0.344749 \n", " 156.0 0.136439 2 1 0.500000 \n", "\n", " frequency \\\n", "feature count tschuprowt n_mod label \n", "Categorical('Sex') 378.0 0.533719 2 0 0.636364 \n", " 216.0 0.533719 2 1 0.363636 \n", "Ordinal('Pclass') 268.0 0.300144 2 0 0.451178 \n", " 326.0 0.300144 2 1 0.548822 \n", "Numerical('Age') 37.0 0.161045 3 0 0.062290 \n", " 535.0 0.161045 3 1 0.900673 \n", " 22.0 0.161045 3 2 0.037037 \n", "Numerical('Fare') 490.0 0.294937 2 0 0.824916 \n", " 104.0 0.294937 2 1 0.175084 \n", "Numerical('Siblings/Spouses Aboard') 404.0 0.162663 3 0 0.680135 \n", " 158.0 0.162663 3 1 0.265993 \n", " 32.0 0.162663 3 2 0.053872 \n", "Numerical('Parents/Children Aboard') 438.0 0.136439 2 0 0.737374 \n", " 156.0 0.136439 2 1 0.262626 \n", "\n", " dropped \\\n", "feature count tschuprowt n_mod label \n", "Categorical('Sex') 378.0 0.533719 2 0 False \n", " 216.0 0.533719 2 1 False \n", "Ordinal('Pclass') 268.0 0.300144 2 0 False \n", " 326.0 0.300144 2 1 False \n", "Numerical('Age') 37.0 0.161045 3 0 False \n", " 535.0 0.161045 3 1 False \n", " 22.0 0.161045 3 2 False \n", "Numerical('Fare') 490.0 0.294937 2 0 False \n", " 104.0 0.294937 2 1 False \n", "Numerical('Siblings/Spouses Aboard') 404.0 0.162663 3 0 False \n", " 158.0 0.162663 3 1 False \n", " 32.0 0.162663 3 2 False \n", "Numerical('Parents/Children Aboard') 438.0 0.136439 2 0 False \n", " 156.0 0.136439 2 1 False \n", "\n", " dropped_reason \n", "feature count tschuprowt n_mod label \n", "Categorical('Sex') 378.0 0.533719 2 0 None \n", " 216.0 0.533719 2 1 None \n", "Ordinal('Pclass') 268.0 0.300144 2 0 None \n", " 326.0 0.300144 2 1 None \n", "Numerical('Age') 37.0 0.161045 3 0 None \n", " 535.0 0.161045 3 1 None \n", " 22.0 0.161045 3 2 None \n", "Numerical('Fare') 490.0 0.294937 2 0 None \n", " 104.0 0.294937 2 1 None \n", "Numerical('Siblings/Spouses Aboard') 404.0 0.162663 3 0 None \n", " 158.0 0.162663 3 1 None \n", " 32.0 0.162663 3 2 None \n", "Numerical('Parents/Children Aboard') 438.0 0.136439 2 0 None \n", " 156.0 0.136439 2 1 None " ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "auto_carver.summary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* For quantitative feature ``Age``, the selected combination of modalities groups ages as follows:\n", " * modality ``0``: lower or equal to 8 years old (``content=\"x <= 8.0+00\"``)\n", " * modality ``1``: ages higher than 8 years old (``content=\"8.0+00 < x \"``)\n", "\n", "* For qualitative categorical feature ``Sex``, the selected combination of modalities has left modalities ``content=\"male\"`` in modality ``0`` and ``content=\"female\"`` in modality ``1`` (no combination possible)\n", "\n", "* For qualitative ordinal feature ``Pclass``, the selected combination of modalities socio-economic status as follows:\n", " * modality ``0``: upper and middle classes (``content=[2, 1]``) \n", " * modality ``1``: lower class (``content=3``). \n", " * The user-provided ordering of modalities has been preserved." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Detailed overview of tested combinations" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
infocramervtschuprowtcombinationn_moddropnatrainviabledev
0Raw distribution0.3210440.269965{'1': '1', '2': '2', '3': '3'}3FalseNaNNaNNaN
1Best for tschuprowt and max_n_mod=50.3001440.300144{'1': '1', '2': '1', '3': '3'}2False{'viable': True, 'info': ''}True{'viable': True, 'info': ''}
\n", "
" ], "text/plain": [ " info cramerv tschuprowt \\\n", "0 Raw distribution 0.321044 0.269965 \n", "1 Best for tschuprowt and max_n_mod=5 0.300144 0.300144 \n", "\n", " combination n_mod dropna \\\n", "0 {'1': '1', '2': '2', '3': '3'} 3 False \n", "1 {'1': '1', '2': '1', '3': '3'} 2 False \n", "\n", " train viable dev \n", "0 NaN NaN NaN \n", "1 {'viable': True, 'info': ''} True {'viable': True, 'info': ''} " ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "features[\"Pclass\"].history" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* The most associated combination (the first tested out, where ``info!=\"Raw distribution\"``) groups ``Pclass==1`` with ``Pclass==2`` and leaves ``Pclass==3`` as its own modality\n", "\n", "* For feature ``Pclass``, the 1st combination passes the tests:\n", " - ``viable=True``\n", " - ``info=\"Best for tschuprowt and max_n_mod=5\"``\n", " - Tschuprow's T with ``Survived`` is ``0.300144`` for this combination (by default, combinations are ranked according to this statistic)\n", " - Following combinations (less associated with the target) where not tested: ``info=\"Not checked\"``\n", "\n", "* For all combinations ``dropna=False`` means that it is not a combination in which ``nan``s are being grouped with other modalities (as requested with ``dropna=False``)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Saving and Loading AutoCarver\n", "### Saving\n", "\n", "All **Carvers** can safely be stored as a .json file." ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "auto_carver.save(\"binary_carver.json\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Loading\n", "\n", "**Carvers** can safely be loaded from a .json file." ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "auto_carver = BinaryCarver.load(\"binary_carver.json\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Applying AutoCarver" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "dev_set_processed = auto_carver.transform(dev_set)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SexPclassAgeFareSiblings/Spouses AboardParents/Children Aboard
0.00.6655290.4505120.0511950.8225260.6825940.805461
1.00.3344710.5494880.9112630.1774740.2696250.194539
2.0NaNNaN0.037543NaN0.047782NaN
\n", "
" ], "text/plain": [ " Sex Pclass Age Fare Siblings/Spouses Aboard \\\n", "0.0 0.665529 0.450512 0.051195 0.822526 0.682594 \n", "1.0 0.334471 0.549488 0.911263 0.177474 0.269625 \n", "2.0 NaN NaN 0.037543 NaN 0.047782 \n", "\n", " Parents/Children Aboard \n", "0.0 0.805461 \n", "1.0 0.194539 \n", "2.0 NaN " ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dev_set_processed[auto_carver.features].apply(lambda u: u.value_counts(dropna=False, normalize=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Feature Selection\n", "## Selectors settings\n", "### Features to select from\n", "\n", "Here all features have been carved using ``BinaryCarver``, hence all features are qualitative.\n", "\n", "### Number of features to select\n", "\n", "The attribute ``n_best_per_type`` allows one to choose the number of features to be selected per data type (quantitative and qualitative)." ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "n_best_per_type = 4 # here the number of features is low, ClassificationSelector will only be used to compute useful statistics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using Selectors" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " [ClassificationSelector] Selected Qualitative Features \n" ] }, { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 featureNanModeTschuprowtMeasureTschuprowtRankTschuprowtFilterTschuprowtWith
0Categorical('Sex')0.00000.63640.53730.00000.0000itself
1Ordinal('Pclass')0.00000.54880.30361.00000.0988Sex
3Numerical('Fare')0.00000.82490.29952.00000.4057Pclass
4Numerical('Siblings/Spouses Aboard')0.00000.68010.16273.00000.2383Pclass
2Numerical('Age')0.00000.90070.16104.00000.2576Siblings/Spouses Aboard
5Numerical('Parents/Children Aboard')0.00000.73740.14045.00000.4257Siblings/Spouses Aboard
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "Features(['Sex', 'Pclass', 'Fare', 'Siblings/Spouses Aboard'])" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from AutoCarver import ClassificationSelector\n", "from AutoCarver.discretizers.utils.base_discretizer import ProcessingConfig\n", "\n", "# select the most target associated qualitative features\n", "feature_selector = ClassificationSelector(\n", " features=features,\n", " n_best_per_type=n_best_per_type,\n", " config=ProcessingConfig(verbose=True), # displays statistics\n", ")\n", "best_features = feature_selector.fit(train_set_processed, train_set_processed[target]).selected_features\n", "best_features" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SexPclassFareSiblings/Spouses Aboard
617010.01
489000.00
871110.00
654110.01
653010.00
\n", "
" ], "text/plain": [ " Sex Pclass Fare Siblings/Spouses Aboard\n", "617 0 1 0.0 1\n", "489 0 0 0.0 0\n", "871 1 1 0.0 0\n", "654 1 1 0.0 1\n", "653 0 1 0.0 0" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_set_processed[best_features].head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* Feature ``Sex`` is the most associated with the target ``Survived``:\n", " - Tschuprow's T value is ``TschuprowtMeasure=0.5337``\n", " - It has 0 % of NaNs (``NaNMeasure=0.0``) \n", " - Its mode represents 64 % of observed data (``ModeMeasure=0.6364``)\n", "\n", "* Feature ``Fare`` is strongly associated to feature ``Pclass``:\n", " - Tschuprow's T value is ``TschuprowtFilter=0.3922`` with ``TschuprowtWith=Pclass``\n", "\n", "* Here, no feature where filtered out for there inter-feature association or over-represented values (no thresholds were set)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Modeling\n", "Fitting model on train data" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SexPclassFareSiblings/Spouses Aboard
0.0378.0268.0490.0404
1.0216.0326.0104.0158
2.0NaNNaNNaN32
\n", "
" ], "text/plain": [ " Sex Pclass Fare Siblings/Spouses Aboard\n", "0.0 378.0 268.0 490.0 404\n", "1.0 216.0 326.0 104.0 158\n", "2.0 NaN NaN NaN 32" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_set_processed[best_features].apply(lambda u: u.value_counts())" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
XGBClassifier(base_score=None, booster=None, callbacks=None,\n",
       "              colsample_bylevel=None, colsample_bynode=None,\n",
       "              colsample_bytree=None, device=None, early_stopping_rounds=None,\n",
       "              enable_categorical=False, eval_metric=None, feature_types=None,\n",
       "              feature_weights=None, gamma=None, grow_policy=None,\n",
       "              importance_type=None, interaction_constraints=None,\n",
       "              learning_rate=None, max_bin=None, max_cat_threshold=None,\n",
       "              max_cat_to_onehot=None, max_delta_step=None, max_depth=None,\n",
       "              max_leaves=None, min_child_weight=None, missing=nan,\n",
       "              monotone_constraints=None, multi_strategy=None, n_estimators=None,\n",
       "              n_jobs=None, num_parallel_tree=None, ...)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" ], "text/plain": [ "XGBClassifier(base_score=None, booster=None, callbacks=None,\n", " colsample_bylevel=None, colsample_bynode=None,\n", " colsample_bytree=None, device=None, early_stopping_rounds=None,\n", " enable_categorical=False, eval_metric=None, feature_types=None,\n", " feature_weights=None, gamma=None, grow_policy=None,\n", " importance_type=None, interaction_constraints=None,\n", " learning_rate=None, max_bin=None, max_cat_threshold=None,\n", " max_cat_to_onehot=None, max_delta_step=None, max_depth=None,\n", " max_leaves=None, min_child_weight=None, missing=nan,\n", " monotone_constraints=None, multi_strategy=None, n_estimators=None,\n", " n_jobs=None, num_parallel_tree=None, ...)" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from xgboost import XGBClassifier\n", "\n", "model = XGBClassifier()\n", "model.fit(train_set_processed[best_features], train_set_processed[target])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Saving model" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "model.save_model(\"binary_xgboost.json\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Prediction on dev dataset and performance" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.8343903638151425" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sklearn.metrics import roc_auc_score\n", "\n", "dev_pred = model.predict_proba(dev_set_processed[best_features])[:, 1]\n", "roc_auc_score(dev_set_processed[target], dev_pred)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What's next?\n", "\n", "* Thanks to **Carvers** all of your features are now optimally processed for your classification task!\n", "* As a final step towards your model, **Selectors** can prove to be handy tools to operate target optimal Data Pre-Selection, so make sure to check out [Selectors Examples](https://autocarver.readthedocs.io/en/latest/selectors_examples.html)!\n", "\n", "## Well done!\n", "\n", "Your commitment to achieving optimal results in binary classification tasks shines through in your meticulous use of **AutoCarver**'s ``BinaryCarver`` for data preprocessing. By fine-tuning and optimizing your dataset, you have set the stage for robust and accurate machine learning models.\n", "\n", "The ``BinaryCarver`` has proven to be a valuable ally in your pursuit of excellence, carving out a path toward enhanced feature representation and model interpretability. Your dedication to refining the data preprocessing steps reflects a commitment to extracting the maximum value from your datasets.\n", "\n", "We extend our sincere appreciation for choosing **AutoCarver** as your companion in the data preprocessing journey. Your use of **AutoCarver** demonstrates a dedication to leveraging cutting-edge tools for achieving excellence in binary classification tasks.\n", "\n", "As you transition to the modeling phase, may the carefully crafted features and preprocessing steps contribute to the success of your predictive models. We're excited to see the impact of your work and are grateful for the opportunity to be part of your data science endeavors.\n", "\n", "Thank you for trusting **AutoCarver**, and we wish you continued success in your data-driven ventures." ] } ], "metadata": { "kernelspec": { "display_name": "AutoCarver", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.15" } }, "nbformat": 4, "nbformat_minor": 2 }