- 博客(116)
- 收藏
- 关注
原创 Kaggle比赛----LANL Earthquake Prediction(Baseline)
第一次较完整地kaggle比赛接近尾声,LANL Earthquake Prediction,先做一篇类似于baseline的东西吧,由于自己看为主,所以简单的一些代码不会全部写出来,主要作为一个思路。比赛地址为:https://www.kaggle.com/c/LANL-Earthquake-Prediction题目介绍:In this competition, you will add...
2019-05-31 14:11:25
831
原创 hierarchal cluster (层次聚类,complete linkage)
上一篇博客介绍了single linkage是让所有簇的距离为簇间结点最短的距离,同时每一次合并所有簇间距中最短的那一个。而complete则是让簇间结点距离最长的作为簇间距,并且每一次让所有簇间距最短两簇进行合并,因此实际上不是都找最长,而是最长最短。因此对于基于上一篇的实现方式,complete linkage则需要在每一次循环中维护一个存储以簇间最长距离而作为簇间距的字典,同时字典的...
2019-05-01 11:51:55
4233
原创 hierarchal cluster (层次聚类,single/complete linkage)
看网上似乎没有层次聚类关于single/comlplete linkage只用numpy的轮子,于是根据作业需求造了一个。虽然都是层次聚类,但是基于single/comlplete linkage的和average linkage的着实不太一样。首先从直观角度来讲,后者每一次合并后都得重新算一次新的簇的中心结点是什么,复杂度非常高。而前者只考虑初始叶结点之间的距离作为最终所有簇间距的评估标准。...
2019-04-27 10:19:48
1837
原创 对二分类问题,4维特征数据的bagging(logstics的bagging)
这次的任务是在用logstic单一分类器的基础上,用bagging进行训练,看看有没有提升。首先对bagging做一些介绍:bagging主要是对样本进行重复放回的采样,对每一重采样都得到一个模型,最后取平均参数(或者进行投票)产生最后的分类器。其实从重采样就能感受到bagging实际上是在为减少variance做努力。首先每一次采样的子模型都不可能是完全互相独立的,也不可能是完全相同的。...
2019-04-18 12:43:12
908
原创 169. Majority Element
Given an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋times.You may assume that the array is non-empty and the majority element alwa...
2019-03-30 05:58:57
109
原创 168. 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 -&g...
2019-03-29 11:30:39
131
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2019-03-29 10:40:37
100
原创 162. Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input arraynums, wherenums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple peaks,...
2019-03-26 09:46:23
116
原创 160. 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:begin to intersect at node c1.Example 1:Input: ...
2019-03-25 08:53:20
163
原创 155. Min Stack
Design a stack that 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() -- Ge...
2019-03-25 07:45:34
125
原创 153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7]might become [4,5,6,7,0,1,2]).Find the minimum element.You may assume no du...
2019-03-24 06:06:48
115
原创 148. Sort List
Sort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1-...
2019-03-23 14:00:22
126
原创 147. Insertion Sort List
Sort a linked list using insertion sort.A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element...
2019-03-22 13:03:47
147
原创 145. Binary Tree Postorder Traversal
Given a binary tree, return thepostordertraversal of its nodes' values.Example:Input:[1,null,2,3] 1 \ 2 / 3Output:[3,2,1]Follow up:Recursive solution is trivial, coul...
2019-03-22 11:36:13
148
原创 144. Binary Tree Preorder Traversal
Given a binary tree, return thepreordertraversal of its nodes' values.Example:Input:[1,null,2,3] 1 \ 2 / 3Output:[1,2,3]Follow up:Recursive solution is trivial, could...
2019-03-21 11:53:51
107
原创 143. Reorder List
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1->2-...
2019-03-20 10:11:45
111
原创 logistic回归的多分类任务实现------鸢尾花数据(DATA MINING HOMEWORK)
鸢尾花问题:http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data对于以上给出的数据集,用模型进行训练,得到良好的分类器,分类模型。(要求用线性回归模型)初看数据可以知道大概这么几个信息:首先数据是四维的,类别是三类,是一个多分类问题。因为题目要求用线性模型做,能想到的分类方式大概就是最朴素的线性回...
2019-02-26 14:23:34
1765
原创 131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: "aab"Output:[ ["aa","b"], ["a","a"...
2019-02-13 14:35:13
281
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2019-02-10 17:26:50
148
原创 129. Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota...
2019-02-08 02:02:41
105
翻译 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-i...
2019-02-04 14:28:40
299
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail co...
2019-02-03 06:40:12
115
原创 136. Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...
2019-02-02 14:54:05
105
原创 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Examp...
2019-01-31 06:51:41
89
原创 122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy on...
2019-01-30 14:24:07
83
原创 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),...
2019-01-29 13:45:28
87
原创 120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5...
2019-01-28 13:23:18
119
原创 119. Pascal's Triangle II
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.Note that the row index starts from 0.In Pascal's triangle, each number is the sum of the two numbers ...
2019-01-27 14:40:41
110
原创 118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...
2019-01-26 15:23:43
122
原创 117. Populating Next Right Pointers in Each Node II
Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right...
2019-01-25 15:03:08
241
1
原创 Leetcode-116. Populating Next Right Pointers in Each Node
Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right...
2019-01-24 06:22:16
152
原创 Leetcode-115. Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (ca...
2019-01-23 04:30:09
155
原创 Leetcode-114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ ...
2019-01-22 06:09:18
158
原创 Leetcode-113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note: A leaf is a node with no children.Example:Given the below binary tree and sum = 22,...
2019-01-21 10:42:45
175
原创 Leetcode-112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:...
2019-01-20 13:54:49
109
原创 Leetcode-111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childre...
2019-01-19 12:33:56
104
原创 Leetcode-110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...
2019-01-18 04:57:39
111
原创 Leetcode-109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the ...
2019-01-17 12:36:53
112
原创 Leetcode-108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2019-01-16 12:33:18
117
原创 Leetcode-107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7...
2019-01-15 12:54:55
114
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人