- 博客(16)
- 收藏
- 关注
原创 [Course] Advanced Computer Programming, Homework, week 15, scikit-learn
scikit-learn example import numpy as np from sklearn import metrics from sklearn import datasets from sklearn.model_selection import cross_validate from sklearn.naive_bayes import GaussianNB from s...
2018-06-18 14:04:50 260
原创 [Course] Advanced Computer Programming, Homework, week 14, Jupyter Notebook
Jupyter Notebook Exercises %matplotlib inline import random import numpy as np import scipy as sp import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import statsmodels.api a...
2018-06-12 20:51:21 270
原创 [Course] Advanced Computer Programming, Homework, week 13, SciPy
10.1 Least squares import numpy as np import matplotlib.pyplot as plt from scipy.linalg import * m = 20 n = 15 A = np.random.random((m, n)) b = np.random.random((m,)) cc, re, rank, sigma = lstsq...
2018-06-05 19:45:33 241
原创 [Course] Advanced Computer Programming, Homework, week 12, Matplotlib
在jupyter notebook中书写,%matplotlib inline 可使图片直接显示 %matplotlib inline import matplotlib.pyplot as plt import numpy as np 1.11 Plotting a function Plot the function f(x)=sin2(x−2)e−x2f(x)=sin2(x−2)e...
2018-05-29 11:03:48 205
原创 [Course] Advanced Computer Programming, Homework, week 12, NumPy
Some NumPy Exercises Some NumPy Exercises 9.1 Matrix operations 9.2 Solving a linear system 9.3 Norms 9.4 Power iteration 9.5 Singular values 9.6 Nearest neighbor Generate matrices A, with r...
2018-05-22 18:48:29 280
原创 [Course] Advanced Computer Programming, Homework, week 9-2, LeetCode 215. Kth Largest Element
215. Kth Largest Element in an Array 题目来源 https://leetcode.com/problems/kth-largest-element-in-an-array/description/ 题意分析 找出序列中第k大元素 题目思路 用快速选择算法求解,即随机选择数组中的一个数,进行划分,若划分的这个数恰好是第k大,那么返回结果。若...
2018-05-02 21:50:21 206
原创 [Course] Advanced Computer Programming, Homework, week 9-1, LeetCode 148. Sort List
148. Sort List 题目来源 https://leetcode.com/problems/sort-list/description/ 题意分析 对链表进行排序,要求复杂度为 O(NlogN)O(NlogN)O(NlogN) 题目思路 采用归并排序,与数组的归并排序在划分和合并时略有不同 代码 class Solution: def sortLis...
2018-04-29 22:24:02 148
原创 [Course] Advanced Computer Programming, Homework, week 8-2, LeetCode 134. Gas Station
134. Gas Station 题目来源 https://leetcode.com/problems/gas-station/description/ 题意分析 给定一个圈,可以从圈的任何一个位置开始, 在位置i可以获得gas[i]的能量,从i到位置i+1需要消耗cost[i]的能量, 若能够按顺时针走一圈,输出初始位置,否则输出-1 (若有解,保证解是唯一的) 题目...
2018-04-28 23:38:10 218
原创 [Course] Advanced Computer Programming, Homework, week 8-1, LeetCode 120. Triangle
120. Triangle 题目来源 https://leetcode.com/problems/triangle/description/ 题意分析 给定一个三角形矩阵,找到从上到下的最短路,每一步只能走下一行的邻接的两个数 题目思路 这是一道非常基础的DP, 采用动态规划的思想,从下往上处理,有 triangle[i][j] += min(triangle[i+1]...
2018-04-28 22:19:04 163
原创 [Course] Advanced Computer Programming, Homework, week 6
# 11-1 城市和国家 import unittest def city_functions(city, country): return city.title() + ', ' + country.title() class NamesTestCase(unittest.TestCase): def test_city_country(self): name ...
2018-04-14 20:39:18 133
原创 [Course] Advanced Computer Programming, Homework, week 5
Chapter 9 Chapter 10 Chapter 9 # 9-1 餐馆 class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = ...
2018-04-08 10:01:47 203
原创 [Course] Advanced Computer Programming, Homework, week 4
Chapter 7 Chapter 8 Chapter 7 # 7-1 汽车租赁 car = input("Which type of car do you like? ") print("\nLet me see if I can find you a", car) Which type of car do you like? red car Let me see if I c...
2018-03-28 22:36:25 214
原创 [Course] Advanced Computer Programming, Homework, week 3
Chapter 5 Chapter 6 Chapter 5 # 5-1 条件测试 for i in range(10): print(i%2==0) True False True False True False True False True False # 外星人颜色#1 alien_color = 'green' if alien_color == '...
2018-03-21 21:47:14 144
原创 [Course] Advanced Computer Programming, Homework, week 2
Chapter 3 Chapter 4 Chapter 3 # 3-1 姓名 names = ['Tom', 'Jerry', 'Jack'] for name in names: print(name, end=', ') Tom, Jerry, Jack, # 3-6 添加嘉宾 persons = ['Tom', 'Jerry', 'Jack'] per...
2018-03-15 21:03:05 228
原创 [Course] Advanced Computer Programming, Homework, week 1
Advanced Computer Programming, Homework, week 1 Advanced Computer Programming, Homework, week 1 1.浏览Python主页(https://www.python.org/),在博客上写下你有哪些发现和收获 2.假设你已经成为一名Python编程高手,你打算实现怎样的程序?在博客上写下你的目标 3.教...
2018-03-10 00:44:17 251
原创 CSDN Markdown编辑器基本测试
CSDN Markdown编辑器基本测试 CSDN Markdown编辑器基本测试 基础 数学公式 代码块 图片 经过测试,体验还是相当不错的 PS: 编辑的时候不能使用Grammarly插件,否则会在语法检查的时候触发奇妙的开关,无限加入换行最后导致csdn的markdown编辑器卡慢奔溃… 基础 加粗 删除线 分点 one tw...
2018-03-08 23:05:05 309
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人