原创 機器學習與數據挖掘之生成模型與判別模型

參考文獻:機器學習與數據挖掘參考文獻 監督學習的任務是學習一個模型,應用這一模型,對給定的輸入預測相應的輸出,這個模型的一般形式爲決策函數: Y=f(X) 或者條件概率分佈: P(Y|X) 監督學習方法分爲生成方法和判別方法。所學到的模

原创 《數據結構與算法分析》讀書筆記之樹的深度和高度

路徑 從節點n1到nk的路徑定義爲節點n1,n2,……,nk的一個序列,使得對於1≤i<k節點ni是ni+1的父親。這條路徑的長是爲該路徑上的邊的條數,即k-1。從每一個節點到它自己有一條長爲0的路徑。 深度 對任意節點ni,ni的深度爲

原创 機器學習與數據挖掘參考文獻

《統計學習方法》 李航《機器學習》 周志華

原创 機器學習與數據挖掘之樸素貝葉斯法

參考文獻:機器學習與數據挖掘參考文獻 樸素貝葉斯法是基於貝葉斯定理與特徵條件獨立假設的分類方法。對分類任務來說,在所有相關概率都已知的理想情形下,貝葉斯決策論考慮如何基於這些概率損失來選擇最優的類別標記。即對每個樣本x,它選擇能使後驗概

原创 LeetCode 388. Longest Absolute File Path

public class Solution { public int lengthLongestPath(String input) { if (input == null || input.length() ==

原创 TypeError: Expected int32, got list containing Tensors of type '_Message' instead.解決方法

0.x版本:數字在前,tensors在後: tf.concat(n, tensors) 1.0及以後版本:tensors在前,數字在後: tf.concat(tensors, n)

原创 LeetCode 64. Minimum Path Sum

public class Solution { public int minPathSum(int[][] grid) { int m = grid.length; int n = grid[0].

原创 LeetCode 39. Combination Sum

public class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { Arrays.sort(

原创 LeetCode 11. Container With Most Water

public class Solution { public int maxArea(int[] height) { int l = 0; int r = height.length - 1;

原创 機器學習與數據挖掘之ROC與AUC

參考文獻:機器學習與數據挖掘參考文獻 圖1 分類結果混淆矩陣 很多學習器是爲測試樣本產生一個實值或概率預測,然後將這個預測值與一個分類閾值進行比較,若大於閾值則分爲正類,否則爲反類。例如,神經網絡在一般情形下是對每個測試樣本預測出

原创 LeetCode 48. Rotate Image

public class Solution { public void rotate(int[][] matrix) { int n = matrix.length; int half = (n +

原创 LeetCode 474. Ones and Zeroes

public class Solution { public int findMaxForm(String[] strs, int m, int n) { int[][] nums = new int[m + 1]

原创 LeetCode 75. Sort Colors

public class Solution { public void sortColors(int[] nums) { if (nums == null || nums.length <= 1) return;

原创 LeetCode 289. Game of Life

public class Solution { public void gameOfLife(int[][] board) { if (board == null || board.length == 0 || boar

原创 LeetCode 313. Super Ugly Number

public class Solution { public int nthSuperUglyNumber(int n, int[] primes) { int[] nums = new int[n];