- 博客(18)
- 收藏
- 关注
原创 scikit learn
scikit learnIn the second ML assignment you have to compare the performance of three different classification algorithms, namely Naive Bayes, SVM, and Random Forest.For this assignment you need to ...
2018-06-19 21:36:42
285
原创 Anscombe's quartet
Anscombe’s quartetPart 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+...
2018-06-12 11:17:01
364
原创 Scipy
ScipyExercise 10.1: Least squaresGenerate matrix A∈Rm×nA∈Rm×nA\in R^{m\times n} with m>nm>nm>n. Also generate some vector b∈Rmb∈Rmb \in R^m. Now find x=argminx||Ax−b||2x=argminx||Ax−b||2x=...
2018-06-03 10:36:51
228
原创 Matplotlib
Matplotlib11.1 Plotting a functionPlot the function f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e−x2f(x)=sin^2(x-2)e^{-x^2} over the interval [0,2]. Add proper axis labels, a title, etc.import matplotli...
2018-05-29 11:06:29
283
原创 Numpy
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈ R n×m and B ∈ R m×m , for n = 200, m = 500.import numpy as npfrom scipy.linalg import toeplitzdef main(): n = 200...
2018-05-21 20:40:26
258
原创 LeetCode第120题详解
题目:给定一个三角形,找出自顶向下的最小路径和。每一步只能移动到下一行中相邻的结点上。例如,给定三角形:[ [2], [3,4], [6,5,7], [4,1,8,3]]自顶向下的最小路径和为 11(即,2 + 3 + 5 + 1 = 11)。说明:如果你可以只使用 O(n) 的额外空间(n 为三角形的总行数)来解决这个问题,那么你的算法会很加分。解答:只需要从下往...
2018-05-01 17:56:29
604
原创 LeetCode第55题详解
题目:给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。判断你是否能够到达最后一个位置。示例 1:输入: [2,3,1,1,4]输出: true解释: 从位置 0 到 1 跳 1 步, 然后跳 3 步到达最后一个位置。示例 2:输入: [3,2,1,0,4]输出: false解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳...
2018-05-01 17:49:47
1000
原创 Leetcode第35题详解
首先先看题目:给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。你可以假设数组中无重复元素。示例 1:输入: [1,3,5,6], 5输出: 2示例 2:输入: [1,3,5,6], 2输出: 1示例 3:输入: [1,3,5,6], 7输出: 4示例 4:输入: [1,3,5,6], 0输出: 0这是寻找插入位置...
2018-04-25 20:03:38
564
原创 教材第十章习题
10-1 Python学习笔记with open('learning_python.txt') as txt: contents = txt.read() print(contents.rstrip())with open('learning_python.txt') as txt: for line in txt: print(line.rstrip())with open('...
2018-04-21 11:33:27
390
原创 教材第九章习题
9-1 餐馆class Restaurant(): def __init__(self,name,type): self.restaurant_name = name self.cuisine_type = type def describe_restaurant(self): print("The name of the restaurant is " + self.resta...
2018-04-10 19:06:12
241
原创 教材第八章习题
8-1 消息def display_message(): print("I learn fuctions")display_message()输出I learn fuctions8-2 喜欢的图书def favorite_book(title): print("One of my favorite books is " + title + ".")favorite_book("Ali...
2018-04-10 10:32:02
268
原创 教材第七章习题
7-1 汽车租赁car = input("What kind of car do you want to rent? ")print("Let me see if I can find you a " + car)输出What kind of car do you want to rent? Hangyu carLet me see if I can find you a Hangyu car...
2018-04-01 19:54:26
278
原创 教材第六章练习题
6-1 人info = {'first_name' : 'Jin', 'last_name' : 'Hangyu', 'age' : 20, 'city' : 'Kunming'}print('first name is ' + info['first_name'] + ' last name is ' + info['last_name'] + ', and age is '+ str(inf...
2018-03-26 20:39:23
228
原创 教材第五章练习题
5-3 外星人颜色#1alien_color = 'green'if(alien_color == 'green'): print("You get 5 points!")alien_color = 'yellow'if(alien_color == 'green'): print("You get 5 points!")输出You get 5 points!5-4 外星人颜色#2al...
2018-03-19 19:39:48
427
原创 教材第四章练习题
4-1 比萨pizzas = ['pepperoni pizza', 'beef pizza', 'chicken pizza']for pizza in pizzas: print(pizza)for pizza in pizzas: print("I like " + pizza + ".")print("I really love pizza!")输出pepperoni pizza...
2018-03-15 15:22:54
247
原创 教材第三章练习题
前言必须指出的是,由于在第二章内书中并未提及for循环的使用,于是我在此博客中提到的代码均未使用循环语句。但实际上,使用循环语句会使得代码更为简洁。例如3-4题中,用for循环版本的代码如下names = ['Jobs','Liu Bei','Jin Hangyu']for name in names: print('I would like to have a dinner with you...
2018-03-13 19:46:01
244
原创 教材第二章练习题
2-1 简单消息message = "I love python"print(message)输出I love python2-2 多条简单消息message = "I love python"print(message)message = "I love C++, too"print(message)输出I love pythonI love C++, too2-3 个性化消息nam...
2018-03-11 19:05:56
223
原创 站在Python的大门前
本学期选了林瀚老师的《高级编程技术》这门课,本博客也是因林瀚老师的作业要求而设。《高级编程技术》这门课,主要是关于Python语言的学习。早就对Python这个简洁优美的语言有所耳闻。Python是著名的“龟叔”Guido van Rossum在1989年圣诞节期间,为了打发无聊的圣诞节而随手编写的一个编程语言。直到今天,Python依然在编程语言中占有非常重要的地位。目前世界上共有编程语言600...
2018-03-05 20:39:55
206
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人