Browse Source

1203

master
苏斌 3 years ago
parent
commit
af833872f2
9 changed files with 11835 additions and 11770 deletions
  1. +64
    -0
      Ex2.2.ipynb
  2. +78
    -0
      KMeans.ipynb
  3. +76
    -0
      KNN.ipynb
  4. +133
    -0
      Matplotlib.ipynb
  5. +1482
    -0
      Regression/Employee Attrition Prediction-LinearRegression.ipynb
  6. +3001
    -0
      Regression/Test_Employee.csv
  7. +7001
    -0
      Regression/Train_Employee.csv
  8. +0
    -10000
      [Dataset]_Module11_(Recommendation).csv
  9. +0
    -1770
      [Notebook - Facilitator] Module 11 (Recommendation System).ipynb

+ 64
- 0
Ex2.2.ipynb View File

@ -0,0 +1,64 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 实验2:What is Python?\n",
"#### 【知识点】Python是一种通用编码语言,可以用来构建各类程序。由于其具有大量功能强大且易于使用的库,Python在AI开发中得到广泛使用。\n",
"## 【实验目标】掌握编程环境,及基本编程方法。\n",
"#### 使用水杉平台的在线JupyterHub,它是基于Jupyter Notebook的多人在线代码编辑平台。\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"number=1\n",
"number"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

+ 78
- 0
KMeans.ipynb View File

@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 聚类效果怎么样?"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"the predicted result:\n",
" [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
" 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
" 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 0 0 0 0 2 0 0 0 0\n",
" 0 0 2 2 0 0 0 0 2 0 2 0 2 0 0 2 2 0 0 0 0 0 2 0 0 0 0 2 0 0 0 2 0 0 0 2 0\n",
" 0 2]\n",
"the real answer:\n",
" [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2\n",
" 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
" 2 2]\n"
]
}
],
"source": [
"from sklearn import datasets\n",
"from sklearn.cluster import KMeans\n",
"iris = datasets.load_iris()\n",
"X = iris.data\n",
"y = iris.target #保留标签\n",
"clf=KMeans(n_clusters=3)\n",
"model=clf.fit(X)\n",
"predicted=model.predict(X)\n",
"\n",
"#补充程序,显示如下的运行结果,并将预测值与标签真值进行对比\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

+ 76
- 0
KNN.ipynb View File

@ -0,0 +1,76 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"数据集结构: (150, 4)\n",
"测试集大小: (30, 4)\n",
"真实结果: [2 1 0 2 0 2 0 1 1 1 2 1 1 1 1 0 1 1 0 0 2 1 0 0 2 0 0 1 1 0]\n",
"预测结果: [2 1 0 2 0 2 0 1 1 1 2 1 1 1 2 0 1 1 0 0 2 1 0 0 2 0 0 1 1 0]\n",
"预测精确率: 0.9666666666666667\n"
]
}
],
"source": [
"from sklearn import datasets\n",
"from sklearn.neighbors import KNeighborsClassifier\n",
"from sklearn.model_selection import train_test_split\n",
"#导入鸢尾花数据并查看数据特征\n",
"iris = datasets.load_iris()\n",
"print('数据集结构:',iris.data.shape)\n",
"# 获取属性\n",
"iris_X = iris.data\n",
"# 获取类别\n",
"iris_y = iris.target\n",
"# 划分成测试集和训练集\n",
"iris_train_X,iris_test_X,iris_train_y,iris_test_y=train_test_split(iris_X,iris_y,test_size=0.2, random_state=0)\n",
"#分类器初始化\n",
"knn = KNeighborsClassifier()\n",
"#对训练集进行训练\n",
"knn.fit(iris_train_X, iris_train_y)\n",
"#对测试集数据的鸢尾花类型进行预测\n",
"predict_result = knn.predict(iris_test_X)\n",
"\n",
"#补充程序,显示下面的程序结果\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

+ 133
- 0
Matplotlib.ipynb
File diff suppressed because it is too large
View File


+ 1482
- 0
Regression/Employee Attrition Prediction-LinearRegression.ipynb
File diff suppressed because it is too large
View File


+ 3001
- 0
Regression/Test_Employee.csv
File diff suppressed because it is too large
View File


+ 7001
- 0
Regression/Train_Employee.csv
File diff suppressed because it is too large
View File


+ 0
- 10000
[Dataset]_Module11_(Recommendation).csv
File diff suppressed because it is too large
View File


+ 0
- 1770
[Notebook - Facilitator] Module 11 (Recommendation System).ipynb
File diff suppressed because it is too large
View File


Loading…
Cancel
Save