From b534b422e9d82395bacdbdb46f9e55a8e13c0af5 Mon Sep 17 00:00:00 2001
From: wengJJ <31797645+wengJJ@users.noreply.github.com>
Date: Tue, 7 Aug 2018 12:37:09 +0800
Subject: [PATCH] Update Day 11 K-NN.md
---
Code/Day 11 K-NN.md | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/Code/Day 11 K-NN.md b/Code/Day 11 K-NN.md
index 2afaa1a..61375e4 100644
--- a/Code/Day 11 K-NN.md
+++ b/Code/Day 11 K-NN.md
@@ -1,54 +1,54 @@
-# K-Nearest Neighbors (K-NN)
+# K近邻法 (K-NN)
-
+
-## The DataSet | Social Network
+## 数据集 | 社交网络
-## Importing the libraries
+## 导入相关库
```python
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
```
-## Importing the dataset
+## 导入数据集
```python
dataset = pd.read_csv('Social_Network_Ads.csv')
X = dataset.iloc[:, [2, 3]].values
y = dataset.iloc[:, 4].values
```
-## Splitting the dataset into the Training set and Test set
+## 将数据划分成训练集和测试集
```python
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)
```
-## Feature Scaling
+## 特征缩放
```python
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
```
-## Fitting K-NN to the Training set
+## 使用K-NN对训练集数据进行训练
```python
from sklearn.neighbors import KNeighborsClassifier
classifier = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p = 2)
classifier.fit(X_train, y_train)
```
-## Predicting the Test set results
+## 对测试集进行预测
```python
y_pred = classifier.predict(X_test)
```
-## Making the Confusion Matrix
+## 生成混淆矩阵
```python
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)