![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 72
momottyy
这个作者很懒,什么都没留下…
展开
-
【python与机器学习入门1】KNN(k近邻)算法2 手写识别系统
参考博客:超详细的机器学习python入门knn干货 (po主Jack-Cui参考书籍:《机器学习实战》——第二章KNN入门第二弹——手写识别系统demo——《机器学习实战》第二章2.3 手写识别系统 这应该是机器学习里很经典的一个例子了,做法有很多,数据集也很多,研一时选修的计算机视觉的大作业也是这个。这篇博客从KNN角度进行分类。KNN详细内容见前篇目录...原创 2018-08-29 21:06:22 · 389 阅读 · 1 评论 -
【python和机器学习入门2】决策树2——决策树构建
参考博客:决策树实战篇之为自己配个隐形眼镜 (po主Jack-Cui,《——大部分内容转载自 参考书籍:《机器学习实战》——第三章目录一 构建决策树1.1 决策树构建原理1.2 决策树结构1.3决策树构建关键代码1.4 构建完整代码1.5 使用构建的决策树进行预测分类二 决策树的存储《——决策树概念子模块等见前篇一...原创 2018-09-04 10:14:17 · 1981 阅读 · 3 评论 -
【python与机器学习入门2】决策树1——决策树概念和子模块
参考博客:决策树基础篇之让我们从相亲说起 (po主Jack-Cui,《——大部分内容转载自 信息熵与ID3算法参考 (po主青松愉快,《——信息增益内容参考 机器学习实战(三)——决策树(po主 呆呆的猫,《——信息增益内容参考参考书籍:《机器学习实战》——第三章摘要:本章介绍了决策树算法概念和构建决策树所...原创 2018-08-30 17:56:59 · 706 阅读 · 0 评论 -
【python和机器学习入门2】决策树3——使用决策树预测隐形眼镜类型
参考博客:决策树实战篇之为自己配个隐形眼镜 (po主Jack-Cui,《——大部分内容转载自 参考书籍:《机器学习实战》——第三章3.4《——决策树基础知识见前两篇 ,摘要:本篇用一个预测隐形眼镜类型的例子讲述如何建树、可视化,并介绍了用sklearn构建决策树的代码目录1 数据处理2 完整代码3 Matplotlib可视化...原创 2018-09-05 09:52:02 · 2316 阅读 · 1 评论 -
【python与机器学习入门3】朴素贝叶斯2——垃圾邮件分类
参考博客:朴素贝叶斯基础篇之言论过滤器 (po主Jack-Cui,《——大部分内容转载自 参考书籍:《机器学习实战》——第四章4.6朴素贝叶斯基础内容见前篇《——1 数据集ham文件夹 正常邮件spam文件夹 垃圾邮件2 数据处理3 训练4 测试#!/usr/bin/env python#_*_coding:utf-8...原创 2018-09-11 14:23:23 · 993 阅读 · 0 评论 -
【python库】matplotlib可视化
官网《——本po环境 maxos 10.12.3 python2.7模块下载,python2pip install matplotlib如果是python3pip3 install matplotlibpyplot模块import matplotlibimport matplotlib.pyplot as plt #绘图模块 ...原创 2018-09-05 14:51:59 · 129 阅读 · 0 评论 -
【python和机器学习入门3】朴素贝叶斯1——过滤恶意留言
参考博客:朴素贝叶斯基础篇之言论过滤器 (po主Jack-Cui,《——大部分内容转载自 参考书籍:《机器学习实战》——第四章4.5一 朴素贝叶斯理论 二 demo:过滤网站恶意留言以在线社区留言为例。为了不影响社区的发展,我们要屏蔽侮辱性的言论,所以要构建一个快速过滤器,如果某条留言使用了负面或者侮辱性的语言,那么就将该留言标志为内容不...原创 2018-09-11 10:30:36 · 1153 阅读 · 0 评论 -
【macOS的anaconda安装】与python版本切换问题
po主环境:macOS原python版本:2.7.13安装anaconda3 1 anaconda下载安装直接在官网找到要下载的版本安装即可,大概500-600MB。现在有3.6和2.7的版本选择。由于我的原python是2.7,下载的是3.6,所以涉及到一个版本切换问题。2 版本切换ps:安装完成后多了一个app:anaconda-navigator 不知道是个啥,然...原创 2018-09-19 10:29:03 · 3395 阅读 · 3 评论 -
【pandas】dataframe去空字符串处理
参考:dataframe.replace官方文档1 问题在处理数据的时候遇到一个问题是,明明某些列有很多是空的,但是在python里用dataframe.info统计出来并不是空的,就很奇怪,排查之后发现在我的excel表里这些数据看起来是空的值,但其实是一个空格。但是用isnull判断是为False的2 pandas的空值 在pandas里空值是指NA,包括numpy的n...原创 2018-11-21 11:45:27 · 22052 阅读 · 2 评论 -
【pandas】apply方法传入dataframe多列进行函数操作
参考:dataframe.apply官方文档How to apply a function to two columns of Pandas dataframepython pandas- apply function with two arguments to columns 在处理数据的时候想做时间的转换,抽取生日(格式如 1994-10-5)提取月份和日期...原创 2018-11-22 13:54:43 · 21203 阅读 · 0 评论 -
【python3】leetcode 268. Missing Number (easy)
268. Missing Number (easy)Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:...原创 2018-12-12 17:47:38 · 132 阅读 · 0 评论 -
【python3】leetcode 88. Merge Sorted Array (easy)
88. Merge Sorted Array (easy)Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n ...原创 2018-12-12 18:22:40 · 191 阅读 · 0 评论 -
【python3】leetcode 724. Find Pivot Index (easy)
724. Find Pivot Index (easy)Given an array of integers nums, write a method that returns the "pivot" index of this array.We define the pivot index as the index where the sum of the numbers to the...原创 2018-12-12 20:26:25 · 151 阅读 · 0 评论 -
【python3】leetcode 896. Monotonic Array (easy)
896. Monotonic Array (easy)An array is monotonic if it is either monotone increasing or monotone decreasing.An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is...原创 2018-12-12 20:35:27 · 114 阅读 · 0 评论 -
【python3】leetcode 953. Verifying an Alien Dictionary (easy)
953. Verifying an Alien Dictionary (easy)In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation...原创 2018-12-19 15:02:32 · 302 阅读 · 0 评论 -
【python3】leetcode 674. Longest Continuous Increasing Subsequence(easy)
674. Longest Continuous Increasing Subsequence(easy)Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).Example 1:Input: [1,3,5,4,7]Ou...原创 2018-12-13 17:46:24 · 225 阅读 · 0 评论 -
【python3】leetcode 888. Fair Candy Swap(easy)
888. Fair Candy Swap(easy) ALice要给bob一堆糖果,bob要给alice一堆,最后两人糖果总数要相同,假设alice给的那堆有a个,bob给的那堆有b个解方程吧~~ sum(A)-a+b = sum(b) - b + a -> b = a + (sum(A) + sum(B)) / 2 = a + x ...原创 2018-12-13 19:52:38 · 202 阅读 · 0 评论 -
【python3】leetcode 414. Third Maximum Numberr (easy)
414. Third Maximum Numberr (easy)一、返回第三大的数字,第一想法就是要排序用了一个magic method class Solution: def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """...原创 2018-12-13 20:44:32 · 145 阅读 · 0 评论 -
【python3】leetcode 387. First Unique Character in a String(easy)
387. First Unique Character in a String(easy)Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0...原创 2018-12-19 15:43:04 · 150 阅读 · 1 评论 -
【python3】leetcode 448. Find All Numbers Disappeared in an Array(easy)
leetcode 448. Find All Numbers Disappeared in an Array(easy)本来想天秀一把 直接用listcomp语句return return [i for i in range(1,len(num)+1) if i not in nums]然而超时哈哈哈。。。。:(。。。。只能拆开写啦,set之后length会变所以先存一个变量...原创 2018-12-13 20:48:29 · 183 阅读 · 0 评论 -
【python3】leetcode 485. Max Consecutive Onesr (easy)
485. Max Consecutive Onesr (easy)Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the...原创 2018-12-13 21:10:05 · 191 阅读 · 0 评论 -
【python3】leetcode 811. Subdomain Visit Count(easy)
811. Subdomain Visit Count(easy)A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the l...原创 2018-12-19 17:04:44 · 182 阅读 · 0 评论 -
【python3】leetcode 771. Jewels and Stones(easy)
771. Jewels and StonesYou're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to...原创 2018-12-19 17:25:10 · 198 阅读 · 0 评论 -
【python3】leetcode 575. Distribute Candies(easy)
575. Distribute CandiesGiven an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. Yo...原创 2018-12-19 17:57:40 · 109 阅读 · 0 评论 -
【python3】leetcode 905. Sort Array By Parity(easy)
905. Sort Array By Parity(easy)Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer...原创 2018-12-14 00:38:39 · 102 阅读 · 0 评论 -
【python3】leetcode 747. Largest Number At Least Twice of Others(easy)
747. Largest Number At Least Twice of Others(easy)In a given integer array nums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as muc...原创 2018-12-14 08:36:36 · 155 阅读 · 0 评论 -
【python3】leetcode 830. Positions of Large Groups(easy)
830. Positions of Large Groups(easy) In a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a string like S = "abbxxxxzyy" has the groups "a...原创 2018-12-14 09:21:13 · 285 阅读 · 0 评论 -
【python3】leetcode 914. X of a Kind in a Deck of Cards (easy)
914. X of a Kind in a Deck of Cards (easy)In a deck of cards, each card has an integer written on it.Return true if and only if you can choose X >= 2 such that it is possible to split the ent...原创 2018-12-14 11:56:40 · 333 阅读 · 2 评论 -
【python3】leetcode 219. Contains Duplicate II(easy)
219. Contains Duplicate II(easy)Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute diffe...原创 2018-12-19 19:46:31 · 156 阅读 · 0 评论 -
【python3】leetcode 205. Isomorphic Strings (easy)
205. Isomorphic Strings (easy)Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a charact...原创 2018-12-19 20:34:09 · 222 阅读 · 0 评论 -
【python3】leetcode 389. Find the Difference (easy)
389. Find the Difference (easy)Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random posit...原创 2018-12-20 00:17:45 · 181 阅读 · 0 评论 -
【python3】leetcode 781. Rabbits in Forest (medium)
781. Rabbits in Forest (medium)In a forest, each rabbit has some color. Some subset of rabbits (possibly all of them) tell you how many other rabbits have the same color as them. Those answers are ...原创 2018-12-20 00:48:02 · 180 阅读 · 0 评论 -
【python3】leetcode 922. Sort Array By Parity II (easy)
922. Sort Array By Parity II (easy)Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that whenever A[i] is odd, i i...原创 2018-12-14 14:45:15 · 192 阅读 · 0 评论 -
【python3】leetcode 867. Transpose Matrix (easy)
867. Transpose Matrix Given a matrix A, return the transpose of A.The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. ...原创 2018-12-14 15:59:03 · 128 阅读 · 0 评论 -
【python3】leetcode 832. Flipping an Image(easy)
832. Flipping an Image(easy)Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of th...原创 2018-12-14 16:11:48 · 97 阅读 · 0 评论 -
【python3】leetcode 941. Valid Mountain Array(easy)
941. Valid Mountain Array(easy) Given an array A of integers, return true if and only if it is a valid mountain array.Recall that A is a mountain array if and only if:A.length >= 3 There ex...原创 2018-12-14 16:47:56 · 164 阅读 · 0 评论 -
【python3】leetcode 204. Count Primes (easy)
204. Count Primes (easy)Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, ...原创 2018-12-20 16:47:41 · 198 阅读 · 0 评论 -
【python3】leetcode 566. Reshape the Matrix(easy)
566. Reshape the Matrix(easy) In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a ...原创 2018-12-14 23:02:31 · 92 阅读 · 0 评论 -
【python3】leetcode 350. Intersection of Two Arrays II(easy)
350. Intersection of Two Arrays II(easy)Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2,2]Example 2:Input: n...原创 2018-12-20 16:57:23 · 133 阅读 · 0 评论 -
【python3】leetcode 594. Longest Harmonious Subsequence(easy)
594. Longest Harmonious Subsequence(easy)We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.Now, given an integer array, yo...原创 2018-12-20 17:20:23 · 157 阅读 · 1 评论