自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【第十五周】sklearn

1、Create a classification dataset(n_samples>=1000,n_features>=10)代码如下:from sklearn import datasetsx, y = datasets.make_classification(n_samples=1000, n_features=10, n_classes=2)print(x,y)2、Spl...

2018-06-20 09:42:05 184

原创 【第十四周】Anscombe's quartet

本次要求出均值、方差、相关系数和线性回归的β1、β2代码如下:import pandas as pdimport scipy as spimport statsmodels.api as smfrom statsmodels.formula.api import olsanascombe = pd.read_csv('anscombe.csv')anascombe.head()prin...

2018-06-11 21:15:26 272

原创 【第十三周】Scipy练习

Exercise 10.1: Least squaresimport numpy as npfrom scipy import linalgA = np.random.randint(0,100,(20, 10))A = np.mat(A)b = np.random.randint(0,100,size=20)x_hat = np.linalg.lstsq(A, b)[0]res...

2018-06-01 12:41:57 172

原创 【第十二周】Matplotlib练习

Exercise 11.1: Plotting a function Plot the functionf(x) = sin2(x − 2)e−x2 over the interval [0, 2]. Add proper axis labels, a title, etc.代码如下:import numpy as npimport matplotlib.pyplot as pltx = n...

2018-05-28 01:39:33 217

原创 【第十一周】numpy练习

注:为了结果较方便截图,本次作业里A矩阵缩减为2*5,B矩阵缩减为5*5生成随机高斯分布的矩阵A,生成拓普利兹矩阵Bimport numpy as npa = np.random.normal(size=[2,5]).reshape([2,5])data = [[1,2,3,4,5],[2,1,2,3,4],[3,2,1,2,3],[4,3,2,1,2],[5,4,3,2,1]]b = np...

2018-05-21 23:26:40 295

原创 【第九周】leetcode上一题

Jump Game (#55)Givenan array of non-negative integers, you are initially positioned at the firstindex of the array.Eachelement in the array represents your maximum jump length at that position.Determi...

2018-05-07 00:40:46 116

原创 【第八周】三道leetcode题目

一、leetcode #540 有序数组的单一元素【题目描述】给定一个只包含整数的有序数组,每个元素都会出现两次,唯有一个数只会出现一次,找出这个数。示例 1:输入: [1,1,2,3,3,4,4,8,8]输出: 2示例 2:输入: [3,3,7,7,10,11,11]输出: 10【我的想法】    其实这道题我的想法比较简单,通过遍历数组判断该数是否与前一个数和后一个数都不同即可,其时间复...

2018-04-30 01:23:43 390

原创 【第六周】第十一章全部习题

11-1 城市和国家city_functions.pydef union(city,country): return city + ',' + countrytest_cities.pyimport unittestfrom city_functions import unionclass Test(unittest.TestCase): def test1(self):...

2018-04-15 10:47:31 534

原创 【第五周】第十章选做五题

10-1 python笔记第一种做法:with open ('learning_python.txt') as file_object: contents = file_object.read() print(contents)第二种做法:with open ('learning_python.txt') as file_object: for line in file_o...

2018-04-07 10:54:05 119

原创 【第五周】第九章习题任选五题

 9-1餐馆class restaurant(): def __init__(self,restaurant_name,cusine_type): self.name = restaurant_name self.type1 = cusine_type def describe_restaurant(self): print ("Th...

2018-04-07 00:57:45 188

原创 【第四周】第八章习题

8-1消息def desplay_message(): print ("I am learning function!")desplay_message()8-2喜欢的图书def favorite_book(title): print ("One of my favorite book is " + title)favorite_book("Alice in Wonderlan...

2018-03-30 23:40:48 201

原创 【第四周】第七章习题

7-1 汽车租赁car = input ("Please input the car: ")print ("Let me see if I can find you a " + car)7-2餐馆订位num = input ("How many people will go to our restaurant? ")num = int(num)if num > 8: pri...

2018-03-27 22:20:26 178

原创 【第三周】第六章全部习题

 6-1人people = { 'first_name':'Lucy', 'last_name': 'Zheng' , 'age': 20 , 'city': 'Guangzhou'}print (people)6-2喜欢的数字num = {'Lucy': 17 , 'Peppa': 2 , 'George': 4 , 'LittlePig': 7}print (num)6-3 词汇表vo =...

2018-03-21 21:48:28 166

原创 【第三周】第五章全部习题

 5-1 条件测试car = 'subaru'print("Is car =='subaru'? I predit True.")print(car == 'subaru')print("\nIs car == 'audi'?I predit False.")print(car == 'audi')car = 'BMW'print("Is car =='BMW'? I predit ...

2018-03-20 00:10:24 218

原创 【第二周】第四章作业

 4-1 披萨pizzas = ['meat','cabbage','pork'] for pizza in pizzas: print(pizza)for pizza in pizzas: print('I like ' + pizza + 'pizza.') print ('I really like pizza!') 4-2动物animals= ['do...

2018-03-15 21:48:59 254

原创 【第二周】第三章全部习题3-1~3-11

3-1姓名names = ['LucyZheng','JairZhu','HHL','WilliamZheng']for name in names: print (name)3-2问候语names = ['LucyZheng','JairZhu','HHL','WilliamZheng']for name in names: print (name + ",nice to ...

2018-03-12 22:42:30 218

原创 【第一周】第二章习题2-1~2-11

第一周作业之——教材第二章全部练习 2-1~2-112-1简单消息:将一条消息存储到变量中,再将其打印出来。message = "hello world"print(message)2-2多条简单消息:将一条消息存储到变量中,将其打印出来;再将变量的值修改为一条新消息,并将其打印出来。message = "hello world"print(message)message = "I love...

2018-03-08 00:05:09 842

空空如也

空空如也

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

TA关注的人

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