摘要:
作业的内容主要是实现AdaBoost-Stump的算法。作业真是给人一种扮猪吃老虎的感觉,AdaBoost-Stump原理看似很简单,但是却埋了思维陷阱。可以通过Q12~Q18的python源码如下(训练数据是train.dat, 测试数据是test.dat)#encoding=utf8import... 阅读全文
摘要:
首先用一个形象的例子来说明AdaBoost的过程:1. 每次产生一个弱的分类器,把本轮错的样本增加权重丢入下一轮2. 下一轮对上一轮分错的样本再加重学习,获得另一个弱分类器经过T轮之后,学得了T个弱分类器,再将这T个弱分类器组合在一起,形成了一个强分类器。由于每一轮样本的权重都在变化,因此分类器学习... 阅读全文
摘要:
题目:Given an integer, write a function to determine if it is a power of two.代码:class Solution {public: bool isPowerOfTwo(int n) { if ( n>... 阅读全文
摘要:
题目:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the n... 阅读全文
摘要:
题目:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exa... 阅读全文
摘要:
题目:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, exc... 阅读全文
摘要:
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t... 阅读全文
摘要:
题目:Invert Binary TreeTotal Accepted:20346Total Submissions:57084My SubmissionsQuestionSolutionInvert a binary tree. 4 / \ 2 7 / \ / \1 ... 阅读全文
摘要:
题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedi... 阅读全文
摘要:
题目:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowe... 阅读全文