- 博客(19)
- 收藏
- 关注
原创 classification dataset 分类数据集
import numpy as npX = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])Y = np.array([1, 1, 1, 2, 2, 2])from sklearn.naive_bayes import GaussianNBclf = GaussianNB()#拟合数据clf.fit(X, ...
2018-06-30 14:53:46 3400
原创 Anscombe's quartet
%matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.form...
2018-06-09 14:05:05 237
原创 13 Iterators
import numpy as np#13.1def collatz(n): if n % 2 == 0: yield n // 2 else: yield 3 * n + 1if __name__ == '__main__': n = input() print(collatz(int(n))) n = colla...
2018-06-01 12:28:05 132
原创 Matplotlib
# -*- coding: utf-8 -*- import matplotlib #https://blog.csdn.net/zjjtilm/article/details/79106348#导入包import matplotlib.pyplot as pltimport numpy as npimport math # 确定坐标轴 plt.xlim((-2, 2))...
2018-05-27 13:53:33 192
原创 Python 矩阵Numpy
import numpy as npa = np.array([(1,2),(-1,2)])b = np.array([(2,3),(-1,2)])#c = np.ones((2,2))print(a)print(b)print('\n\n')#9-1print(a + a)print(a * a.T)print(a.T * a)print(a * b)p = 1x ...
2018-05-18 11:31:53 262
原创 Python 28
def strStr(haystack, needle): if not needle: return 0 for index, value in enumerate(haystack): if value==needle[0] and haystack[index:len(needle)+index]==needle: r...
2018-05-06 17:14:57 155
原创 python 算法作业 leetcode 7&258
#7def reverse(x): x = int(str(x)[::-1]) if x >= 0 else - int(str(-x)[::-1]) return x if x < 2147483648 and x >= -2147483648 else 0#258def addDigits(num): return 1 + (num - 1) % 9
2018-04-28 13:25:01 156
原创 leetcode 66
def plusOne(digits): a = 0 index = 1 count = 0 New = [] for digit in digits: a = a * 10 + digit index = index * 10 count = count + 1 a = a + 1 if a % 10 == 0: New.append(1) for...
2018-04-24 10:47:22 135
原创 Python 第十一章
def City(city, country, population): return city + ' ' + country + ' ' + population; class Employee(): def __init__(self, first_name, second_name, annual_salary): self.first_name = first_name ...
2018-04-09 21:41:43 114
原创 Python 第十章
#10-1print('10-1')filename = 'learn.txt'with open(filename) as file_object: contents = file_object.read() lines = file_object.readlines() for line in file_object: print(line)print(contents)f...
2018-04-04 21:20:44 167
原创 Python 第九章
#9-6print('9-6')class Restaurant(): def __init__(self, name, type): self.name = name self.type = type def describe_restaurant(self): print('The name of restaurant is :' + self.name) pri...
2018-04-02 13:27:09 181
原创 Python 第八章
#8-2print('#8-2')def favorite_book(book): print('One of my favorite book is ' + book.title())favorite_book('The Kite Runner')#8-3print('#8-3')def make_shirt(size = 2, message = 'Love'): print...
2018-03-28 22:00:50 289
原创 Python 第七章
代码:#7-1print('#7-1')car = input('Which car would you like ?\n')print('Let me see if I can find you a ' + car + ' .\n')#7-2print('#7-2')number = input('How many people are in your dinner group ?...
2018-03-27 12:42:18 319
原创 Python 第六章
#6-1print('6-1\n')Red = {'first_name':'Alan','last_name':'Waker','age':12,'city':'Beijing'}print(Red)#6-2print('\n6-2\n')Love_number = {'A':1,'B':2,'C':3,'D':4,'E':5}print(Love_number)#6-5p...
2018-03-21 21:30:59 129
原创 Python 第五章
源码:#5-3print('5-3\n')alien_color = 'green'if alien_color == 'green': print('You have just earned 5 points!')else: print('')print('\n') alien_color = 'red'if alien_color == 'green': print('Y...
2018-03-19 20:51:03 268
原创 Python第四章 Working with Lists
#4-3for value in range(1,21): print(value, end = ' ')print('\n') #4-6for value in range(1,21,2): print(value, end = ' ')print('\n') #4-7lists = []for value in range(3,31,3): lists.append(...
2018-03-14 21:47:27 92
原创 Python 第三章Lists
#3-4people = ['Jim', 'Tom', 'Hitler']print(people)print(people[0] + " , would you like to have a dinner with me ?")print(people[1] + " , would you like to have a dinner with me ?")print(people[2]...
2018-03-12 13:35:45 126
原创 Python之变量和简单数据类型
1 习题2-3>>> print(name)Tom>>> print(name + ", would you like have a cup of tea?")Tom, would you like have a cup of tea?2 习题2-4>>> name = 'Tom'>>> print(n
2018-03-08 10:54:58 163
原创 初识Python
一、访问Python的发现和体会 在浏览Python的主页过程中,我发现 1 它的网站设计非常简明,突出重点。比如在网站的上面,点击menu后网站的左边,以及网站的下面都有网站地图, 列出了包括教程、下载、文档、工作和社区等等一系列重要的项目。 2 网站中最突出的是Python的特点和优点,给浏览网页的开发者提供一些使用它的理由。 ...
2018-03-06 21:55:42 96
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人