study 100-Days-Of-ML-Code first day
This commit is contained in:
@ -11,6 +11,8 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
|
"搭建anaconda环境,参考 https://zhuanlan.zhihu.com/p/33358809\n",
|
||||||
|
"\n",
|
||||||
"## 第一步:导入需要的库\n",
|
"## 第一步:导入需要的库\n",
|
||||||
"这两个是我们每次都需要导入的库。NumPy包含数学计算函数。Pandas用于导入和管理数据集。"
|
"这两个是我们每次都需要导入的库。NumPy包含数学计算函数。Pandas用于导入和管理数据集。"
|
||||||
]
|
]
|
||||||
@ -18,9 +20,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"collapsed": true
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
@ -63,7 +63,9 @@
|
|||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"dataset = pd.read_csv('../datasets/Data.csv')\n",
|
"dataset = pd.read_csv('../datasets/Data.csv')\n",
|
||||||
|
"# 不包括最后一列的所有列\n",
|
||||||
"X = dataset.iloc[ : , :-1].values\n",
|
"X = dataset.iloc[ : , :-1].values\n",
|
||||||
|
"#取最后一列\n",
|
||||||
"Y = dataset.iloc[ : , 3].values\n",
|
"Y = dataset.iloc[ : , 3].values\n",
|
||||||
"print(\"Step 2: Importing dataset\")\n",
|
"print(\"Step 2: Importing dataset\")\n",
|
||||||
"print(\"X\")\n",
|
"print(\"X\")\n",
|
||||||
@ -108,6 +110,7 @@
|
|||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"from sklearn.preprocessing import Imputer\n",
|
"from sklearn.preprocessing import Imputer\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",
|
||||||
@ -323,7 +326,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.6.2"
|
"version": "3.6.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user