自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 sklearn练习

题目来自高级编程课程的课件。题目要求用sklearn创建一个分类问题的数据集,然后用三种不同的机器学习方法对数据集进行学习,并对三种方法的准确度、F1分数、受试者工作特征进行计算。代码如下:from sklearn import datasetsfrom sklearn import cross_validationfrom sklearn.naive_bayes import GaussianN...

2018-06-19 23:27:52 243

原创 数据处理练习

题目来自高级编程课程给定一个csv文件,完成以下两题:对应代码如下:import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels...

2018-06-10 12:52:00 2422 1

原创 scipy练习

题目来自高级编程课程的课件。# 10.1 Least squaresfrom scipy.optimize import least_squaresimport numpy as npn = 5m = 8A = []for i in range(n): temp = [] for j in range(m): temp += [np.random.r...

2018-06-04 20:15:27 229

原创 matplotlib练习

题目来自高级编程课程的课件。# 11.1 Plotting a functionimport matplotlibimport matplotlib.pyplot as pltimport numpy as npimport math# Data for plottingx = np.arange(0.0, 2.0, 0.01)y = (np.sin(x-2)**2)*(math....

2018-05-28 22:22:17 345

原创 numpy练习

题目来自高级编程课程的课件。Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈ Rn×m and B ∈ Rm×m,for n = 200, m = 500.首先生成上述矩阵:import numpy as npfrom scipy.linalg import toeplitzn ...

2018-05-22 00:06:00 199

原创 LeetCode 120 Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7],...

2018-04-29 09:35:03 108

原创 LeetCode 165 Compare Version Numbers

Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and ...

2018-04-29 09:19:03 120

原创 LeetCode 119 Pascal's Triangle II

题目:Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.Note that the row index starts from 0.思路:用一个ans数组来存储答案,一开始ans=[1]。采用迭代的方法,每次利用已有的ans和一个临时数组temp生成下一行,再复制...

2018-04-23 22:18:32 103 1

原创 Python教材第十一章部分习题

教材:《Python编程 从入门到实践》11-1:城市和国家11-2:人口数量修改被测试函数:可见测试未通过再次修改函数:    测试通过了添加测试:两个测试都通过了11-3:雇员...

2018-04-11 13:53:57 210

原创 Python教材第十章部分习题

教材:《Python编程 从入门到实践》10-3:访客#10-3 visitorwith open("visitor.txt", "w") as writer: print("Please enter your name:") name = input() writer.write(name)print("File successfully written")运行程序后...

2018-04-06 08:45:37 210

原创 Python教材第九章部分习题

教材:《Python编程 从入门到实践》9-3:用户#9-3 Usersclass User(): def __init__(self, first, last): self.first_name = first self.last_name = last self.level = 1 def describe_user(self...

2018-04-02 13:44:36 335

原创 Python教材第八章部分习题

教材:《Python编程 从入门到实践》8-5:城市#8-5 citiesdef describe_city(name, country='China'): print(name + ' is in ' + country + '.')describe_city('Shanghai')describe_city('Haiko')describe_city('Katowice',...

2018-04-01 23:42:04 326

原创 Python教材第七章部分习题

教材:《Python编程 从入门到实践》7-3:10的整数倍#7-3 multiple of 10num = input()if int(num) % 10 == 0: print("It is a multiple of 10")else: print("It is not a multiple of 10")输入1,输出为It is not a multiple of 1...

2018-03-29 09:03:43 414

原创 Python教材第六章部分习题

教材:《Python编程 从入门到实践》6-2:喜欢的数字#6-2 favorite numberd = {"Alice": 1, "Bob": 2, "Carol": 3, "Dennis": 4, "Edward": 5}for i in d: print(i + "'s favorite number is " + str(d[i]))输出:Alice's favorit

2018-03-27 21:55:43 2210

原创 Python教材第五章部分习题

教材:《Python编程 从入门到实践》5-3:外星人颜色#1#5-3 Color of aliens #1alien_color = "green"if alien_color == "green": print("You've got 5 points!")alien_color = "yellow"if alien_color == "green": print(".

2018-03-19 19:04:07 860

原创 Python教材第四章部分习题

教材:《Python编程 从入门到实践》4-5:计算1-1 000 000的总和# 4-5 insane suml = list(range(1, 1000001))print(min(l))print(max(l))print(sum(l))输出:110000005000005000004-7:3的倍数# 4-7 multiples of 3l = [i * 3 for i in ...

2018-03-15 08:42:56 693

原创 Python教材第三章部分习题

教材:《Python编程 从入门到实践》3-4:嘉宾名单# 3-4 Guests!guests = [ 'Jared "PiG" Krensel', 'Evan "Winter" Ballnik', 'Simon "Lowko" Heijnen', 'Austin "Neuro" Filsinger']for guest in guests: print("Dear...

2018-03-12 20:33:09 1901

原创 Python教材第二章部分习题

教材:《Python编程 从入门到实践》2-2:多条简单消息# 2-2 multiple simple messagesmsg = "Hello!"print(msg)msg = "My name is Maxwell"print(msg)输出:Hello!My name is Maxwell2-4:调整名字的大小写# 2-4 playing around with casesname...

2018-03-07 22:20:23 2331

原创 探索Python官网记 + 我的Python程序开发目标

    Python官网除了有关Python介绍、下载、文档等必不可少的内容之外,最有趣的地方可以说就是它的“Community”和“Success Stories”栏目了。    “Community”内包含了各种有关Python社区的信息,比如各种论坛、会议、特别小组的信息,甚至还有出售Python周边(衣服之类)的链接。Python Wiki也在这一栏中,提供了一个查询各种有关Python的...

2018-03-05 19:32:43 177

空空如也

空空如也

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

TA关注的人

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