自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

homework4

homework

  • 博客(21)
  • 收藏
  • 关注

原创 sklearn习题

Steps1 Create a classification dataset (n samples ! 1000, n features ! 10) 2 Split the dataset using 10-fold cross validation 3 Train the algorithms I GaussianNB I SVC (possible C values [1e-02,...

2018-06-19 01:17:19 327

原创 jupyter练习

%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.form...

2018-06-11 16:46:13 710

原创 scipy练习

10.1import numpy as np;import scipy.optimize as oz;import scipy.linalg as linm=20n=10A = np.random.random(size=(m,n))b = np.random.random(m)x = oz.lsq_linear(A,b).funprint(lin.norm(x))...

2018-06-05 18:05:04 187

原创 matplotlib练习

11.1import numpy as npimport matplotlib.pyplot as pltf,ax = plt.subplots(1,1,figsize=(5,4))x = np.linspace(0,2,200)y = np.power(np.sin(x-2),2) * np.exp(-np.power(x,2))ax.plot(x,y,'r-')ax.se...

2018-05-26 21:14:11 203

原创 numpy习题

Exercise 9.1: Matrix operationsCalculate A + A, AA>; A>A and AB. Write a function that computes A(B − λI) for any λ.import numpy as npnp.random.seed()n=200m=500def toeplitz(x, y): ...

2018-05-22 12:53:25 282

原创 leetcode #343

题目描述:给定一个正整数 n,将其拆分为至少两个正整数的和,并使这些整数的乘积最大化。 返回你可以获得的最大乘积。例如,给定 n = 2,返回1(2 = 1 + 1);给定 n = 10,返回36(10 = 3 + 3 + 4)。注意:你可以假设 n 不小于2且不大于58。解题思路:首先,我们要把n拆分为仅由2,3,4组成的数,且其中2和4的个数最多为1。 原因:对于大于...

2018-05-16 19:57:30 165

原创 leetcode #2. 两数相加

题目描述:给定两个非空链表来表示两个非负整数。位数按照逆序方式存储,它们的每个节点只存储单个数字。将两数相加返回一个新的链表。你可以假设除了数字 0 之外,这两个数字都不会以零开头。示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807解题思路:首...

2018-05-02 21:25:39 118

原创 leetcode #213打家劫舍 II

题目描述在上次盗窃完一条街道之后,窃贼又转到了一个新的地方,这样他就不会引起太多注意。这一次,这个地方的所有房屋都围成一圈。这意味着第一个房子是最后一个是紧挨着的。同时,这些房屋的安全系统与上次那条街道的安全系统保持一致。给出一份代表每个房屋存放钱数的非负整数列表,确定你可以在不触动警报的情况下盗取的最高金额。解题思路首先,把这个环形的街道转化为直线,因为第一个房子和最后一个房...

2018-04-29 00:46:16 735

原创 leetcode #55

题目描述给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。判断你是否能够到达最后一个位置。示例 1: 输入: [2,3,1,1,4] 输出: true 解释: 从位置 0 到 1 跳 1 步, 然后跳 3 步到达最后一个位置。示例 2: 输入: [3,2,1,0,4] 输出: false 解释: 无论怎样,你总会到达...

2018-04-26 10:40:45 133

原创 leetcode #41. 缺失的第一个正数

题目描述:给定一个未排序的整数数组,找出其中没有出现的最小的正整数。示例 1: 输入: [1,2,0] 输出: 3示例 2: 输入: [3,4,-1,1] 输出: 2示例 3: 输入: [7,8,9,11,12] 输出: 1说明:你的算法的时间复杂度应为O(n),并且只能使用常数级别的空间。解题思路:首先,因为所求的为最小正数,则对于数组中的负数,不会影...

2018-04-24 00:04:39 747

原创 homework11

11-1city_functions.pydef city_country(city,country): return city+', '+countrytest_cities.pyimport unittestfrom city_functions import city_countryclass city_Test_class(unittest.TestC...

2018-04-09 18:32:07 126

原创 homework10

10-3name = input("Please enter your name:")with open("names.txt",'w') as fout: fout.write(name)10-6first = input('Please enter a number:')second = input('Please enter a number:')try...

2018-04-04 20:42:16 105

原创 homework9

9-3class User(): def __init__(self,first,last,age,job): self.first=first self.last=last self.age=age self.job=job def describe_user(self): print(sel...

2018-04-02 20:29:52 135

原创 homework8

8-1def display_message(): print("I learn function this chapter.")display_message()8-5def describe_city(city, country = "China"): print(city + " is in " + country)describe_city("B...

2018-03-28 19:51:30 159

原创 homework7

7-3num = int(input("Please enter a number:"))if num % 10 == 0: print("This number is the multiplier of 10.")else: print("This number is not the multiplier of 10.")7-5num = int(in...

2018-03-26 13:04:26 120

原创 homework6

6-2num = {'Mike' : 3, 'Nancy' : 9, 'Jace' : 4, 'Dave' : 8, 'Jack' : 0}print(num)6-3rivers = {'nile' : 'egypt', 'amazon' : 'brazil', 'yangtze' : 'china'}for river,nation in rivers.items()...

2018-03-21 20:32:59 156

原创 homework5

5-3(1)alien_color = 'green'if alien_color == 'green': print('You got 5 points')else: print('')(2)alien_color = 'red'if alien_color == 'green': print('You got 5 points')else...

2018-03-19 21:52:45 179

原创 hoemwork4

4-2aanimals = ['tiger', 'lion', 'wolf']for animal in animals: print(animal)banimals = ['tiger', 'lion', 'wolf']for animal in animals: print('The ' + animal +' is terror!')c...

2018-03-14 21:40:01 236

原创 homework3

3-13-23-53-9

2018-03-12 23:20:22 216

原创 homework2

2-12-22-32-42-82-11

2018-03-07 23:55:18 371

原创 初识Python

看完python的官网后,我有了以下几点体会:1.python的语法十分灵活,不像c或c++般严格,更容易书写和理解。2.官网上对python的介绍中有一个词quick,这强调了python是一门高效率的语言。3.python可以使用较短的语句实现复杂的功能,即它更为简洁。4.python在许多不同的行业都有应用,一方面是因为它强大的功能,另一方面是因为它易于学习而且更为友好。如果我在将来熟练掌握...

2018-03-07 00:15:23 353

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除