摘要: #题目描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.#解题思路:首先我们要了解罗马数字怎么写的个位数举例I, 1 】II, 2】... 阅读全文
posted @ 2015-02-05 22:51 mrbean 阅读(265) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest for... 阅读全文
posted @ 2015-02-04 17:04 mrbean 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 最近因为想要看漫画,无奈下载的漫画是jpg的格式,网上的转换器还没一个好用的,于是乎就打算用python自己DIY一下:这里主要用了reportlab。开始打算随便写几行,结果为若干坑纠结了挺久,于是乎就想想干脆把代码写好点吧。#实现了以下的几项功能:* 将当前文件夹下的图片保存到一个pdf中,支持... 阅读全文
posted @ 2015-01-30 00:09 mrbean 阅读(2360) 评论(2) 推荐(4) 编辑
摘要: 来自为知笔记(Wiz) 阅读全文
posted @ 2015-01-24 17:51 mrbean 阅读(537) 评论(0) 推荐(0) 编辑
摘要: ![居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不让发居然不... 阅读全文
posted @ 2015-01-24 17:32 mrbean 阅读(716) 评论(0) 推荐(0) 编辑
摘要: 首先用Anaconda是因为方便(管理方便,包安装真心不方便)。下面是我的安装过程:首先使用如下命令安装opencvconda install -c https://conda.binstar.org/menpo opencv不过装完之后用不了,这时候找到如下文件夹Anaconda\pkgs\ope... 阅读全文
posted @ 2015-01-24 14:58 mrbean 阅读(26063) 评论(0) 推荐(0) 编辑
摘要: #题目描述:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating lett... 阅读全文
posted @ 2015-01-22 17:02 mrbean 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are ... 阅读全文
posted @ 2015-01-22 15:22 mrbean 阅读(256) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set ... 阅读全文
posted @ 2015-01-22 00:41 mrbean 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #题目描述:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a s... 阅读全文
posted @ 2015-01-22 00:00 mrbean 阅读(186) 评论(0) 推荐(0) 编辑
摘要: #题目简述:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity shou... 阅读全文
posted @ 2015-01-21 22:22 mrbean 阅读(221) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in... 阅读全文
posted @ 2015-01-19 14:47 mrbean 阅读(208) 评论(0) 推荐(0) 编辑
摘要: #题目描述:Given an integer n, return the number of trailing zeroes in n!.**Note**: Your solution should be in logarithmic time complexity.#解题思路:这个题目给的评级是e... 阅读全文
posted @ 2015-01-18 23:30 mrbean 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #题目概述:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn... 阅读全文
posted @ 2015-01-18 19:29 mrbean 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #题目概述:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume tha... 阅读全文
posted @ 2015-01-17 17:25 mrbean 阅读(1721) 评论(0) 推荐(0) 编辑
摘要: #题目简述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can y... 阅读全文
posted @ 2015-01-17 16:00 mrbean 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the ... 阅读全文
posted @ 2015-01-16 22:25 mrbean 阅读(216) 评论(0) 推荐(0) 编辑
摘要: #题目简述:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to sho... 阅读全文
posted @ 2015-01-16 18:42 mrbean 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 解决方法:这个貌似是属于一个bug把Image.py中的1500行左右的split函数改成如下即可: def split(self): "Split image into bands" self.load() if self.im.bands == 1... 阅读全文
posted @ 2015-01-16 14:49 mrbean 阅读(1213) 评论(0) 推荐(0) 编辑
摘要: 找到PIL安装文件里的ImageShow.py把第99行的 return "start /wait %s && del /f %s" % (file, file) 修改成 return "start /wait %s && PING 127.0.0.1 -n 5 > NUL && del... 阅读全文
posted @ 2015-01-14 18:13 mrbean 阅读(473) 评论(0) 推荐(0) 编辑
摘要: #题目描述:##Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A ... 阅读全文
posted @ 2014-12-30 00:38 mrbean 阅读(1424) 评论(0) 推荐(0) 编辑
摘要: #题目概要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix: ... 阅读全文
posted @ 2014-12-29 23:54 mrbean 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a collection of numbers, return all possible permutations. For example, have the following permutations: , and . 解题思路: 这道题目由于是求所有的全排列,比较直观 阅读全文
posted @ 2014-12-22 17:10 mrbean 阅读(212) 评论(0) 推荐(0) 编辑
摘要: #题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted... 阅读全文
posted @ 2014-12-20 01:01 mrbean 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #题目描述:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in t... 阅读全文
posted @ 2014-12-19 12:36 mrbean 阅读(270) 评论(0) 推荐(0) 编辑
摘要: ##win7下复制文件的时候发生了这个问题搜索发现是因为win7支持的最长的文件名称260个字符,我这个目录搞的太深了。。。 阅读全文
posted @ 2014-12-14 13:33 mrbean 阅读(2282) 评论(0) 推荐(0) 编辑
摘要: 协同过滤(collaborative filtering)推荐系统:百度百科的定义是:它是利用电子商务网站向客户提供商品信息和建议,帮助用户决定应该购买什么产品,模拟销售人员帮助客户完成购买过程主要有有以下几种推荐的方式:基于内容的推荐协同过滤关联推荐混合推荐协同过滤这里我们主要考虑的是协同过滤,这... 阅读全文
posted @ 2014-12-13 00:12 mrbean 阅读(3857) 评论(0) 推荐(1) 编辑
摘要: SVD(Singular Value Decomposition,奇异值分解)算法优缺点:优点:简化数据,去除噪声,提高算法结果缺点:数据的转换可能难于理解适用数据类型:数值型数据算法思想:很多情况下,数据的一小部分包含了数据的绝大部分信息,线性代数中有很多矩阵的分解技术可以将矩阵表示成新的易于处理... 阅读全文
posted @ 2014-12-12 00:06 mrbean 阅读(7487) 评论(0) 推荐(0) 编辑
摘要: Principal Component Analysis算法优缺点:优点:降低数据复杂性,识别最重要的多个特征缺点:不一定需要,且可能损失有用的信息适用数据类型:数值型数据算法思想:降维的好处:使得数据集更易使用降低很多算法计算开销去除噪声使得结果易懂主成分分析(principal componen... 阅读全文
posted @ 2014-12-10 23:25 mrbean 阅读(2718) 评论(3) 推荐(0) 编辑
摘要: 机器学习实战笔记索引 最近通过学习《机器学习实战》把书结合网上的一些博客都完整的看了下,感觉还是很有收获的,稍微总结了下,留着复习吧 "kNN算法python实现和简单数字识别" "决策树的python实现" "朴素贝叶斯算法的python实现" "Logistic回归 python实现" "Log 阅读全文
posted @ 2014-12-10 18:57 mrbean 阅读(2047) 评论(0) 推荐(2) 编辑
摘要: FP-growth算法优缺点:优点:一般快于Apriori缺点:实现比较困难,在某些数据上性能下降适用数据类型:标称型数据算法思想:FP-growth算法是用来解决频繁项集发现问题的,这个问题再前面我们可以通过Apriori算法来解决,但是虽然利用Apriori原理加快了速度,仍旧是效率比较低的。F... 阅读全文
posted @ 2014-12-09 23:55 mrbean 阅读(3429) 评论(0) 推荐(2) 编辑
摘要: Apriori算法优点:易编码实现缺点:在大数据集上可能较慢适用数据类型:数值型或者标称型算法过程:关联分析是一种在大规模数据集中寻找有意思的关系的任务,这里的有意思的关系有两种:频繁项集(frequent item sets)或关联规则(association rules)。支持度(support... 阅读全文
posted @ 2014-12-08 00:27 mrbean 阅读(4683) 评论(0) 推荐(3) 编辑
摘要: 线性回归算法优缺点:优点:结果易于理解,计算不复杂缺点:对非线性数据拟合不好适用数据类型:数值型和标称型算法思想:这里是采用了最小二乘法计算(证明比较冗长略去)。这种方式的优点是计算简单,但是要求数据矩阵X满秩,并且当数据维数较高时计算很慢;这时候我们应该考虑使用梯度下降法或者是随机梯度下降(同Lo... 阅读全文
posted @ 2014-12-05 23:56 mrbean 阅读(11279) 评论(0) 推荐(1) 编辑
摘要: AdaBoost(自适应boosting,adaptive boosting)算法算法优缺点:优点:泛化错误率低,易编码,可用在绝大部分分类器上,无参数调整缺点:对离群点敏感适用数据类型:数值型和标称型元算法(meta algorithm)在分类问题中,我们可能不会只想用一个分类器,我们会考虑将分类... 阅读全文
posted @ 2014-12-04 00:26 mrbean 阅读(4715) 评论(1) 推荐(2) 编辑
摘要: 二分K-means聚类(bisecting K-means)算法优缺点:由于这个是K-means的改进算法,所以优缺点与之相同。算法思想:1.要了解这个首先应该了解K-means算法,可以看这里这个算法的思想是:首先将所有点作为一个簇,然后将该簇一分为二。之后选择能最大程度降低聚类代价函数(也就是误... 阅读全文
posted @ 2014-11-29 00:33 mrbean 阅读(11957) 评论(0) 推荐(4) 编辑
摘要: K-means聚类算法算法优缺点:优点:容易实现缺点:可能收敛到局部最小值,在大规模数据集上收敛较慢使用数据类型:数值型数据算法思想k-means算法实际上就是通过计算不同样本间的距离来判断他们的相近关系的,相近的就会放到同一个类别中去。1.首先我们需要选择一个k值,也就是我们希望把数据分成多少类,... 阅读全文
posted @ 2014-11-28 00:53 mrbean 阅读(72146) 评论(8) 推荐(6) 编辑
摘要: read直接读入整个文件,存成一个字符串变量readline一行一行读入文件,所以说读取的文件可以大于内存,但是读取的速度很慢readlines一次读取整个文件,存成一个列表,所以说也必须小于内存。从使用上来说,除非是文件太大一般不用readline如文件如下:代码如下结果如下:来自为知笔记(Wiz... 阅读全文
posted @ 2014-11-27 16:07 mrbean 阅读(1138) 评论(0) 推荐(0) 编辑
摘要: listThe Average Case assumes parameters generated uniformly at random.Internally, a list is represented as an array; the largest costs come from growing beyond the current allocation size (because eve... 阅读全文
posted @ 2014-11-27 16:06 mrbean 阅读(2548) 评论(0) 推荐(0) 编辑
摘要: Logistic回归的使用和缺失值的处理从疝气病预测病马的死亡率数据集:UCI上的数据,368个样本,28个特征测试方法:交叉测试实现细节:1.数据中因为存在缺失值所以要进行预处理,这点待会再单独谈2.数据中本来有三个标签,这里为了简单直接将未能存活和安乐死合并了3.代码中计算10次求均值缺失值的处... 阅读全文
posted @ 2014-11-25 00:26 mrbean 阅读(1928) 评论(0) 推荐(1) 编辑
摘要: Max Points on a Line题目描述:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.解题思路:1.首先由这么一个O(n^3)的方法,也就... 阅读全文
posted @ 2014-11-24 13:10 mrbean 阅读(398) 评论(0) 推荐(0) 编辑