原创 Python- How to format datetime and replace value by multiple datetime conditions

1 Format datetime sample un-formatted date in my dataset:17-Jan-18 use "%d-%b-%y" to impute , which changes to 2017-01-

原创 兩種方法解決leetcode 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 migh

原创 三種方法解決Leetcode169. Majority Element in Python

1. dictionary  class Solution: """ @param: nums: a list of integers @return: find a majority number "

原创 三種方法解決Lintcode39 Recover Rotated Sorted Array in Python

1. 三次翻轉 首先找到最小值的index,而後翻轉三次。for example, [4,5,1,2,3], 先找到1的index2,再以2爲軸: [4,5]->[5,4]; [1,2,3]->[3,2,1]; [5,4,3,2,1]->

原创 兩種方法解決leetcode 53. Maximum Subarray

1. 第一種方法,pre_sum是無腦加,max是對比“pre_sum減去前面一個最小的元素”和current max的對比。把我自己繞進去了。上代碼: def maxSubArray(self, nums):

原创 兩種方法解決leetcode206:Reverse Linked List

方法一:遞歸 其實在正序遞歸的時候已經確定了tail元素。回溯的時候,進行兩步 1. 讓head.next指向head 2. 讓head指向none class Solution(object): def reverseList

原创 中文自然語言處理示例__LSTM with Attention Model運用於中文醫學報告預測_Part1

中文的自然語言處理和不像英語那麼方便,要遇到各種各樣的問題. 幾個大方向,除了刪去一些data裏原本的錯誤之外,還要創造中文和數字的字典,替代中文中的特殊字符,還要處理文本,保持長度的一致,等等. Part1主要是在model之前,講講如

原创 Deep Learning_Autonomous driving application - Car detection_自動駕駛代碼實現

Autonomous driving - Car detectionWelcome to your week 3 programming assignment. You will learn about object detection

原创 Lintcode 31. Partition Algorithm

Partition算法。快排實習的關鍵。 這裏只需要把比k大的放右邊,小的放左邊,並沒有繼續再在左右partition裏排序。相當於完成了快排的一個步驟。思想:雙指針,左邊和K對比,if nums[start]<k, 說明就不是一個swa

原创 Python solving Topological Sorting with explanation

拓撲排序: class Solution: """ @param: graph: A list of Directed graph node @return: Any topological order for t

原创 Leetcode78 Subset

構造遞歸函數。先加進數來找子集,再減去數來找其他子集。class Solution(object): def subsets(self, nums): """ :type nums: List[in

原创 兩種方法解決 Sort Color II - with multiple colors k

1. 最直觀的方法,把list存成dictionary,key爲color,value爲color出現的次數,而後循環一個個導出。 def sortcolor2(colors,k): count={} for c in c

原创 Data visualization_Ted Talk Data

df = pd.read_csv(r'ted_main.csv') df.keys() df.dtypespd.isnull(df).sum() # check missing valuecomments 0

原创 雙指針解決Leetcode 15. 3 Sum

1. 3sum其實和2sum思路差不多。只要把第三個數變成2sum的target就好了。當然要先sort一下,原數組是無序的。2. 也要考慮重複數組的情況。比如left[i]==left[i-1]說明這個數字在i-1的時候應該考慮過了,需

原创 Python_data pre-processing

All of the tech are basic solving solution. In order to obtain robust predictive model, missing value imputation should