自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 奶牛编号

牛牛养了n只奶牛,牛牛想给每只奶牛编号,这样就可以轻而易举地分辨它们了。 每个奶牛对于数字都有自己的喜好,第i只奶牛想要一个1和x[i]之间的整数(其中包含1和x[i])。 牛牛需要满足所有奶牛的喜好,请帮助牛牛计算牛牛有多少种给奶牛编号的方法,输出符合要求的编号方法总数。 输入描述: 输入包括两行,第一行一个整数n(1 ≤ n ≤ 50),表示奶牛的数量 第二行为n个整数x[i](1 ≤...

2018-08-30 10:31:55 939

原创 100-Days-Of-ML-Code-day4/5/6-Logistic Regression

从这里下载数据集步骤1 数据预处理导入库import numpy as numpyimport matplotlib.pyplot as pltimport pandas as pd导入数据集dataset = pd.read_csv('Social_Network_Ads.csv')X = dataset.iloc[:, [2, 3]].valuesY =...

2018-08-29 13:44:25 497

转载 python 的decorator

注意:我们要借助Python的@语法,把decorator置于函数的定义处初步尝试:def log(func): def wrapper(*args, **kw): print ‘begin call: %s’ %func.__name__ return func(*args, **kw) print ‘end call: %s’ %fu...

2018-08-28 18:07:53 556

原创 filter()删除1~100的素数

def del_prime(n): if n == 1: return True for i in range(2,n): if n%i==0: return True return False filter(del_prime, [x for x in ...

2018-08-28 14:37:01 985

原创 python 高阶函数map/reduce

利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。输入:[‘adam’, ‘LISA’, ‘barT’],输出:[‘Adam’, ‘Lisa’, ‘Bart’]。def func(x): return x.title()str = ['adAm', 'LISA', 'barT']map(func,str)capitalize() #字符串...

2018-08-28 14:03:00 142

转载 SQL SELECT DISTINCT 语句和Limit的用法

1.SQL SELECT DISTINCT 语句 在表中,可能会包含重复值。这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值。关键词 DISTINCT 用于返回唯一不同的值。"Orders"表:Company OrderNumberIBM 3532W3School 2356Apple 4698W3School 6...

2018-08-27 18:36:34 1828

原创 100-Days-Of-ML- day3 Multiple Linear Regression.

第1步: 数据预处理导入库import pandas as pdimport numpy as np导入数据集dataset = pd.read_csv('50_Startups.csv')X = dataset.iloc[ : , :-1].valuesY = dataset.iloc[ : , 4 ].values解析分类数据from sklearn...

2018-08-22 21:12:44 262

原创 4. Median of Two Sorted Arrays

我真的没想到我这样写能过,本以为会超过他要求的时间复杂度class Solution: def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float ...

2018-08-22 20:19:32 116

原创 100-days-of-ML-day2 --Simple Linear Regression

100-Days-Of-ML-Code中文版 链接如下 100-Days-Of-ML-Code中文版第一步 数据预处理import pandas as pdimport numpy as npimport matplotlib.pyplot as pltdataset = pd.read_csv('studentscores.csv')X = dataset.iloc[ ...

2018-08-21 11:07:37 664

原创 leetcode 347. Top K Frequent Elements

def topKFrequent(self, nums, k): """ :type nums: List[int] :type k: int :rtype: List[int] """ dict = {} result = [] for i in range(len(n...

2018-08-20 21:57:11 152

原创 100day of ML DAY1 ——data preprocessing

这个100天搞定机器学习编程的项目,现在已经是爆红GitHub。项目地址day1数据预处理第一步 导入一些库,numpy和pandasNumpy里面有各种数学函数,Pandas是用来导入数据集、管理数据集的。import numpy as npimport pandas as pd第二步 导入数据集在Pandas库里面,用read_csv的方法,来读取本地...

2018-08-20 14:16:41 529

原创 opencv两个版本不兼容的问题

1.’module’ object has no attribute ‘boxPoints’opencv版本不兼容 cv2.boxPoints()改为cv2.cv.BoxPoints()2.findContours need more than 2 values to unpackcv2.findContours 只有两个返回值.改为下面的形式 contours,hierarchy...

2018-08-08 18:22:34 1514

转载 python按照多个条件排序

对tuple进行排序,先按照第一个元素升序,如果第一个元素相同,再按照第二个元素降序排列。L = [(12, 12), (34, 13), (32, 15), (12, 24), (32, 64), (32, 11)]L.sort(key=lambda x: (x[0], -x[1]))print(L)结果:[(12, 24), (12, 12), (32, 64), (32, 15),...

2018-08-08 09:08:28 1212

空空如也

空空如也

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

TA关注的人

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