- 博客(14)
- 收藏
- 关注
原创 python homework —— the 15th week
codes运行结果随机森林算法的效果最好,评价指数最高,都在0.91以上;SVC比高斯朴素贝叶斯评价指数要高一些;总体而言,差距不会很大。
2018-06-20 23:28:01 150 4
原创 python homework——the 14th week
Part11.import pandas as pd import seaborn as snsimport matplotlib.pyplot as plt import statsmodels.formula.api as sfaanc=pd.read_csv('anscombe.csv')print('The mean of x is\n'+str(anc.groupby('dataset'...
2018-06-12 19:54:59 301
原创 python homework——the 13th week
10.1import numpy as np import scipy.linalg as linA=np.random.randn(20,15)b=np.random.randn(20)c,re,rand,sigma=lin.lstsq(A,b)b_=A.dot(c)print(lin.norm(b-b_))10.2import numpy as np import scipy.optimize...
2018-06-05 11:53:36 156
原创 python homework——the 12th week
11.1import numpy as npimport matplotlib.pyplot as pltdef func(x): return (np.sin(x-2)**2)*np.exp(-x**2)x=np.linspace(0,2,100)plt.figure(figsize=(8,4))plt.plot(x,func(x),label='$y=sin^2(x-2)*exp(-x^2)$...
2018-05-27 22:32:07 168
原创 python homework——the 11th week
9.1>>> import numpy as np>>> import scipy.linalg as la>>> A=np.random.randn(200,500)>>> B=la.toeplitz([x for x in range(500)])>>> C=A+A>>
2018-05-22 13:32:49 183
原创 python homework-----the ninth week
1.两数之和给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]思路:从列表第一个元素开始遍历到倒数第二个元素,每一次循环将target减去该元素得到一个差,然...
2018-05-07 17:48:33 135
原创 python homework——the eighth week
349.Intersection of two arraysGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be un...
2018-04-29 21:08:18 107
原创 python homework ——the sixth week
11-1city_functions.pydef get_city_country(city,country): city_country=city+", "+country return city_country.title()test_cities.pyimport unittestfrom city_function import get_city_countryclass Ci...
2018-04-15 16:41:49 157
原创 python homework ——the fifth week
9-1class Restaurant(): """ 描述一个饭店""" def _init_(self,name,c_type): """初始化饭店信息""" self.name=name self.type=c_type def describe_res(self): print("The restaurant's name is "+self.name+&
2018-04-08 22:04:28 131
原创 python homework——the fourth week
7-2num=input('How many people will have dinner here?')if num >8: print('There are not so many tables.')else: print('there are enough tables')7-3num=input('Please input a number.')if num%10==0...
2018-04-01 19:59:56 146
原创 python homework ——the third week
5-3alien_color='green'if alien_color=='green': print('You get 5 points')5-5alien_color='yellow'if alien_color=='green': print('You get 5 points')elif alien_color=='yellow': print('You get 10 points')e...
2018-03-25 12:03:10 159
原创 python homework——The second week
3-1names=['Mike','John','Jack']for name in names: print(name)3-4guests=['Stark','Mike','Einstein']for guest in guests: print("Could you come to have a dinner with me,"+guest+"?")3-5print('Mike c...
2018-03-16 20:51:13 151
原创 读python主页感想以及设想用python做什么
这周学习了python语言,并且去浏览python主页。python是一门简单易学的语言。虽然说他是用c语言基础写的,但他没有了c语言中的指针等复杂语法,让初学者更容易理解;python也是可读性很好的一门语言,他强制要求人们按一定的格式去写代码,而不会像c语言一样有各种风格的代码。并且python比c语言更加简洁,让人感觉读代码就像读英语。python有丰富的库,可以帮你做各种工作,功能...
2018-03-11 20:49:56 255
原创 python作业2-1~2-11
2-1. message='hello world'print(message)2-2. message='hello world'print(message)message='good morning'print(message)2-3name='Mike'print('Hello '+name+', would you like to learn some Python today...
2018-03-11 16:12:01 232
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人