- 博客(20)
- 收藏
- 关注
原创 sklearn
Code:from sklearn import datasets from sklearn import cross_validation from sklearn.naive_bayes import GaussianNB from sklearn.svm import SVC from sklearn.ensemble import RandomForestClassifier from ...
2018-06-20 11:30:45
165
原创 Anscombe's quartet
%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 as sm import statsmodels.form...
2018-06-08 00:30:38
408
原创 10 Scipy
Code:Exercise 10.1: Least squares import scipy import numpy as np from scipy.optimize import minimize def error(x0, A, b): return np.linalg.norm(np.dot(A, x0) - b, ord = 2) m = 15 n = 10 A = np...
2018-05-31 22:51:00
133
原创 11 Matplotlib
11 MatplotlibExercise 11.1: Plotting a functionPlot the functionf(x) = sin2(x - 2)e-x2over the interval [0; 2]. Add proper axis labels, a title, etc.Exercise 11.2: DataCreate a data matrix X with 20 o...
2018-05-25 15:45:15
214
原创 9 Numpy
Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A 2 Rn×m and B 2 Rm×m,for n = 200, m = 500.Exercise 9.1: Matrix operationsCalculate A + A, AA>; A>A and AB. Write a...
2018-05-22 21:10:47
131
原创 String to Integer (atoi)
Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this ...
2018-05-03 03:45:38
143
原创 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2 Output: 1->2 Example 2:Input: 1->1->2->3->3 Output: 1->2->...
2018-04-29 16:27:36
91
原创 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined a...
2018-04-26 13:23:19
96
原创 665. Non-decreasing Array
Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] <= array[i + 1] holds for eve...
2018-04-24 00:59:01
85
原创 第十一章
11-1#city_functions.py def city_and_country(city, country): string = city.title() + ', ' + country.title() return string #test_cities.py import unittest from city_functions import city_and_country ...
2018-04-09 17:28:01
92
原创 第十章
10-1with open('learning_Python.txt') as pro: article = pro.read() print(article) with open('learning_Python.txt') as pro: for line in pro: print(line.rstrip()) lines = [] with open('learning_...
2018-04-06 14:41:12
121
原创 第九章
9-1class Restaurant(): def __init__(self, name, type_,number_served = 0 ): self.restaurant_name = name self.cuisine_type = type_ self.number_served = number_served def describe_restaurant(s...
2018-04-02 13:38:56
125
原创 第八章
8-1def display_message(): print('I have learnt how to use function in this chapter.') display_message()8-2def favourite_book(title): print('One of my favourite book is ' + title + '.') fa...
2018-03-28 14:01:13
94
原创 第七章
7-1car = input('Please tell me which kind of car you want:\n') print('Let me see if I can find you a ' + car + ' .')7-2seats = int(input('How many seats do you want?\n')) if seats > 8: print('Sorr...
2018-03-26 02:03:20
107
原创 第六章
6-1friend = {'fist_name':'John','last_name':'Steve','age':15,'city':'Guangzhou'} print(friend) 6-5rivers = { 'nile':'egypt', 'Changjiang_River':'China', 'Rhine River':'Germany' } for river,country in...
2018-03-21 20:06:19
98
原创 第五章
5-2print('car'=='car') print('car'=='caa') print('car'!='car') print('car'!='caa') print('car'=='Car'.lower()) print('car'=='Caa'.lower()) print(2 == 1) print(2 != 1) print(2 > 1) print(2 < 1) p...
2018-03-19 13:23:57
165
原创 第四章
4-2animals = ['cat','dog','bird'] for animal in animals: print(animal) print('A ' + animal + ' would make a great pet.') print('Any of these animals would make a great pet.')4-3for num in range(1,21...
2018-03-15 13:26:33
147
1
原创 第三章作业
3-1names = ['Joker','James','Key'] print(names[0]) print(names[1]) print(names[2])3-2names = ['Joker','James','Key'] for name in names: print('Hello, '+name)3-3vehicles = ['car','bike','boat','plane'...
2018-03-12 17:04:03
133
原创 No.2
2-1message = 'hello,world' print(message)2-2message = 'hello,bit' print(message)2-3name = 'Eric' print('"Hello '+name+', would you like to learn some Python today?"')2-4name = "huang zilin" print(name...
2018-03-11 17:29:40
120
原创 No.1
浏览python主页后的发现及收获: 在python主页浏览的主要是python的一些基本信息,特点、编译环境、语法等等,发现python主要有以下特点: python的语法非常简洁,许多语句的写法非常接近人的思维,很容易理解,且因为是动态语言,连变量的声明都不需要,实现相同的功能时,代码量明显少于c或者c++,但是为此python也付出了代价,python程序的运行时间是远超...
2018-03-11 16:15:02
172
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人