a0fee34
joyvan 6 years ago
11 changed file(s) with 266 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
377377 "metadata": {},
378378 "source": [
379379 "**答案 2**:(在此处填写你的答案。)\n"
380 ]
381 },
382 {
383 "cell_type": "markdown",
384 "metadata": {},
385 "source": [
386 "## 扩展阅读\n",
387 "1. [Introduction to the A* Algorithm](https://www.redblobgames.com/pathfinding/a-star/introduction.html)\n",
388 "2. [游戏开发中的人工智能:A* 路径寻找算法](https://blog.csdn.net/Jurbo/article/details/75532885)\n",
389 "3. [A* Search Algorithm](https://www.101computing.net/a-star-search-algorithm/)\n",
390 "4. [A star Pathfinding A星寻路算法](https://www.bilibili.com/video/av32847834/)"
380391 ]
381392 }
382393 ],
7777 " \"E\": (7, 4), \"F\": (6,6),\"G\": (11,5)}\n",
7878 "\n",
7979 "# 绘制无向图\n",
80 "g = SearchGraph(node_list, weighted_edges_list, 'A', 'F', max_depth=3, nodes_pos = nodes_pos)\n",
80 "g = SearchGraph(node_list, weighted_edges_list, 'A', 'G', max_depth=3, nodes_pos = nodes_pos)\n",
8181 "g.show_graph()"
8282 ]
8383 },
241241 "metadata": {},
242242 "source": [
243243 "需要强调的是,对于一个搜索问题,只要存在答案(即从初始节点到终止节点存在满足条件的一条路径),那么排除了回路的深度优先搜索和广度优先搜索均能找到一个答案,但是这个找到的答案不一定是最优的,例如距离最短。"
244 ]
245 },
246 {
247 "cell_type": "markdown",
248 "metadata": {},
249 "source": [
250 "### 扩展内容\n",
251 "** 深度优先搜索 dfs ** 基础代码解读\n",
252 "\n",
253 "```\n",
254 "def iter_dfs(G, start, target):\n",
255 " '''\n",
256 " 深度优先搜索\n",
257 " :param G: 字典,存储每个点的相邻点\n",
258 " :param start: 初始点\n",
259 " :param target: 目标点\n",
260 " :return:\n",
261 " '''\n",
262 "\n",
263 " # 定义已访问的点的集合\n",
264 " S = set()\n",
265 " # 定义一个待访问点的列表\n",
266 " Q = []\n",
267 " # 把初始点放进列表中\n",
268 " Q.append(start)\n",
269 " while Q:\n",
270 " # 只要带访问的列表不为空,那么从列表中拿取最后一个元素,也就是一个点,记作 u\n",
271 " u = Q.pop()\n",
272 " # 如果当前点是目标点,则结束查找\n",
273 " if u == target:\n",
274 " break\n",
275 " # 如果该点已经被访问了,则跳过此点\n",
276 " if u in S:\n",
277 " continue\n",
278 " # 访问此点,将点加入已访问点的结合 S 中\n",
279 " S.add(u)\n",
280 " # 将点 u 相邻的点放入待访问的列表中\n",
281 " Q.extend(G[u])\n",
282 "```"
244283 ]
245284 },
246285 {
408447 "source": [
409448 "# 查看 dfs 的搜索过程\n",
410449 "h_graph.animation_search_tree('dfs')"
450 ]
451 },
452 {
453 "cell_type": "markdown",
454 "metadata": {},
455 "source": [
456 "## 扩展阅读\n",
457 "1. [Introduction to the A* Algorithm](https://www.redblobgames.com/pathfinding/a-star/introduction.html)\n",
458 "2. [游戏开发中的人工智能:A* 路径寻找算法](https://blog.csdn.net/Jurbo/article/details/75532885)\n",
459 "3. [A* Search Algorithm](https://www.101computing.net/a-star-search-algorithm/)\n",
460 "4. [A star Pathfinding A星寻路算法](https://www.bilibili.com/video/av32847834/)\n",
461 " "
411462 ]
412463 }
413464 ],
921921 "source": [
922922 "**答案 1**:(在此处填写你的答案。)"
923923 ]
924 },
925 {
926 "cell_type": "markdown",
927 "metadata": {},
928 "source": [
929 "## 扩展阅读\n",
930 "\n",
931 "1. [决策树与随机森林](https://www.bilibili.com/video/av26086646?from=search&seid=6716049859412037731)\n",
932 "2. [从决策树到随机森林:树型算法的原理与实现](https://www.jiqizhixin.com/articles/2017-07-31-3)\n",
933 "3. [sklearn 决策树](https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html)"
934 ]
924935 }
925936 ],
926937 "metadata": {
793793 "source": [
794794 "ent = cal_essay_entropy(en_essay, split_by = ' ')\n"
795795 ]
796 },
797 {
798 "cell_type": "markdown",
799 "metadata": {},
800 "source": [
801 "## 扩展阅读\n",
802 "\n",
803 "1. [决策树与随机森林](https://www.bilibili.com/video/av26086646?from=search&seid=6716049859412037731)\n",
804 "2. [从决策树到随机森林:树型算法的原理与实现](https://www.jiqizhixin.com/articles/2017-07-31-3)\n",
805 "3. [sklearn 决策树](https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html)"
806 ]
796807 }
797808 ],
798809 "metadata": {
490490 "plt.plot(x_predict, z_predict, c='b')\n",
491491 "plt.show()"
492492 ]
493 },
494 {
495 "cell_type": "markdown",
496 "metadata": {},
497 "source": [
498 "## 扩展阅读\n",
499 "\n",
500 "1. [线性回归白板推导](https://www.bilibili.com/video/av31989606?from=search&seid=15463936019723788543)\n",
501 "2. [sklearn 线性回归](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html)"
502 ]
493503 }
494504 ],
495505 "metadata": {
511511 "plt.plot(x_predict, z_predict, c='b')\n",
512512 "plt.show()"
513513 ]
514 },
515 {
516 "cell_type": "markdown",
517 "metadata": {},
518 "source": [
519 "## 扩展阅读\n",
520 "\n",
521 "1. [线性回归白板推导](https://www.bilibili.com/video/av31989606?from=search&seid=15463936019723788543)\n",
522 "2. [sklearn 线性回归](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html)"
523 ]
514524 }
515525 ],
516526 "metadata": {
481481 "source": [
482482 "**答案 1**:(在此处填写你的答案。)"
483483 ]
484 },
485 {
486 "cell_type": "markdown",
487 "metadata": {},
488 "source": [
489 "## 扩展阅读\n",
490 "1. [一文读懂概率论学习:贝叶斯理论](https://www.jiqizhixin.com/articles/2019-11-21)\n",
491 "2. [朴素贝叶斯法讲解](https://www.bilibili.com/video/av57126177?from=search&seid=1588787263892359481)\n",
492 "3. [sklearn 贝叶斯方法](https://scikit-learn.org/stable/modules/naive_bayes.html)"
493 ]
484494 }
485495 ],
486496 "metadata": {
467467 "imgs = get_imgs(test_images, test_labels, test_predict_BNB, 9, 4)\n",
468468 "plot_images(imgs)"
469469 ]
470 },
471 {
472 "cell_type": "markdown",
473 "metadata": {},
474 "source": [
475 "## 扩展阅读\n",
476 "1. [一文读懂概率论学习:贝叶斯理论](https://www.jiqizhixin.com/articles/2019-11-21)\n",
477 "2. [朴素贝叶斯法讲解](https://www.bilibili.com/video/av57126177?from=search&seid=1588787263892359481)\n",
478 "3. [sklearn 贝叶斯方法](https://scikit-learn.org/stable/modules/naive_bayes.html)"
479 ]
470480 }
471481 ],
472482 "metadata": {
2424 "cell_type": "markdown",
2525 "metadata": {},
2626 "source": [
27 "人眼在辨识图片时,会先提取边缘特征,再识别部件,最后再得到最高层的模式。也就是说,高层的特征是低层特征的组合,从低层到高层的特征表示越来越抽象,越来越能表现语义。"
28 ]
29 },
30 {
31 "cell_type": "markdown",
32 "metadata": {},
33 "source": [
34 "<img src=\"http://imgbed.momodel.cn//20200103102429.png\" width=300>"
27 "<table>\n",
28 " <tr>\n",
29 " <td ><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133721.png\"/></center></td>\n",
30 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133731.png\"/></center></td>\n",
31 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133746.png\"/></center></td>\n",
32 " </tr>\n",
33 "</table>\n"
34 ]
35 },
36 {
37 "cell_type": "markdown",
38 "metadata": {},
39 "source": [
40 "高层的特征是低层特征的组合,从低层到高层的特征表示越来越抽象,越来越能表现语义。"
41 ]
42 },
43 {
44 "cell_type": "markdown",
45 "metadata": {},
46 "source": [
47 "<table>\n",
48 " <tr>\n",
49 " <td ><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133800.png\" width=600px/></center></td>\n",
50 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133808.png\" width=600px/></center></td>\n",
51 " </tr>\n",
52 "</table>"
53 ]
54 },
55 {
56 "cell_type": "markdown",
57 "metadata": {},
58 "source": [
59 "人工智能中神经网络正是体现“逐层抽象、渐进学习”机制的学习模型。"
60 ]
61 },
62 {
63 "cell_type": "markdown",
64 "metadata": {},
65 "source": [
66 "<img src=\"http://imgbed.momodel.cn/微信图片_20200114133755.png\"/>"
67 ]
68 },
69 {
70 "cell_type": "markdown",
71 "metadata": {},
72 "source": [
73 "人眼在辨识图片时,会先提取边缘特征,再识别部件,最后再得到最高层的模式。"
74 ]
75 },
76 {
77 "cell_type": "markdown",
78 "metadata": {},
79 "source": [
80 "<img src=\"http://imgbed.momodel.cn//20200103102429.png\" width=500>"
3581 ]
3682 },
3783 {
4793 "source": [
4894 "**感知机模型**:\n",
4995 "\n",
50 "<img src=\"http://imgbed.momodel.cn/感知器模型.png\" width=300/>"
96 "<table>\n",
97 " <tr>\n",
98 " <td ><center><img src=\"http://imgbed.momodel.cn/感知器模型.png\" width=400/></center></td>\n",
99 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114135559.png\" width=400/>\n",
100 " <img src=\"http://imgbed.momodel.cn/微信图片_20200114135643.png\" width=400/></center></td>\n",
101 " </tr>\n",
102 "</table>"
51103 ]
52104 },
53105 {
214266 "\n",
215267 "与感知机的不同,神经网络:\n",
216268 "+ 输入层和输出层之间存在若干隐藏层。\n",
217 "+ 每个隐藏层中包含若干神经元。\n"
269 "+ 每个隐藏层中包含若干神经元。\n",
270 "\n",
271 "神经网络流程:\n",
272 "<center><video src=\"https://files.momodel.cn/media1.mp4\" controls=\"controls\" width=800px></center>\n",
273 "<center><video src=\"https://files.momodel.cn/media2.mp4\" controls=\"controls\" width=800px></center>\n",
274 "<center><video src=\"https://files.momodel.cn/media3.mp4\" controls=\"controls\" width=800px></center>\n",
275 "<center><video src=\"https://files.momodel.cn/media4.mp4\" controls=\"controls\" width=800px></center>\n",
276 "<center><video src=\"https://files.momodel.cn/media5.mp4\" controls=\"controls\" width=800px></center>\n",
277 "<center><video src=\"https://files.momodel.cn/media6.mp4\" controls=\"controls\" width=800px></center>\n"
218278 ]
219279 },
220280 {
2424 "cell_type": "markdown",
2525 "metadata": {},
2626 "source": [
27 "人眼在辨识图片时,会先提取边缘特征,再识别部件,最后再得到最高层的模式。也就是说,高层的特征是低层特征的组合,从低层到高层的特征表示越来越抽象,越来越能表现语义。"
28 ]
29 },
30 {
31 "cell_type": "markdown",
32 "metadata": {},
33 "source": [
34 "<img src=\"http://imgbed.momodel.cn//20200103102429.png\" width=300>"
27 "<table>\n",
28 " <tr>\n",
29 " <td ><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133721.png\"/></center></td>\n",
30 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133731.png\"/></center></td>\n",
31 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133746.png\"/></center></td>\n",
32 " </tr>\n",
33 "</table>\n"
34 ]
35 },
36 {
37 "cell_type": "markdown",
38 "metadata": {},
39 "source": [
40 "<table>\n",
41 " <tr>\n",
42 " <td ><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133800.png\" width=600px/></center></td>\n",
43 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114133808.png\" width=600px/></center></td>\n",
44 " </tr>\n",
45 "</table>"
46 ]
47 },
48 {
49 "cell_type": "markdown",
50 "metadata": {},
51 "source": [
52 "高层的特征是低层特征的组合,从低层到高层的特征表示越来越抽象,越来越能表现语义。\n"
53 ]
54 },
55 {
56 "cell_type": "markdown",
57 "metadata": {},
58 "source": [
59 "人工智能中神经网络正是体现“逐层抽象、渐进学习”机制的学习模型。"
60 ]
61 },
62 {
63 "cell_type": "markdown",
64 "metadata": {},
65 "source": [
66 "<img src=\"http://imgbed.momodel.cn/微信图片_20200114133755.png\"/>\n"
67 ]
68 },
69 {
70 "cell_type": "markdown",
71 "metadata": {},
72 "source": [
73 "人眼在辨识图片时,会先提取边缘特征,再识别部件,最后再得到最高层的模式。"
74 ]
75 },
76 {
77 "cell_type": "markdown",
78 "metadata": {},
79 "source": [
80 "<img src=\"http://imgbed.momodel.cn//20200103102429.png\" width=500>"
3581 ]
3682 },
3783 {
4793 "source": [
4894 "**感知机模型**:\n",
4995 "\n",
50 "<img src=\"http://imgbed.momodel.cn/感知器模型.png\" width=300/>"
96 "<table>\n",
97 " <tr>\n",
98 " <td ><center><img src=\"http://imgbed.momodel.cn/感知器模型.png\" width=400/></center></td>\n",
99 " <td><center><img src=\"http://imgbed.momodel.cn/微信图片_20200114135559.png\" width=400/>\n",
100 " <img src=\"http://imgbed.momodel.cn/微信图片_20200114135643.png\" width=400/></center></td>\n",
101 " </tr>\n",
102 "</table>"
51103 ]
52104 },
53105 {
216268 "\n",
217269 "与感知机的不同,神经网络:\n",
218270 "+ 输入层和输出层之间存在若干隐藏层。\n",
219 "+ 每个隐藏层中包含若干神经元。\n"
271 "+ 每个隐藏层中包含若干神经元。\n",
272 "\n",
273 "神经网络流程:\n",
274 "<center><video src=\"https://files.momodel.cn/media1.mp4\" controls=\"controls\" width=800px></center>\n",
275 "<center><video src=\"https://files.momodel.cn/media2.mp4\" controls=\"controls\" width=800px></center>\n",
276 "<center><video src=\"https://files.momodel.cn/media3.mp4\" controls=\"controls\" width=800px></center>\n",
277 "<center><video src=\"https://files.momodel.cn/media4.mp4\" controls=\"controls\" width=800px></center>\n",
278 "<center><video src=\"https://files.momodel.cn/media5.mp4\" controls=\"controls\" width=800px></center>\n",
279 "<center><video src=\"https://files.momodel.cn/media6.mp4\" controls=\"controls\" width=800px></center>\n"
220280 ]
221281 },
222282 {
400400 def generate_greedy_help_text(self,path):
401401 if path[-1] == self.target_node:
402402 return '抵达目标节点' + str(self.target_node)
403 elif len(path) == self.max_depth+1:
403 elif path not in self.search_scores:
404404 return '抵达最大搜索深度,未找到目标节点'
405405
406406 base_text = '当前可选的子节点及其信息值为 \n'+ \