- added relative cluster path in xgboost
- added MAD_Outlier_Remove Function - added MAD_Outlier_Removal to xgboost in extra file
This commit is contained in:
@@ -1,12 +1,40 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e790b157",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Im folgenden wird auf die Daten das MAD Outlier removal angewendet."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f38311af",
|
||||
"id": "4bd7c061",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"from sklearn.preprocessing import StandardScaler, MinMaxScaler\n",
|
||||
"\n",
|
||||
"def mad_outlier_removal(df, columns, threshold=3.5):\n",
|
||||
" \"\"\"\n",
|
||||
" Entfernt Ausreißer basierend auf Median Absolute Deviation (MAD).\n",
|
||||
" threshold: typischer Wert ist 3.5 (entspricht robustem Z-Score Cutoff).\n",
|
||||
" \"\"\"\n",
|
||||
" df_clean = df.copy()\n",
|
||||
" for col in columns:\n",
|
||||
" median = df_clean[col].median()\n",
|
||||
" mad = np.median(np.abs(df_clean[col] - median))\n",
|
||||
" if mad == 0:\n",
|
||||
" continue # keine Streuung, keine Ausreißer\n",
|
||||
" robust_z = 0.6745 * (df_clean[col] - median) / mad\n",
|
||||
" mask = np.abs(robust_z) <= threshold\n",
|
||||
" df_clean = df_clean[mask]\n",
|
||||
" return df_clean"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user