- 博客(381)
- 资源 (9)
- 收藏
- 关注
原创 特征离散化,特征交叉,连续特征离散化
一.互联网广告特征工程博文《互联网广告综述之点击率系统》论述了互联网广告的点击率系统,可以看到,其中的logistic regression模型是比较简单而且实用的,其训练方法虽然有多种,但目标是一致的,训练结果对效果的影响是比较大,但是训练方法本身,对效果的影响却不是决定性的,因为训练的是每个特征的权重,权重细微的差别不会引起ctr的巨大变化。在训练方法确定后,对ctr预估起到决定性作用的是选
2017-04-28 09:55:15 855
转载 hadoop下实现kmeans算法——一个mapreduce的实现方法
写mapreduce程序实现kmeans算法,我们的思路可能是这样的1. 用一个全局变量存放上一次迭代后的质心2. map里,计算每个质心与样本之间的距离,得到与样本距离最短的质心,以这个质心作为key,样本作为value,输出3. reduce里,输入的key是质心,value是其他的样本,这时重新计算聚类中心,将聚类中心put到一个全部变量t中。4. 在main里比较前一次的质心和本次的质心是否
2017-04-24 10:36:29 878
转载 word2vec
part1 The Model The skip-gram neural network model is actually surprisingly simple in its most basic form; I think it’s the all the little tweaks and enhancements that start to clutter the explanatio
2017-03-27 14:22:31 739
转载 Local Response Normalization (LRN)
This concept was raised in AlexNet, click here to learn more. Local response normalization algorithm was inspired by the real neurons, as the author said, “bears some resemblance to the local contrast
2017-03-27 14:20:26 1194
转载 序列标注模型
序列标注模型被广泛应用于文本处理相关领域,例如分词、词性标注、命名实体识别等方面。现有的序列标注模型主要有 HMM , MEMM 以及 CRF ,通过对这几种自然语言处理中常用的序列标注模型进行对比,分析其各自的优缺点。 在介绍三种序列标注模型之前,首先需了解下产生式模型与判别式模型的概念,二者在分类器中经常被提及。假定输入 X ,类别标签 Y : 产生式模型估计联合概率P(x,y) ,判别式模型
2017-03-27 14:19:32 1886
原创 movingCount
class Solution {private: int count=0; vector<vector<int>> directions{{-1,0},{1,0},{0,1},{0,-1}}; bool judge(int threshold,int row,int col) { int judgecount=0; while(row
2017-03-16 17:51:55 400
原创 hasPath
class Solution {private: vector<vector<int>> directions={{-1,0},{1,0},{0,1},{0,-1}}; bool haspathhelper(char *matrix,int rows,int cols,int currow,int curcol,char *str,int length,int curindex,b
2017-03-16 16:42:10 613
原创 Serialize and DeSerialize
class Solution {private: void serializehelper(TreeNode *root,vector<int> &v) { if(root==NULL) { v.push_back(0x23333333); return; } v.push
2017-03-15 22:20:45 333
原创 按照之字形打印二叉树
#include <string>#include <iostream>#include <vector>#include <cstring>#include <stack>using namespace std;struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right;
2017-03-14 19:30:24 355
原创 duplicate
#include <string>#include <iostream>#include <vector>using namespace std;class Solution {public: // Parameters: // numbers: an array of integers // length: the l
2017-03-11 22:57:28 423
原创 424. Longest Repeating Character Replacement
public class Solution { public int characterReplacement(String s, int k) { int start=0; int end=0; int maxlength=0; int len=s.length(); int[] count=new int[2
2017-02-13 14:12:11 288
原创 423. Reconstruct Original Digits from English
public class Solution { public String originalDigits(String s) { int[] count = new int[10]; for (int i = 0; i < s.length(); i++){ char c = s.charAt(i); if (c
2017-02-13 10:20:12 280
原创 421. Maximum XOR of Two Numbers in an Array
class Solution {public: int findMaximumXOR(vector<int>& nums) { int max=0; int mask=0; unordered_set<int> s; for(int i=31;i>=0;i--) { s.clear();
2017-02-12 12:08:35 264
原创 419. Battleships in a Board
public class Solution { public int countBattleships(char[][] board) { int m=board.length; if(m==0) return 0; int n=board[0].length; if(n==0)
2017-02-10 16:01:43 305
原创 417. Pacific Atlantic Water Flow dfs
public class Solution { public List<int[]> pacificAtlantic(int[][] matrix) { List<int[]> ret=new ArrayList<int[]>(); int m=matrix.length; if(m==0) return ret;
2017-02-09 19:05:23 273
原创 417. Pacific Atlantic Water Flow
public class Solution { public List<int[]> pacificAtlantic(int[][] matrix) { List<int[]> ret=new ArrayList<int[]>(); int m=matrix.length; if(m==0) return ret;
2017-02-09 16:00:09 330
原创 Principal Component Analysis
pca的目标是通过基变换 使得元素的方差从大到小排列 并且元素之间的协方差为0(线性无关)。而元素的协方差 矩阵的对角线上是元素的方差 ,对角线外的元素是协方差。 我们的目标就是 找到单位正交基,使得通过基变换后 ,元素的方差从大到小排列 而不同元素的协方差为0 。元素的协方差矩阵 和经过基变换后的协方差矩阵关系如下 原数据为X X的协方差矩阵为C Y=PX P为变换矩阵 Y为变换后的元
2017-02-08 20:41:42 376
原创 416. Partition Equal Subset Sum
public class Solution { public boolean canPartition(int[] nums) { int sum=0; for(int num:nums) { sum+=num; } if(sum%2==1) return false;
2017-02-08 15:56:43 320
原创 415. Add Strings
public class Solution { public String addStrings(String num1, String num2) { int carry=0; StringBuilder sb=new StringBuilder(); for(int i=num1.length()-1,j=num2.length()-1;i
2017-02-08 11:22:17 308
原创 414. Third Maximum Number
public class Solution { public int thirdMax(int[] nums) { Integer max1=null; Integer max2=null; Integer max3=null; for(Integer num:nums) { if(num
2017-02-07 14:35:44 323
原创 413. Arithmetic Slices
class Solution {public: int numberOfArithmeticSlices(vector<int>& A) { int n=A.size(); if(n<3) return 0; vector<int> dp(n,0);//dp[i]表示以i结尾的等差数列的个数 if(A[
2017-02-07 13:48:03 262
原创 412. Fizz Buzz
class Solution {public: vector<string> fizzBuzz(int n) { vector<string> ret; for(int i=1;i<=n;i++) { bool timeofthree=(i%3==0); bool timeoffive=(i%5
2017-02-07 10:57:08 236
原创 410. Split Array Largest Sum
class Solution {private: bool valid(int target,vector<int>& nums,int m) { int count=1;//count应该初始化1 int total=0; for(int num:nums) { total+=num;
2017-02-06 15:08:51 274
原创 409. Longest Palindrome
class Solution {private: bool static compare(int a,int b) { return a>b; }public: int longestPalindrome(string s) { map<char ,int > m; for(int i=0;i<s.size();i+
2017-02-06 10:48:17 219
原创 03. Frog Jump
public class Solution { public boolean canCross(int[] stones) { HashMap<Integer,HashSet<Integer>> map=new HashMap<>(); map.put(stones[0], new HashSet<Integer>()); map.get(st
2017-02-01 15:22:25 214
原创 407. Trapping Rain Water II
package leetcode;import java.util.*;public class Solution{ class Cell{ int col; int row; int height; public Cell(int col,int row,int height){ this.col=c
2017-01-24 12:35:45 294
原创 406. Queue Reconstruction by Height
public class Solution { public int[][] reconstructQueue(int[][] people) { Arrays.sort(people,new Comparator<int[]>(){ public int compare(int[] a1,int[] a2){ retu
2017-01-17 15:39:27 249
原创 405. Convert a Number to Hexadecimal
public class Solution { public String toHex(int num) { char[] mymap={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; String s=""; if(num==0) re
2017-01-17 10:59:18 218
原创 404. Sum of Left Leaves
class Solution {private: int count=0; void sumhelper(TreeNode* root,bool isleft) { if(!root) return; if(isleft&&!root->left&&!root->right) count+=ro
2017-01-17 10:22:39 241
原创 402. Remove K Digits
public class Solution { public static String removeKdigits(String num, int k) { int digits=num.length()-k; int top=0; char[] stack=new char[num.length()]; for(int i=
2017-01-15 12:09:27 279
原创 400. Nth Digit
class Solution {public: int findNthDigit(int n) { /* * 首先定位到包含n的这个数字有几位 * 然后定位到包含n的这个数字是什么 * 最后定位到n是这个数字的第几位 */ long digit=1,base=9,ith=1;//digi
2017-01-15 10:53:19 269
原创 399. Evaluate Division
结题思路是: a/b=v 可以看成是一个又a点指向b点的有向图 边的权值为v 有了a指向b的边 就有 b指向a的边 大小为1/v 则求 c/v 的话就是在图中寻找一条由c指向v的边 将边上所有的权值相乘即可。public class Solution { public double[] calcEquation(String[][] equations, double[] va
2017-01-14 15:42:46 328
原创 398. Random Pick Index
public class Solution { private int[] nums; private Random random; public Solution(int[] nums) { this.nums=nums; random=new Random(); } public int pick(int target) {
2017-01-14 12:23:15 257
原创 Integer Replacement
public class Solution { public int integerReplacement(int n) { int c = 0; while (n != 1) { if ((n & 1) == 0) { n >>>= 1; } else if (n == 3 || Integer.bitCount(n +
2017-01-13 20:24:41 309
原创 396. Rotate Function
class Solution {public: int maxRotateFunction(vector<int>& A) { int F=0; int sum=0; for(int i=0;i<A.size();i++) { sum+=A[i]; F+=i*A[i];
2017-01-13 10:47:16 218
原创 395. Longest Substring with At Least K Repeating Characters
public class Solution { public int longestSubstring(String s, int k) { char [] string =s.toCharArray(); return helper(string,0,s.length(),k);//求每个字符的出现次数 都 >=k 的最长子字符串的长度 }
2017-01-12 11:12:00 245
原创 394. Decode String
public class Solution { public String decodeString(String s) { Stack repeattimes=new Stack<>(); Stack res=new Stack<>(); String cur=”“; int idx=0; whil
2017-01-11 15:21:42 300
原创 392. Is Subsequence
class Solution {public: bool isSubsequence(string s, string t) { auto it=s.begin(); for(char c:t) { it+=((*it)==c); } return it==s.end(); }
2017-01-11 12:52:25 284
原创 391. Perfect Rectangle
class Solution {public: bool isRectangleCover(vector<vector<int>>& rectangles) { unordered_set<string> s; int x1=INT_MAX; int y1=INT_MAX; int x2=INT_MIN; in
2017-01-10 13:56:10 320
原创 390. Elimination Game
class Solution {public: int lastRemaining(int n) { int head=1; int remain=n; int setp=1; bool forward=true; while(remain>1) { if(forward
2017-01-09 11:00:04 308
PID算法详解
2013-04-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人