Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent args and base transformers #168

Merged
merged 7 commits into from
Feb 21, 2024
120 changes: 13 additions & 107 deletions examples/base/BaseTransformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"data": {
"text/plain": [
"'0.3.0'"
"'1.1.1'"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -223,9 +223,7 @@
"collapsed": true
},
"source": [
"## Initialising BaseTransformer\n",
"### Not setting columns \n",
"Columns do not have to be specified when initialising BaseTransformer objects. Both the fit and transform methods call the columns_set_or_check to ensure that columns is set before the transformer has to do any work."
"## Initialising BaseTransformer\n"
]
},
{
Expand All @@ -242,7 +240,7 @@
}
],
"source": [
"base_1 = BaseTransformer(copy=True, verbose=True)"
"base_1 = BaseTransformer(columns=\"HouseAge\", copy=True, verbose=True)"
]
},
{
Expand All @@ -252,85 +250,7 @@
},
"source": [
"## BaseTransformer fit\n",
"Not all transformers in the package will implement a fit method, if the user directly specifies the values the transformer needs e.g. passes the impute value, there is no need for it.\n",
"### Setting columns in fit\n",
"If the columns attribute is not set when fit is called, columns_set_or_check will set columns to be all columns in X."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"base_1.columns is None"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BaseTransformer.fit() called\n"
]
},
{
"data": {
"text/plain": [
"BaseTransformer(columns=['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms',\n",
" 'Population', 'AveOccup', 'Latitude', 'Longitude'],\n",
" verbose=True)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"base_1.fit(cali_df)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['MedInc',\n",
" 'HouseAge',\n",
" 'AveRooms',\n",
" 'AveBedrms',\n",
" 'Population',\n",
" 'AveOccup',\n",
" 'Latitude',\n",
" 'Longitude']"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"base_1.columns"
"Not all transformers in the package will implement a fit method, if the user directly specifies the values the transformer needs e.g. passes the impute value, there is no need for it.\n"
]
},
{
Expand All @@ -345,7 +265,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -362,7 +282,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -371,7 +291,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -380,7 +300,7 @@
"False"
]
},
"execution_count": 13,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -399,7 +319,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -416,7 +336,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand All @@ -434,7 +354,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand All @@ -443,7 +363,7 @@
"True"
]
},
"execution_count": 16,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -473,20 +393,6 @@
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -511,7 +417,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.11"
"version": "3.8.17"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading