Commit c07c1c17 by 20200519016

project1

parent eca30312
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem 1. Fibonacci Sequence\n",
"在课程里,讨论过如果去找到第N个Fibonacci number。在这里,我们来试着求一下它的Closed-form解。 \n",
"\n",
"Fibonacci数列为 1,1,2,3,5,8,13,21,.... 也就第一个数为1,第二个数为1,以此类推...\n",
"我们用f(n)来数列里的第n个数,比如n=3时 f(3)=2。\n",
"\n",
"下面,来证明一下fibonacci数列的closed-form, 如下:\n",
"\n",
"$f(n)=\\frac{1}{\\sqrt{5}}(\\frac{1+\\sqrt{5}}{2})^n-\\frac{1}{\\sqrt{5}}(\\frac{1-\\sqrt{5}}{2})^n$\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"// your proof is here ....\n",
"见图片problem1.jpg\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem2. Algorithmic Complexity\n",
"对于下面的复杂度,从小大排一下顺序:\n",
"\n",
"$O(N), O(N^2), O(2^N), O(N\\log N), O(N!), O(1), O(\\log N), O(3^N), O(N^2\\log N), O(N^{2.1})$\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"// your answer....\n",
"\n",
"$O(N!),O(3^N), O(2^N), O(N^{2.1}),O(N^2\\log N), O(N^2), O(N\\log N), O(N),O(\\log N)$\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem 3 Dynamic Programming Problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Edit Distance (编辑距离)\n",
"编辑距离用来计算两个字符串之间的最短距离,这里涉及到三个不通过的操作,add, delete和replace. 每一个操作我们假定需要1各单位的cost. \n",
"\n",
"例子: \"apple\", \"appl\" 之间的编辑距离为1 (需要1个删除的操作)\n",
"\"machine\", \"macaide\" dist = 2\n",
"\"mach\", \"aaach\" dist=2"
]
},
{
"cell_type": "code",
"execution_count": 142,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]]\n",
"[[0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 2, 2, 2, 2, 1], [1, 1, 0, 1, 2, 3, 3, 2], [1, 2, 1, 0, 1, 2, 3, 3], [1, 2, 2, 1, 1, 2, 3, 4], [1, 2, 3, 2, 2, 1, 2, 3], [1, 2, 3, 3, 3, 2, 2, 3], [1, 2, 3, 4, 4, 3, 3, 2]]\n",
"2\n"
]
}
],
"source": [
"# 基于动态规划的解法\n",
"import math\n",
"def edit_dist(str1, str2):\n",
" # 两个string 输入\n",
" # your code here\n",
" len1 = len(str1)\n",
" len2 = len(str2)\n",
" dist = [ [0] * (len2+1) for i in range((len1+1))]\n",
" for j in range(1,len2+1,1):\n",
" dist[0][j] =1 \n",
" for i in range(1,len1+1,1):\n",
" dist[i][0] =1\n",
" \n",
" print(dist)\n",
" for i in range(0,len1+1,1):\n",
" for j in range(1,len2+1,1):\n",
" if str1[i-1] == str2[j-1]:\n",
" dist[i][j] = dist[i-1][j-1]\n",
" else:\n",
" dist[i][j] = min(dist[i-1][j-1]+1,dist[i-1][j]+1,dist[i][j-1]+1)\n",
" print(dist)\n",
" return dist[len1][len2]\n",
" \n",
"if __name__ == \"__main__\":\n",
" str1='machine'\n",
" str2 = 'macaide'\n",
"\n",
" dist = edit_dist(str1,str2)\n",
" print(dist)\n",
" \n",
" \n",
" \n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem 4 非技术问题\n",
"本题目的目的是想再深入了解背景,之后课程的内容也会根据感兴趣的点来做适当会调整。 \n",
"\n",
"\n",
"Q1: 之前或者现在,做过哪些AI项目/NLP项目?可以适当说一下采用的解决方案,如果目前还没有想出合适的解决方案,也可以说明一下大致的想法。 请列举几个点。\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"Q2: 未来想往哪个行业发展? 或者想做哪方面的项目? 请列举几个点。\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"Q3: 参加训练营,最想获得的是什么?可以列举几个点。\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
......@@ -22,9 +22,7 @@
"source": [
"// your proof is here ....\n",
"\n",
"\n",
"\n",
"\n",
"见图片problem1.jpg\n",
"\n",
"\n",
"\n",
......@@ -50,14 +48,12 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"// your answer....\n",
"\n",
"\n",
"$O(N!),O(3^N), O(2^N), O(N^{2.1}),O(N^2\\log N), O(N^2), O(N\\log N), O(N),O(\\log N)$\n",
"\n",
"\n",
"\n",
......@@ -88,23 +84,49 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 142,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "unexpected EOF while parsing (<ipython-input-1-5160edc8389a>, line 9)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-1-5160edc8389a>\"\u001b[0;36m, line \u001b[0;32m9\u001b[0m\n\u001b[0;31m \u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n"
"name": "stdout",
"output_type": "stream",
"text": [
"[[0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]]\n",
"[[0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 2, 2, 2, 2, 1], [1, 1, 0, 1, 2, 3, 3, 2], [1, 2, 1, 0, 1, 2, 3, 3], [1, 2, 2, 1, 1, 2, 3, 4], [1, 2, 3, 2, 2, 1, 2, 3], [1, 2, 3, 3, 3, 2, 2, 3], [1, 2, 3, 4, 4, 3, 3, 2]]\n",
"2\n"
]
}
],
"source": [
"# 基于动态规划的解法\n",
"import math\n",
"def edit_dist(str1, str2):\n",
" # 两个string 输入\n",
" # your code here\n",
" len1 = len(str1)\n",
" len2 = len(str2)\n",
" dist = [ [0] * (len2+1) for i in range((len1+1))]\n",
" for j in range(1,len2+1,1):\n",
" dist[0][j] =1 \n",
" for i in range(1,len1+1,1):\n",
" dist[i][0] =1\n",
" \n",
" print(dist)\n",
" for i in range(0,len1+1,1):\n",
" for j in range(1,len2+1,1):\n",
" if str1[i-1] == str2[j-1]:\n",
" dist[i][j] = dist[i-1][j-1]\n",
" else:\n",
" dist[i][j] = min(dist[i-1][j-1]+1,dist[i-1][j]+1,dist[i][j-1]+1)\n",
" print(dist)\n",
" return dist[len1][len2]\n",
" \n",
"if __name__ == \"__main__\":\n",
" str1='machine'\n",
" str2 = 'macaide'\n",
"\n",
" dist = edit_dist(str1,str2)\n",
" print(dist)\n",
" \n",
" \n",
" \n",
......@@ -144,6 +166,22 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"//your answer...\n",
"\n",
"Q1:\n",
"之前做过恶意作弊账号分类,主要是建立用户画像然后采用xgboost模型融合的方式进行分类预测。\n",
"\n",
"Q2:\n",
"未来主要是希望可以往金融等领域发展,主要希望可以做文本分类等方面的工作。\n",
"\n",
"Q3:\n",
"希望能够巩固自己的知识体系,为将来面试新的工作做好铺垫。\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
......@@ -167,7 +205,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.6"
}
},
"nbformat": 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment