- 博客(41)
- 资源 (9)
- 收藏
- 关注

原创 GBDT和Xgboost
GBDT英文全称:Gradient Boosting Decision Tree 。一句话解释:以决策树为基模型(base model),以损失函数的负梯度为学习目标的boosting集成模型这句话有三个概念:决策树,损失函数的负梯度,boosting对第一个基本概念的解释:决策树主流有三类ID3,C4.5,CRAT树。gbdt的基模型是CART树。id3使用信息增益作为分裂点选择C4.5使用信息增益比作为分裂点选择cart树使用基尼系数作为分裂点选择第二个基本概念的解释
2020-11-15 15:25:44
1296
原创 深度学习为什么需要suffle,xgb为什么不需要shuffle?
因为深度学习的优化方法是随机梯度下降,每次只需要考虑一个batch的数据,也就是每次的“视野”只能看到这一批数据,而不是全局的数据。是一种“流式学习”。原始数据因为某中原因分布并不平均,会出现连续的正负样本,或者数据分布集中的情况,这样的话会限制梯度优化方向的可选择性,导致收敛点选择空间严重变少。不容易收敛到最优值。而xgb模型训练建树的过程最重要的步骤是分裂点的选择。考虑的数据是整个训练集。xgb的视野是整个数据集。所以不需要shufle。...
2020-11-22 19:38:02
469
原创 docker for mac下载,阿里镜像
docker直接从外网下载非常大,速度也很慢。国内有一些镜像不是没有就是版本非常旧。ali提供了最新版的镜像http://mirrors.aliyun.com/docker-toolbox/mac/docker-for-mac/stable/
2020-11-17 13:52:13
1578
原创 对话管理
对话管理不仅要能够完成对话,还要“漂亮”的完成对话。这个漂亮一方面让提取器尽量提对,没有太多错误。另一方面对话要多种多样,在完成功能的基础上把话说的漂亮。所以应该在对话MDP模型里应该有对对话多样性的度量。对话多样性1.同一个意思应该有多种表述2.不应该在同一个问题上“纠结”太长时间。因为马氏决策过程只根据当前的系统对话状态去决策,过去的状态并不考虑进来。而对话系统
2015-09-22 22:28:55
1047
原创 leetcode Single Number II
https://leetcode.com/problems/single-number-ii/排序可以做:public class Solution { public int singleNumber(int[] A) { Arrays.sort(A); int i; for(i=0;i<A.length-1;i++){ if(
2015-04-03 15:44:37
312
原创 java 解惑3 string 字符串
System.out.print("H"+"a"); System.out.print('H'+'a'); 这两个程序输出的都是“Ha”吗?不是第一个是“Ha”,第二个是"169"因为第二个‘H’和‘a’都不是string,所以“+”执行的是加法而不是字符串连接。如果也要活得“Ha”可以1.预置一个空字符串2.使用Stirng.valueof()3.使用StringBuffe
2015-03-07 22:53:56
370
原创 Java 解惑2
4.初级问题System.out.println(12345+54321);System.out.println(12345+5432l);你能发现这两个语句有什么区别么?后一个5432l最后一位是小写的L,而第一个是真正的54321.小写字母L和数字1几乎是一样的。为避免混淆,千万不要使用小写的1来作为long型字面常量的结尾或是作为变量名。java从C中继承很多,也许当初允许
2015-03-07 21:07:10
395
原创 java 解惑
1.奇偶性public static boolean isOdd(int i){return i%2==1;}这个程序并不一定获得正确答案,因为i有可能是负数。健壮的写法是这样;return i%2!=0;或者这样:return (i&1)!=0;2.找零System.out.println(2.0-1.10);它不会打印出0.9,更不会打印出0
2015-03-06 22:23:04
427
原创 leetcode Length of Last Word
https://oj.leetcode.com/problems/length-of-last-word/求字符串最后一个单词的长度。单词只用空格分开。public class Solution { public int lengthOfLastWord(String s) { if(s==null)return 0; int last=s.lastI
2015-03-05 17:04:00
301
原创 leetcode Add Binary
https://oj.leetcode.com/problems/add-binary/这个题目不是他别难,但要把string转成int[]却费了一番功夫。当然不转也可以。我的程序一如既往的笨拙。当中有个while()循环。有一些专门对两个链表或数组操作的题目。需要注意的是有的时候是或(||)符号,有的时候是并且符号(&&)主要是看这两个链表要不要一定出现。比如如果是比较的话,确一
2015-03-05 16:41:02
201
原创 leetcode Count and Say
https://oj.leetcode.com/problems/count-and-say/感觉这是一个有点综合的题目了。后一个的结果只跟它的前一个有关。可以用双变量轮换大法。一些经典的算法:1.单链表双指针方法2.双变量轮换大法3.删除重复元素的算法,指针从前向后依次移动。4树结构考虑递归。另外,给字符数个数的时候注意,这也是一个挺有意思的算法。public
2015-03-05 16:24:34
312
原创 leetcode Valid Sudoku
https://oj.leetcode.com/problems/valid-sudoku/判断是不是一个有效的九宫格。行检验,列检验,子九宫格检验。这是一个类似于操作矩阵的算法题。比如让你给一个矩阵旋转90,180度等等。题目简单,写起来跟简单就不搭边。。。public class Solution { public static boolean isValid
2015-03-05 16:00:28
303
原创 leetcode Climbing Stairs
https://oj.leetcode.com/problems/climbing-stairs/这是一个动态规划问题。思路是这样的。登上最后一阶有两种方法:走两步,或者走一步。那么stairs[n]=stairs[n-1]+stairs[n-2]。程序一如既往的笨拙。。。public class Solution { public int climbStairs(in
2015-03-05 15:55:35
312
原创 leetcode Implement strStr()
https://oj.leetcode.com/problems/implement-strstr/字符串匹配在java中inexof()能解决这个问题。public class Solution { public int strStr(String haystack, String needle) { return haystack.indexOf(needle)
2015-03-05 11:54:49
331
原创 leetcode Merge Sorted Array
https://oj.leetcode.com/problems/merge-sorted-array/将两个有序数组合并数组合并从前向后,还是从后向前,这是个问题。public class Solution { public void merge(int A[], int m, int B[], int n) { int a=m-1; in
2015-03-05 11:25:35
278
原创 leetcode Remove Element
https://oj.leetcode.com/problems/remove-element/移除数组中等于element的元素,不开辟新空间,O(n).这个跟有序数组删除重复元素的思路是一样的。public class Solution { public int removeElement(int[] A, int elem) { if(A==null||
2015-03-05 10:47:38
276
原创 leetcode Remove DUplicates from Sorted List
题目https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/这是一个典型的题目public class Solution { public int removeDuplicates(int[] A) { if(A==null)return 0; if(A.length
2015-03-05 10:36:33
308
原创 leetcode Same Tree
https://oj.leetcode.com/problems/same-tree/判断两棵树是不是一样递归是树结构的第一思路。public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p==null||q==null)return p==null&&q
2015-03-05 10:19:55
325
原创 leetcode Symmetric Tree
题目:https://oj.leetcode.com/problems/symmetric-tree/判断一个二叉树是不是对称。这不是一个非常简单的题目需要两个变量,leftList,rightList,每次移出一个比较。要注意leftList,rightList的压入顺序和public class Solution { public static boolea
2015-03-05 09:29:44
277
原创 leetcode Binary Tree Level Order Traversal II
https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/这是一个二叉树的层次遍历问题public class Solution { public List> levelOrderBottom(TreeNode root) { List>list_list=new ArrayList>();
2015-03-04 22:56:21
348
原创 leetcode Balanced Binary Tree
https://oj.leetcode.com/problems/balanced-binary-tree/判断一棵二叉树是不是平衡二叉树方法比较笨拙。。。。用到求深度的函数。/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left;
2015-03-04 22:07:00
393
原创 leetcode Minimum Depth of Binary Tree
https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/求二叉树的最小深度。先看看如何求二叉树的深度:int GetDepth(BinaryTreeNode * pRoot){ if(pRoot == NULL) // 递归出口 return 0; int depthLeft = GetDepth(pRoot
2015-03-04 21:48:35
447
原创 leetcode Path Sum
https://oj.leetcode.com/problems/path-sum/实际上可看做二叉树的遍历。只不过要比二叉树的遍历多存储一个变量,就是根节点到当前节点的和。可以深度遍历也可广度遍历深度遍历(前序遍历)/** * Definition for binary tree * public class TreeNode { * int val; *
2015-03-04 21:32:03
381
原创 leetcode Factorial Trailing Zeroes
https://oj.leetcode.com/problems/factorial-trailing-zeroes/求n的阶乘后边有几个0能产生10的2*5,那就是数数n!里一共有多少个2,多少个5,又因为2的个数一定大于5的个数,所以数数5的个数就行了。1-10一共有2个51-15一共有3个5,1-20一共有4个51-25一共有5个5吗不对,是6个,25=5*5。。
2015-03-04 17:02:54
312
原创 leetcode Pascal's Triangle
https://oj.leetcode.com/problems/pascals-triangle/在Pascal's Triangle II没有用到双变量轮换大法,这次用一下import java.util.*;public class Solution { public List> generate(int numRows) { Listlist=ne
2015-03-04 16:39:51
268
原创 leetcode Pascal's Triangle II
https://oj.leetcode.com/problems/pascals-triangle-ii/有一点动态规划的意思。可以设置两个list,一个pre,一个current,pre计算得到current,再让pre=current,直到n但是根据本题目的数据来看可以在一个list里完成。如下是一个具有上述trick 的程序。public class Soluti
2015-03-04 15:07:01
272
原创 leetcode Remove Nth Node From End of List
双指针大法又显神通。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * }
2015-03-04 14:54:43
264
原创 leetcode Valid Palindrome
题目:https://oj.leetcode.com/problems/valid-palindrome/字符是字母和数字构成回文的就是回文字符串那把不是字母和数字的字符剔除。在用最笨的方法判断是不是回文。public class Solution { public boolean isPalindrome(String s) { if(s==null||
2015-03-04 14:45:00
257
原创 leetcode Longest Common Prefix
点击打开链接求最长公共前缀要找到两个变量,字符串数组的长度,最短字符串的长度。public class Solution { public String longestCommonPrefix(String[] strs) { if(strs==null)return null; if(strs.length==0)return "";
2015-03-04 13:45:20
361
原创 leetcode Roman to Integer
点击打开链接如果连罗马字符都不认识还怎么写。。。。看完别人的程序才知道如此简单。怪不得有人说数学是逻辑,有人说数学是符号估计在罗马人看来数学是符号。public class Solution { public int romanToInt(String str) { int radix[] = {1000, 900, 500, 400, 100
2015-03-04 13:34:46
337
原创 leetcode Palindrome Number
点击打开链接判断一个整数是不是回文整数这个程序完全是试出来的,首先没有想到十的整数倍会是一个bug然后回文的形式有12321,1221两种情况public class Solution { public boolean isPalindrome(int x) { if(x<0)return false; if(x==0)return tru
2015-03-04 13:25:57
287
原创 leetcode String to Integer (atoi)
题目Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible
2015-03-04 11:28:27
250
原创 leetcode Reverse Integer
题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321取余运算public class Solution { public int reverse(int x) { int flag=1; if(
2015-03-04 11:15:52
257
原创 leetcode Min Stack
题目:Design a supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get th
2015-03-04 11:08:58
257
原创 leetcode Intersection of Two Linked Lists
题目: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 ↘
2015-03-04 10:52:18
306
原创 leetcode Compare Version Numbers
题目Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empt
2015-03-04 10:37:21
273
原创 leetcode Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 这个题感觉挺简单,
2015-03-04 08:50:35
299
原创 leetcode Majority Element
题目: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 that the array is non-empty and the majority eleme
2015-03-03 22:08:53
310
原创 leetcode Excel Sheet Column Number
题目Given a column title as appear in an Excel sheet, return its corresponding column number.这实际是26进制,跟问你12345是多少一样的。12345=5*1+4*10+3*100+2*1000+1*10000ABC=1*C+26*B+26*26*Apublic class Solution
2015-03-03 21:57:45
239
适合于初学者的java小程序之四
2011-05-09
适合于初学者的java小程序之3
2011-05-08
适合于初学者的java小程序之2
2011-05-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人