Python
文章平均质量分 52
wuzy38
这个作者很懒,什么都没留下…
展开
-
python学习第15周:sklearn
Question:1datasets.make_classification是一个智能生成数据集的函数from sklearn import datasetsdataset = datasets.make_classification(n_samples=1000, n_features=10,n_informative=2, n_redundant=2, n_r...原创 2018-06-20 01:58:34 · 236 阅读 · 0 评论 -
python学习第14周:Anscombe's quartet
about Anscombe's quartet1973年,统计学家F.J. Anscombe构造出了四组奇特的数据。它告诉人们,在分析数据之前,描绘数据所对应的图像有多么的重要。这四组数据中,x值的平均数都是9.0,y值的平均数都是7.5;x值的方差都是10.0,y值的方差都是3.75;它们的相关度都是0.816,线性回归线都是y=3+0.5x。单从这些统计数字上看来,四组数据所反映出的实际...原创 2018-06-12 23:16:59 · 2119 阅读 · 2 评论 -
python学习第13周:scipy
10.1题目 题解import numpyfrom scipy.linalg import lstsq#10.1 least squarem = 20n = 10A = numpy.random.normal(size=(m, n))b = numpy.random.normal(size = m)x, residues, rank, s = lstsq(A, b)pr...原创 2018-06-05 12:31:42 · 228 阅读 · 2 评论 -
python学习第12周: Python matplotlib
11.1题目题解import matplotlib.pyplot as pltimport numpyimport mathdef func(x): y1 = numpy.sin(x-2) y2 = math.e ** (-x*x) return y1**2 * y2x = numpy.linspace(0, 2, 1000)y = ...原创 2018-05-29 18:03:22 · 341 阅读 · 0 评论 -
python学习第11周:python numpy
Problem:Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A 2 Rn×m and B 2 Rm×m,for n = 200, m = 500首先是初始化过程:import numpyimport timefrom scipy.linalg import t...原创 2018-05-22 00:43:45 · 303 阅读 · 0 评论 -
python学习第9周:LeetCode 120. Triangle题解
#120题目来源:https://leetcode.com/problems/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 ...原创 2018-05-11 00:52:48 · 128 阅读 · 0 评论 -
python学习第8周(3): LeetCode 11. Container With Most Water
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find...原创 2018-04-29 23:28:08 · 103 阅读 · 0 评论 -
python学习第8周(2): LeetCode.63. Unique Paths II 题解
这是一题动态规划的题目。若一个格子可达,则到达这个格子的路径数等于到达其上一个格子的路径数与到达其左格子的路径数的和;否则到达这个格子的路径数为0.题目:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can onl...原创 2018-04-29 19:15:07 · 169 阅读 · 0 评论 -
python学习第8周(1):LeetCode45. Jump Game II题解
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your go...原创 2018-04-28 11:35:56 · 278 阅读 · 0 评论 -
python学习第6周
#11-1city_functions.pydef city_country(city, country): return (city + ", " + country).title()test_cities.pyimport unittestfrom city_functions.py import city_countryclass CitysTestCase(u...原创 2018-04-15 15:31:00 · 119 阅读 · 0 评论 -
python学习第5周(2)
#10-1with open(r'learning_python.txt') as file_object:#linefor line in file_object:print(line.rstrip())with open(r'learning_python.txt') as file_object:#filecontents = file_object.read()print(...原创 2018-04-05 00:59:14 · 107 阅读 · 0 评论 -
python学习第5周(1)
#9-3class User():def __init__(self, first_name, last_name, sex, country):self.first_name = first_nameself.last_name = last_nameself.sex = sexself.country = countrydef describe_user(self):messa...原创 2018-04-04 23:22:47 · 160 阅读 · 0 评论 -
python学习第4周(2)
#8-1def display_message():print("I learn function in this chapter.")display_message()#8-5def describe_city(city_name, country = "China"):print(city_name + " is in " + country)describe_city("Gua...原创 2018-04-01 23:20:49 · 122 阅读 · 0 评论 -
python学习第4周(1)
#7-2num = input("how many people for dinner:")num = int(num)if num > 8 :print("there is no available table.\n")#7-3num = input("please input a numble:");if int(num) % 10 == 0 :print("it is ...原创 2018-03-28 20:09:33 · 122 阅读 · 0 评论 -
python学习第3周(2)
#6-2favorite_num = {"LiHua": 1,"Ben": 2,"Lili": 3,"Estin": 8,"Kimi": 6}for name, num in favorite_num.items():print(name + "'s favorite numble is " + str(num))#6-5rivers_inf = {"nile": "egyp...原创 2018-03-21 23:36:42 · 156 阅读 · 0 评论 -
python学习第3周(1)
#5-2str1 = "String"str2 = "string"print(str1 == str2)print(str1 != str2)print(str1.lower() == str2.lower())print(str1.lower() != str2.lower())print(4 == 5)print(4 != 5)print(4 > 5)print(4...原创 2018-03-21 22:59:20 · 128 阅读 · 0 评论 -
python学习第2周(2)
#4-2animals = ["dog", "cat", "pig"]for animal in animals :print("A " + animal + " would make a great pet")print("Any of the animals would make a great pet!")#4-3for value in range(1, 21):print(...原创 2018-03-15 16:17:50 · 122 阅读 · 0 评论 -
python学习第2周(1)
#python课后作业#3-1,2names = ["Wuzy", "Xul", "Xusw"]for name in names:print(name + ", How are you.")#3-3vehicles = ["car", "bike", "motorbike"]for vehicle in vehicles:print("I would like to own a ...原创 2018-03-13 19:44:32 · 277 阅读 · 0 评论 -
python学习第1周(2)
#python课后作业#2-3name = "alice"print("Hello " + name.title() + ", it's cold today.")#2-7name = "\n\tEinstein \n"print(name)print(name.lstrip())print(name.strip())print(name.rstrip())#2-8print...原创 2018-03-10 20:00:12 · 120 阅读 · 0 评论