- 博客(19)
- 收藏
- 关注
原创 第十五周作业
Assignment of Sklearn Task In the second ML assignment you have to compare the performance of three different classification algorithms, namely Naive Bayes, SVM, and Random Forest. For this assig...
2018-06-19 19:24:15
468
原创 第十四周作业
今天老师讲了 pandas ,要求我们用 pandas 、numpy 等工具完成下面两项作业。 %matplotlib inline import random import numpy as np import scipy as sp import pandas as pd import matplotlib.pyplot as plt import seaborn as sns imp...
2018-06-12 17:40:08
230
原创 第十三周作业
今天老师讲了 Scipy 的用法,并要求我们做 Scipy 的课后练习。 第一题 随机生成一个 m×n(m>n)m×n(m>n)m \times n (m \gt n) 的矩阵 AAA 和一个 mmm 维向量 bbb ,求 x=argminx||Ax−b||2x=argminx||Ax−b||2x = \arg \min_x ||Ax - b|| _2 这时候就可以用 ...
2018-06-04 17:07:30
297
原创 第十二周作业
今天老师介绍了 matplotlib ,并要求我们用 numpy 和 matplotlib 完成下面 3 题练习题: 第一题 画出 f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e−x2f(x) = sin^2(x - 2) e^{-x^2} 。 参考老师给的课件,只要掌握了set_xlim, set_ylim, set_xlabel, set_ylabel, set_ti...
2018-05-28 17:52:00
244
原创 第十一周作业
Numpy 这节课老师讲了 Numpy ,装个 Numpy 都能装半个钟 TAT ……查一查就知道有镜像源可以用啊 QAQ 9.1 Matrix operations Calculate A+A,AAT,ATAA+A,AAT,ATAA+A, AA^T, A^TA and ABABAB. Write a function that computes A(B−λI)A(B−λI)A(B-\lam...
2018-05-18 00:29:05
387
原创 第九周作业(周三)
第九周作业(周三) 这节课老师讲了 Functional Programming ,我翻了几道题发现都用不着这个…… Leetcode 124 求二叉树上最大的路径和。这里注意路径至少有一个点。 解法显然,树形dp。每个点维护两个值:这颗子树中最大的路径和 f(x)f(x)f(x)、从这个点往下走能走到的最大路径和 g(x)g(x)g(x) 。 就有:f(x)=max(f(lson(x)...
2018-05-10 17:12:36
179
原创 第九周作业(周一)
第九周作业(周一) 这周讲字符串,那就写一个字符串的题 #6 吧 题目是按给定规则排列字符串,再按照给定规则输出。 通过分析规律,容易找到新字符串的字符与旧字符串的字符的一对一的映射关系。 class Solution: def convert(self, s, numRows): if numRows == 1: return s ...
2018-05-02 12:40:32
197
原创 第八周作业(周三)
Leetcode 题目 再做一道 Array 的题目,#57 标了Hard,发现好像不难。只要分三种情况讨论就好了,一是比newinterval.start小,二是比newinterval.end大,三是其他。 class Solution: def insert(self, intervals, newInterval): ret = [] ok...
2018-05-02 11:06:00
176
原创 第八周作业(周一)
Leetcode Array 林老师让我们在 Leetcode 找一道标签为 Array 的题目,用 Python 写。我随便找了一个 Hard 的来看看。 我找了题目 #84 ,题目链接 https://leetcode.com/problems/largest-rectangle-in-histogram/description/ 。 题意是说,给定 a1,a2,⋯ana1,a2,⋯an...
2018-04-23 21:44:21
275
原创 第五周作业(周三)
第10章作业 习题10-1 learning_python.txt In Python you can work In Python you can sleep In Python you can be lazy a.py filename = 'learning_python.txt' with open(filename) as f: contents = f.re...
2018-04-09 00:29:14
160
原创 第五周作业(周一)
第9章作业 习题9-1 class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_r...
2018-04-09 00:16:07
294
原创 第四周作业(周三)
第8章作业 习题8-2 def favorite_book(title): print("My favorite book is " + title) favorite_book("Alice in Wonderland") My favorite book is Alice in Wonderland 习题8-4 def make_shirt(sent...
2018-03-29 16:13:46
210
原创 第四周作业(周一)
第7章作业 习题7-1 car = input("What car do you want: ") print("Let me see if I can find you a " + car) What car do you want: YanBin Let me see if I can find you a YanBin 习题7-3 n = input("Inpu...
2018-03-29 13:47:42
207
原创 第三周作业(周三)
第6章作业 习题6-1 >>> person = {'first_name':'Alice', 'last_name': 'Bob', 'age':18, 'city':'Guangzhou'} >>> person {'first_name': 'Alice', 'last_name': 'Bob', 'age': 18, 'city': 'Guang...
2018-03-24 23:01:32
175
原创 第三周作业(周一)
第5章作业 习题5-4 >>> alien_color = 'green' >>> if alien_color == 'green': ... print('score 5 points') ... else: ... print('score 10 points') ... score 5 points >>>...
2018-03-19 11:22:29
212
原创 第二周作业(周三)
第二周作业 习题4-1 >>> pizza = ['liulian', 'haixian', 'zhishi'] >>> for i in pizza: ... print('i like ' + i + ' pizza') ... i like liulian pizza i like haixian pizza i like zhish...
2018-03-15 20:02:26
238
原创 第二周作业(周一)
第3章作业 习题3-1 >>> names = ['Wang JP', 'Wang QC', 'Wang ZS'] >>> for i in names: ... print(i) ... Wang JP Wang QC Wang ZS 本题只要熟悉list的用法即可做出。 习题3-2 >>> for i in na...
2018-03-12 22:26:24
201
原创 第一周作业(周三)
第2章作业 习题 2-1 mSg = "message" print(mSg) print(msg) 结果如下: message Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'msg' is not defined 我们可以...
2018-03-08 14:46:25
231
原创 第一周作业(周一)
第一周作业 浏览Python主页的发现和收获 Python的入门教程非常完善,包括下载、安装的文档,以及Python语法、用法的文档,还有FAQ。 Python的文档内容丰富,包括了Python的数据类型、控制语句、以及字符串处理等内容。在每一节,除了有语句的详细解释,更有范例帮助新手理解这些语法。 Python的文档还介绍了代码风格。它建议使用4个空格作为一个缩进,而不选用Tab作为缩...
2018-03-05 11:02:12
197
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人