自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Scikit-Learn: Machine Learning in Python

Step1: 代码:from sklearn import datasetsx, y = datasets.make_classification(n_samples=1000, n_features=10, n_classes=2)print(x)print(y)结果:[[ 0.73344374 1.39021153 1.63908277 ... 0.53789494 -1.1279...

2018-06-19 13:39:33 890

原创 pandas

Part 1For each of the four datasets...Compute the mean and variance of both x and yCompute the correlation coefficient between x and yCompute the linear regression line: y=β0+β1x+ϵy=β0+β1x+ϵ (hint: us...

2018-06-08 17:37:52 280

原创 Scipy

Exercise 10.1: Least squaresimport numpy as npfrom scipy.optimize import leastsqA = np.random.randint(10, 20, (20, 10))A = np.mat(A)b = np.random.randint(10, 20, size=20)residuals = np.linalg.ls...

2018-05-31 17:23:09 245

原创 Matplotlib

Exercise 11.1: Plotting a functionimport matplotlib.pyplot as pltimport numpyx = numpy.linspace(0, 2, 10000)y = [(numpy.sin((i - 2) * numpy.exp(- i ** 2))) ** 2 for i in x]plt.plot(x, y)plt.titl...

2018-05-24 15:03:35 255

原创 Numpy Exercises

Exercise 9.1: Matrix operationsimport numpyfrom scipy.linalg import toeplitzA = []for i in range(0, 200): x = numpy.random.normal(size=500) A.append(x)A = numpy.array(A)B = toeplitz([i f...

2018-05-20 19:03:04 252

原创 LeetCode上的一道题

Triangle (#120)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-05-16 19:07:47 187

原创 LeetCode上的一道题

1.   House Robber II (#213)After robbing those houses on that street, thethief has found himself a new place for his thievery so that he will not gettoo much attention. This time, all houses at this p...

2018-05-02 22:04:55 396

原创 LeetCode上的一道题

283. 移动零给定一个数组 nums, 编写一个函数将所有 0 移动到它的末尾,同时保持非零元素的相对顺序。例如, 定义 nums = [0, 1, 0, 3, 12],调用函数之后, nums 应为 [1, 3, 12, 0, 0]。注意事项:必须在原数组上操作,不要为一个新数组分配额外空间。尽量减少操作总数。算法描述:遍历列表删除列表中的0并计数,遍历完后在列表末尾加上0代码:class S...

2018-04-29 13:59:15 181

原创 leetcode上的两道题

58. 最后一个单词的长度给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。如果不存在最后一个单词,请返回 0 。说明:一个单词是指由字母组成,但不包含任何空格的字符串。示例:输入: "Hello World"输出: 5算法描述:将输入的字符串依据空格切片,切片返回一个列表,若列表为空,则return 0,若不为空,则return列表最后一个元素的长度代码:class ...

2018-04-26 23:56:33 202

原创 第十一章

11-1import unittestdef city_function(city, country): return city.title() + ', ' + country.title()class city_country_test(unittest.TestCase): def test_city_country(self): formated ...

2018-04-10 00:13:01 170

原创 第十章

10-1with open('learning_python.txt') as file: print(file.read())with open('learning_python.txt') as file: for line in file: print(line.rstrip())with open('learning_python.txt') as ...

2018-04-06 16:03:43 240

原创 第九章

9-1:class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self...

2018-04-03 01:02:28 174

原创 第八章

8-1:def display_message(): print('我们正在学函数')display_message()8-2:def favorite_book(title): print('One of my favorite books is', title)favorite_book('Alice in Wonderland')8-3:def make_shirt(size, ...

2018-03-28 22:01:01 235

原创 第七章

7-1:car = input("Please input car: ")print("Let me see if I can find you a "+car)7-2:number = int(input('请输入用餐人数:'))if number > 8: print('抱歉没有空桌了')else: print('还有空桌')7-3:num = input('请输入一个数字:...

2018-03-26 09:07:18 214

原创 第六章

6-1:friend = {'first_name': 'YIngxue', 'last_name': 'Zheng', 'age': 20, 'city': 'Hefei'}print(friend)6-2:numbers = {'Alan': 1, 'Mary': 2, 'John': 3, 'James': 4, 'Jay': 5}print('Alan', numbers['Alan'])...

2018-03-21 20:30:54 151

原创 第五章

5-2:str1 = "wo hen kai xin"str2 = "wo bu kai xin"print(str != str2)test1 = "JaiR"test2 = "jair"print(test1.lower() == test2)num1 = 10000num2 = 1238522print(num1 == num2, num1 != num2, num1 > num2, ...

2018-03-20 22:45:58 243

原创 4-1 to 4-13

4-1pizzas = ['New York Style', 'Chicago Style', 'California Style']for pizza in pizzas: print(pizza) print("I like " + pizza + " pizza")print("I really love", pizzas[0], ',', pizzas[1], "and", p...

2018-03-14 23:35:58 285

原创 第三章作业

3-1:names = ['John', 'Bob', 'James', 'Alan']for name in names: print(name)3-2:names = ['John', 'Bob', 'James', 'Alan']for name in names: print(name + ", Good afternoon!")3-3:names = ['bike', 'mo...

2018-03-12 23:08:38 251

原创 习题2-1到2-11

2-1:    simple_message.py :message = "hello world!"print(message)2-2:    simple_messages.py :message = "hello world!"print(message)message = "I'm Jair Zhu."print(message)2-3:    name_cases.py :name = ...

2018-03-07 23:00:22 390

原创 在python主页的一些发现和收获以及对未来的展望

    发现和收获:    最近几天浏览了一下python主页,发现其对初学者十分友好,对python的介绍十分详细,并有相关教程。该教程可帮助我们快速入门。    和python相比,老牌语言C和C++有许多细节需要我们自己处理,在处理不当的情况下会产生程序崩溃和其他很难解决的问题。Java虽说解决了前者的许多缺点,但相比之下代码更加冗长,写起来也有许多限制。    python简洁的语法可以让...

2018-03-06 12:55:12 752

原创 hello world!

hello world!

2018-03-05 09:39:40 171

空空如也

空空如也

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

TA关注的人

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