Update Day 1_Data_Preprocessing.ipynb
This commit is contained in:
@ -41,23 +41,10 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
"text": [
|
"text": [
|
||||||
"Step 2: Importing dataset\n",
|
"Step 2: Importing dataset\nX\n[['France' 44.0 72000.0]\n ['Spain' 27.0 48000.0]\n ['Germany' 30.0 54000.0]\n ['Spain' 38.0 61000.0]\n ['Germany' 40.0 nan]\n ['France' 35.0 58000.0]\n ['Spain' nan 52000.0]\n ['France' 48.0 79000.0]\n ['Germany' 50.0 83000.0]\n ['France' 37.0 67000.0]]\nY\n['No' 'Yes' 'No' 'No' 'Yes' 'Yes' 'No' 'Yes' 'No' 'Yes']\n"
|
||||||
"X\n",
|
|
||||||
"[['France' 44.0 72000.0]\n",
|
|
||||||
" ['Spain' 27.0 48000.0]\n",
|
|
||||||
" ['Germany' 30.0 54000.0]\n",
|
|
||||||
" ['Spain' 38.0 61000.0]\n",
|
|
||||||
" ['Germany' 40.0 nan]\n",
|
|
||||||
" ['France' 35.0 58000.0]\n",
|
|
||||||
" ['Spain' nan 52000.0]\n",
|
|
||||||
" ['France' 48.0 79000.0]\n",
|
|
||||||
" ['Germany' 50.0 83000.0]\n",
|
|
||||||
" ['France' 37.0 67000.0]]\n",
|
|
||||||
"Y\n",
|
|
||||||
"['No' 'Yes' 'No' 'No' 'Yes' 'Yes' 'No' 'Yes' 'No' 'Yes']\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -109,12 +96,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"# If you use the newest version of sklearn, use the lines of code commented out",
|
"# If you use the newest version of sklearn, use the lines of code commented out\n",
|
||||||
"# from sklearn.impute import SimpleImputer",
|
"from sklearn.impute import SimpleImputer\n",
|
||||||
"# imputer = SimpleImputer(missing_values=\"NaN\", strategy=\"mean\")",
|
"imputer = SimpleImputer(missing_values=np.nan, strategy=\"mean\")\n",
|
||||||
"from sklearn.preprocessing import Imputer\n",
|
"#from sklearn.preprocessing import Imputer\n",
|
||||||
"# axis=0表示按列进行\n",
|
"# axis=0表示按列进行\n",
|
||||||
"imputer = Imputer(missing_values = \"NaN\", strategy = \"mean\", axis = 0)\n",
|
"#imputer = Imputer(missing_values = \"NaN\", strategy = \"mean\", axis = 0)\n",
|
||||||
"imputer = imputer.fit(X[ : , 1:3])\n",
|
"imputer = imputer.fit(X[ : , 1:3])\n",
|
||||||
"X[ : , 1:3] = imputer.transform(X[ : , 1:3])\n",
|
"X[ : , 1:3] = imputer.transform(X[ : , 1:3])\n",
|
||||||
"print(\"---------------------\")\n",
|
"print(\"---------------------\")\n",
|
||||||
@ -329,9 +316,9 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.6.5"
|
"version": "3.8.3-final"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 2
|
"nbformat_minor": 2
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user