- 博客(62)
- 资源 (1)
- 收藏
- 关注

原创 Adaboost原理及例子
Adaboost是一种迭代算法,其核心思想是针对同一个训练集训练不同的分类器(弱分类器),然后把这些弱分类器集合起来,构成一个更强的最终分类器(强分类器)。Adaboost是一种boosting提升方法,类似于将多个分类器串联在一起,组合成为一个强分类器。而bagging方法则类似于串联模式,将多个分类器并行串联组合成为一个强分类器,如随机森林Random Forest。Adaboost模型Ada...
2018-06-29 14:48:16
1336
1

原创 BP神经网络算法推导(包含输出层和隐层)
你是否也有疑问,在神经网络的训练过程中,随着多样本的训练,我们的参数是如何进行调节的呢?答案自然就是BP算法(Error Back Propagation)。反向传播时,将输出误差(期望输出与实际输出之差)按原通路反传计算,通过隐层反向,直至输入层,在反传过程中将误差分摊给各层的各个单元,获得各层各单元的误差信号,并将其作为修正各单元权值的根据。这一计算过程使用梯度下降法完成,在不停地调整各层神经...
2018-06-01 19:58:12
10049

原创 李航《统计学习方法》第二章-感知机的python实现
重点:感知机是一种二类分类的线性分类模型,属于判别模型。感知机对应于特征空间中的分离超平面 w*x+b=0损失函数:误分类点到分离超平面的总距离。学习算法:随机梯度下降法。有原始和对偶两种形式。当训练数据线性可分时,感知机学习算法存在无穷多解,其解由不同初值和迭代顺序而可能不同。实现代码:import numpy as np import matplotlib.pyplot as plt ...
2018-04-17 21:28:29
688

原创 python实现中文分词和词频统计
python2.7中实现中文分词,是引入了jieba中文分词库。再进行简单的词频统计。import sys reload(sys) sys.setdefaultencoding('utf-8') import jieba import jieba.analyse import xlwt #写入Excel表的库 if __name__=="__mai
2018-01-21 21:54:59
10255
原创 RANSAC随机采样一致算法
RANSAC简介RANSAC(RAndomSAmpleConsensus,随机采样一致)算法是从一组含有“外点”(outliers)的数据中正确估计数学模型参数的迭代算法。“外点”一般指的的数据中的噪声,比如说匹配中的误匹配和估计曲线中的离群点。所以,RANSAC也是一种“外点”检测算法。RANSAC算法是一种不确定算法,它只能在一种概率下产生结果,并且这个概率会随着迭代次数的增加而加大(...
2019-07-07 11:47:05
902
原创 图像Non-local means 去噪算法matlab实现
function [output]=NLmeansfilter(input,t,f,h) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % input: image to be filtered % t: radio of search window 5 5*5大小的搜索窗 % ...
2019-07-07 11:39:23
1791
1
转载 KD-Tree的C++源码实现
#include<cstdio>#include<algorithm>#include<vector>using namespace std;class Node{ public: int location; int p, l, r; Node() {}}; class Point{ public: int id, x, y...
2019-07-07 11:37:23
779
原创 双目立体视觉的SSD立体匹配matlab代码
# Licensed under the MIT Licenseimport numpy as npfrom PIL import Imagedef stereo_match(left_img, right_img, kernel, max_offset): # Load in both images, assumed to be RGBA 8bit per channel im...
2019-07-07 11:36:37
2639
1
原创 堆排序的Python代码
# -*- coding: utf-8 -*-"""Created on Fri Jul 5 10:13:16 2019@author: Yuki"""def heapAdjust(nums, Len, index): left = index*2 + 1 right = index*2 + 2 maxIndex = index if l...
2019-07-07 11:34:49
455
原创 双目立体匹配SAD的matlab源码分析
clear allclcleft=double(rgb2gray(imread('left.png')));right=double(rgb2gray(imread('right.png')));[m n]=size(left);w=9; %窗口半径depth=20; %最大偏移距离,同样也是最大深度距离imgn=zeros(m,n);for i=1+w:m...
2019-07-07 11:32:36
1682
原创 DBSCAN源码分析
%% Copyright (c) 2015, Yarpiz (www.yarpiz.com)% All rights reserved. Please read the "license.txt" for license terms.%% Project Code: YPML110% Project Title: Implementation of DBSCAN Clustering ...
2019-07-07 11:30:27
1165
2
转载 二叉树重建(C++/Python)
问题:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。 思路分析 根据二叉树前序遍历的特点(根-左-右),每次读取的第一个值一定是根节点,这样我们可以在中序遍历的序列中找到当前的根节点的位置。 根...
2018-09-09 16:45:42
237
转载 《一一》影评:年华一帧一帧地逝去
有一幅很著名的画:太阳在海平面之上,阳光洒下整片海,沙滩上有几个人正朝着太阳的方向仰望,你认为是日出还是日落?据说看到日出的人充满朝气,是乐观主义者;看到日落的人暮气沉沉,是悲观主义者。某天有人问我,你看到的是日出还是日落?虽然我知道这个寓意,却不想掩饰什么,我说我看到的是日落,他说你真的老了。也是在那天我看了《一一》,本来很淡然的我却在片尾曲响起的时候,呆坐在那里,掩面而泣,好像活了一辈子...
2018-09-03 19:33:45
286
转载 快速理解EM算法
原文链接: https://www.jianshu.com/p/1121509ac1dc如果使用基于最大似然估计的模型,模型中存在隐变量,就要用EM算法做参数估计。个人认为,理解EM算法背后的idea,远比看懂它的数学推导重要。idea会让你有一个直观的感受,从而明白算法的合理性,数学推导只是将这种合理性用更加严谨的语言表达出来而已。打个比方,一个梨很甜,用数学的语言可以表述为糖分含量90%...
2018-09-02 10:01:46
662
转载 迅速掌握 快速排序
转载:http://developer.51cto.com/art/201403/430986.htm假设我们现在对“6 1 2 7 9 3 4 5 10 8”这个10个数进行排序。首先在这个序列中随便找一个数作为基准数(不要被这个名词吓到了,就是一个用来参照的数,待会你就知道它用来做啥的了)。为了方便,就让第一个数6作为基准数吧。接下来,需要将这个序列中所有比基准数大的数放在6...
2018-07-18 21:29:01
205
原创 吴恩达 DeepLearning《神经网络与深度学习》之《神经网络基础》作业2
# -*- coding: utf-8 -*-"""Created on Thu Jul 5 10:17:56 2018@author: Yuki"""import numpy as npimport matplotlib.pyplot as pltimport h5pyimport scipyfrom PIL import Imagefrom scipy import ...
2018-07-08 10:47:17
376
原创 LeetCode题解-144. Binary Tree Preorder Traversal(二叉树的非递归前序遍历)
题目:Given a binary tree, return the preorder traversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,2,3]思路:根据前序遍历访问的顺序,优先访问根结点,然后再分别访问左孩子和右孩子。即对于任一结点,其可看做是根...
2018-06-09 16:07:19
254
转载 C++中一级指针和双重(二级)指针作为函数参数传递
引用博文:https://www.cnblogs.com/WeyneChen/p/6672045.html函数参数传递的只能是数值,所以当指针作为函数参数传递时,传递的是指针的值,而不是地址。当指针作为函数参数传递时,在函数内部重新申请了一个新指针,与传入指针指向相同地址。在函数内部的操作只能针对指针指向的值。#include <iostream>using namespace st...
2018-06-07 16:55:05
6771
原创 LeetCode题解347. Top K Frequent Elements
题目:Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele...
2018-06-07 14:18:32
175
原创 LeetCode题解287- Find the Duplicate Number(C++)
题目:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,...
2018-06-05 09:27:19
289
原创 LeetCode题解221— Maximal Square(C++)
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.Example:Input: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4思路:借鉴了LeetCode大神...
2018-05-31 14:45:57
450
原创 LeetCode题解226-Invert Binary Tree(C++)
题目:nvert a binary tree.Example:Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by M...
2018-05-30 21:44:36
289
原创 LeetCode题解215-Kth Largest Element in an Array(C++)
题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Examp...
2018-05-30 17:03:14
344
原创 LeetCode题解240-Search a 2D Matrix II(C++)
题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each c...
2018-05-30 16:18:31
252
原创 LeetCode题解160-Intersection of Two Linked Lists(C++)
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ ...
2018-05-28 16:36:08
190
原创 Leetcode题解142- Linked List Cycle II(C++)
题目:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?思路:快慢双指针,快指针移...
2018-05-23 18:54:07
524
原创 Leetcode题解141-Linked List Cycle(C++)
题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:设立快慢两个指针,快指针一次移动两步,慢指针一次移动一步。若存在换,那么慢指针会赶上快指针。可以想象成操场上有两个人在跑步,一个快一个慢,那么经过几圈之后,两个人肯定会相遇...
2018-05-23 08:58:26
158
原创 LeetCode题解121- Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock)...
2018-05-21 16:28:44
163
原创 Leetcode题解84- Largest Rectangle in Histogram
题目Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of each b...
2018-05-11 20:41:33
172
原创 Leetcode题解48-Rotate Image
题目:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix dire...
2018-05-01 14:44:14
154
原创 Leetcode题解198- House Robber
题目:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent ho...
2018-04-30 11:48:53
188
原创 Leetcode题解42-Trapping Rain Water
题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above elevation map is represented by array...
2018-04-30 09:02:27
130
原创 Leetcode题解70-Climbing Stairs
题目: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 you climb to the top?Note: Given n will be a positive ...
2018-04-27 18:10:14
130
原创 Leetcode题解55- Jump Game
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you...
2018-04-27 15:43:45
214
原创 leetcode题解32- Longest Valid Parentheses
题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: "(()"Output: 2Explanation: The longest valid p...
2018-04-27 11:50:10
133
原创 leetcode题解35- Search Insert Position
题目: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 in order.You may assume no duplicates in the array.E...
2018-04-27 10:06:11
122
原创 leetcode题解34- Search for a Range
题目:Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the ...
2018-04-27 09:30:17
279
原创 leecode题解22- Generate Parentheses
题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())",...
2018-04-22 10:50:22
169
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人