- 博客(20)
- 收藏
- 关注
原创 sklearn练习
这个练习是让我们比较三种分类算法的性能,加上学习调试一些算法的参数。详情请看注释:代码中没有from sklearn import cross_validation,因为pycharm提示这个库在新版上sklearn已经被删掉了from sklearn import datasetsfrom sklearn.model_selection import KFoldfrom sklearn.na...
2018-06-16 20:24:54
368
原创 Jupyter 练习
anscombe里有四个datasetpart1要求算出四个dataset的x、y均值、算出四个dataset的x、y的相关系数、实现线性回归import randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsi...
2018-06-11 22:27:40
551
原创 Scipy 练习
这道题要求使用最小二乘法找到这个x并且输出残差的范数,程序如下:import scipyfrom scipy import linalgfrom scipy.optimize import leastsqA = scipy.random.normal(size=[30, 20])b = scipy.random.normal(size=[30])def error(x, A, b)...
2018-06-04 23:52:22
602
原创 Matplotlib 练习
import matplotlib.pyplot as pltfrom pylab import *import numpyfrom scipy.stats import gaussian_kde#exercise 1x = np.linspace(0, 2)y = np.power(np.sin(x-2), 2)*np.power(np.e, -x*x)plt.plot(x, y...
2018-05-27 19:54:16
315
1
原创 Numpy 练习
先设置随机数种子:import numpy as npimport timeseed = np.int64(time.time())print(seed)np.random.seed(seed)Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m,...
2018-05-19 11:47:17
429
原创 Leetcode题解 813 Largest Sum of Averages 【Dynamic programming】
813. Largest Sum of AveragesWe partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve...
2018-05-04 01:02:21
232
原创 Leetcode题解 4. Median of Two Sorted Arrays 【Array】
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1, 3]nu...
2018-04-29 12:08:36
263
原创 Leetcode题解 23. Merge k Sorted Lists【Linked List】
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4-&g...
2018-04-26 22:27:51
117
原创 Leetcode题解 495.Teemo Attacking 【Array】
In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning tim...
2018-04-23 20:18:13
145
原创 Python 第十一章部分习题
11-1 城市和国家:代码:homework.pydef city_fun(city, country): return city.title()+", "+countrytest_cities.pyimport unittestfrom homework import city_funclass CityTestCase(unittest.TestCase): def te...
2018-04-10 01:17:17
514
原创 Python第十章部分习题
10-1 Python学习笔记代码:filename = r'D:\homework.txt'with open(filename) as file_object: contents = file_object.read() print(contents)with open(filename) as file_object: for line in file_obj...
2018-04-05 14:20:43
346
原创 Python第九章部分习题
9-1 餐馆代码:class restaurant: def __init__(self, name, ctype): self.restaurant_name = name self.cuisine_type = ctype def discribe_restaurant(self): print("Restaurant ...
2018-04-02 19:17:34
332
原创 Python 第八章部分习题
8-1 消息代码:def display_message(): print("I learn how to write a function") def main(): display_message() if __name__ == '__main__': main()输出:8-2 喜欢的图书代码:def favorite_book(book_name): p...
2018-03-29 00:46:56
824
原创 Python 第七章部分练习
7.1 汽车租赁代码:car = input("Hello ,please tell which car you want to lease\n car name:")print("Let me see if I can find you a " + car)输出(输入为Subarn):7-2 餐馆订位代码:num = input("Hello ,please tell me how many ...
2018-03-28 00:36:40
1648
原创 Python第五章部分习题
5-2 更多的条件测试输出:输出:输出:输出:输出:5-3外星人颜色#1输出:输出:5-4外星人颜色#2输出:输出:5-11序数输出:
2018-03-21 23:57:13
573
原创 Python第四章部分习题
4-1 比萨:输出如下:4-2 动物:输出:4-3 数到20:输出:4-6 奇数:输出:4-7 3的倍数:输出:4-8 立方:输出:4-9 立方解析:输出:
2018-03-14 23:17:35
572
原创 Python 第三章部分练习
3-1姓名:将一些朋友的姓名存储在一个列表中,并将其命名为names。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。3-2问候语:3-4 嘉宾名单:3-5 修改嘉宾名单:3-6 添加嘉宾3-9 晚餐嘉宾...
2018-03-12 17:19:43
457
原创 Python编程从入门到实践 第二章部分习题练习
2-1 简单消息:将一条消息存储到变量中,再将其打印出来。2-2 多条简单消息:将一条消息存储到变量中,再将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。2-3 个性化消息:将用户的姓名存到一个变量中,并向该用户显示一条消息。显示的消息应非常简单,如“Hello Eric, would you like to learn some Python today?"2-4 调整名字的大小写:...
2018-03-07 23:52:20
413
原创 初入python及目标
打开python主页后,一眼就看到Download,十分简单就可以下载好windows环境下的python3.6.4,主页十分友好。可以让人找到想要的资料,比如在About里可以找到对新手的指引,在Documentation 里还能找到 python 3.6.4 documentation,进而可以找到一些tutorial,可以让人一步一步熟悉python,掌握python的特性。除了对新...
2018-03-07 23:10:42
184
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人