Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions tasks/variance-threshold/Experiment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"outputs": [],
"source": [
"# parameters\n",
"dataset = \"/tmp/data/boston.csv\" #@param {type:\"string\"}\n",
"target = \"medv\" #@param {type:\"feature\", label:\"Atributo alvo\", description: \"Esse valor será utilizado para garantir que o alvo não seja removido.\"}\n",
"dataset = \"/tmp/data/Iris-2.csv\" #@param {type:\"string\"}\n",
"target = \"\" #@param {type:\"feature\", label:\"Atributo alvo\", description: \"Esse valor será utilizado para garantir que o alvo não seja removido.\"}\n",
"\n",
"# hyperparameters\n",
"threshold = 0.0 #@param {type:\"number\", label:\"Limiar\", description:\"Atributos com variância menor que o limiar serão removidos.\"}"
"threshold = 2 #@param {type:\"number\", label:\"Limiar\", description:\"Atributos com variância menor que o limiar serão removidos.\"}\n"
]
},
{
Expand Down Expand Up @@ -201,6 +201,15 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_after = df.copy()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -214,6 +223,28 @@
" df[target] = y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def description():\n",
" \n",
" new_df = pd.DataFrame({'Columns':[], 'Removed':[], 'Variance':[]})\n",
"\n",
" for column in columns:\n",
" if column in df.columns and column in numerical_columns:\n",
" new_df.loc[len(new_df)] = [column, 'No', df[column].var()]\n",
"\n",
" elif column in numerical_columns:\n",
" new_df.loc[len(new_df)] = [column, 'Yes', df_after[column].var()]\n",
" else:\n",
" new_df.loc[len(new_df)] = [column, 'text_column', \"text_column_no_variance\"]\n",
"\n",
" return new_df"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -237,6 +268,17 @@
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ax1 = plot_data_table(description())\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -285,8 +327,9 @@
],
"metadata": {
"celltoolbar": "Tags",
"experiment_id": "ee31de81-1d25-4a11-b580-1780f7f29b04",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.8.10 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -300,7 +343,14 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.8.10"
},
"operator_id": "ddabcfe4-209a-4b85-85a2-73902cb267f4",
"task_id": "c3d6cc89-ed2c-48d0-924f-115fa7886fe2",
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
Expand Down