自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 classification dataset 分类数据集

import numpy as np X = 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 GaussianNB clf = GaussianNB() #拟合数据 clf.fit(X, ...

2018-06-30 14:53:46 3530

原创 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-09 14:05:05 296

原创 13 Iterators

import numpy as np #13.1 def collatz(n): if n % 2 == 0: yield n // 2 else: yield 3 * n + 1 if __name__ == '__main__': n = input() print(collatz(int(n))) n = colla...

2018-06-01 12:28:05 177

原创 Matplotlib

# -*- coding: utf-8 -*- import matplotlib #https://blog.youkuaiyun.com/zjjtilm/article/details/79106348 #导入包 import matplotlib.pyplot as plt import numpy as np import math # 确定坐标轴 plt.xlim((-2, 2))...

2018-05-27 13:53:33 243

原创 Python 矩阵Numpy

import numpy as np a = 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-1 print(a + a) print(a * a.T) print(a.T * a) print(a * b) p = 1 x ...

2018-05-18 11:31:53 310

原创 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 196

原创 python 算法作业 leetcode 7&258

#7 def 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#258 def addDigits(num): return 1 + (num - 1) % 9

2018-04-28 13:25:01 209

原创 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 170

原创 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 157

原创 Python 第十章

#10-1 print('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 222

原创 Python 第九章

#9-6 print('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 237

原创 Python 第八章

#8-2 print('#8-2') def favorite_book(book): print('One of my favorite book is ' + book.title()) favorite_book('The Kite Runner') #8-3 print('#8-3') def make_shirt(size = 2, message = 'Love'): print...

2018-03-28 22:00:50 337

原创 Python 第七章

代码:#7-1 print('#7-1') car = input('Which car would you like ?\n') print('Let me see if I can find you a ' + car + ' .\n') #7-2 print('#7-2') number = input('How many people are in your dinner group ?...

2018-03-27 12:42:18 393

原创 Python 第六章

#6-1 print('6-1\n') Red = {'first_name':'Alan','last_name':'Waker','age':12,'city':'Beijing'} print(Red) #6-2 print('\n6-2\n') Love_number = {'A':1,'B':2,'C':3,'D':4,'E':5} print(Love_number) #6-5 p...

2018-03-21 21:30:59 166

原创 Python 第五章

源码:#5-3 print('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 318

原创 Python第四章 Working with Lists

#4-3 for value in range(1,21): print(value, end = ' ') print('\n') #4-6 for value in range(1,21,2): print(value, end = ' ') print('\n') #4-7 lists = [] for value in range(3,31,3): lists.append(...

2018-03-14 21:47:27 129

原创 Python 第三章Lists

#3-4 people = ['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 166

原创 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 198

原创 初识Python

一、访问Python的发现和体会        在浏览Python的主页过程中,我发现        1    它的网站设计非常简明,突出重点。比如在网站的上面,点击menu后网站的左边,以及网站的下面都有网站地图, 列出了包括教程、下载、文档、工作和社区等等一系列重要的项目。        2    网站中最突出的是Python的特点和优点,给浏览网页的开发者提供一些使用它的理由。       ...

2018-03-06 21:55:42 129

空空如也

空空如也

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

TA关注的人

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