분류 전체보기

LeetCode 🏔️/Tree

105. Construct Binary Tree from Preorder and Inorder Traversal

Description: Solution: In the recursion, we set the root and mid, and then divide two portion: right & left. root is always the first value of preorder[] mid is always the index of root of inorder[] left portion: preorder[1: mid+1] and inorder[:mid]. right portion: preorder[mid+1:] and inorder[mid+1:].

LeetCode 🏔️/Array

11. Container With Most Water

Description: Solution: Brute force method is not adapted as a solution. We are gonna make the pointer end of both array. Shift l if height[l] is smaller than height[r]. Else: shift r to right.

Computer Science 🌋/Machine Learning🐼

Gradient Descent

Gradient Derivatives We can also interpret the slope as: If I nudge x, how does y change? Pretend that multivariable funciton is univariate, then take derivative as normal. This is a partial derivative. The gradient extends the derivative to multiple variables. Vector-valued function (always outputs a vector). The gradient of f(θ) w.r.t. θ is a vector. Each element is the partial derivative for ..

Computer Science 🌋/Machine Learning🐼

Foundation of Machine Learning

Modeling Making Predition To make a prediction, we choose a model, Constant Model: Prediction: fθ(x) = θ (Recipe to compute the prediction) Simple Linear Model: fθ(x) = θ1x + θ0 ( Two model weights) The Constant Model Start simple: if constant model, how do we pick θ? Intuition: pick θ to be close to most of the values in data Model Loss Use x to denote what we use to make predictions Use y to d..

LeetCode 🏔️/Array

15. 3Sum

Description: Solution: We need to nums.sort() before moving pointer. i is a count, a is the value (enumerate) if i > 0 and a == nums[i-1] => if i is bigger than 0, we make sure not using same value l, r pointers to find the two sum for 0 of three sum. Since we sort the values, if threeSum is bigger than 0, we should move r pointer to left. elif threeSum is smaller than 0, we should move l pointe..

Computer Science 🌋/Machine Learning🐼

SQL in Pandas Review

Schemas Schema describes all relations and their attribute names & types. Granularity (what does one record in each table represent?) Primary and Foreign keys Representation CREATE TABLE users( id INTEGER PRIMARY KEY, name TEXT ) CREATE TABLE orders( item TEXT PRIMARY KEY, price NUMERIC, name TEXT ) GROUP BY and HAVING # SQL SELECT max(name), legs, weight FROM animals GROUP BY legs, weight HAVIN..

Computer Science 🌋/Machine Learning🐼

Text Fields Review

Text Fields and Data Cleaning / EDA Extract quantitative values from text: dates, times, positions, etc. Determine if missing values are denoted # split time_str = first.split('[')[1].split(' ', 1)[0] # '26/Jan/2014:10:47:58' day, month, rest = time_str.split('/') # ['26', 'Jan', '2014:10:47:58'] year, hour, minute, second = rest.split(':') # ['2014', '10', '47', '58'] year, month, day, hour, mi..

Computer Science 🌋/Machine Learning🐼

EDA Review

Goals of EDA Data Types: What kinds of data do we have? Granularity: How fine/coarse is each datum? Scope: How (in)complete are the data? Temporality: How are the data situated in time? Faithfulness: How accurately do the data describe the world? Data Type: Nominal Data: categories without natural ordering Ordinal Data: categories with natural ordering Numerical Data: amounts or quantities Compu..

LeetCode 🏔️/Array

33. Search in Rotated Sorted Array

Description: Solution: We are gonna set l, r, m pointers to find in O(logn). If l pointer value is less than m pointer value: target should be between l and m or between m and r. if target is more than m value or target is less than l value, we are gonna see right portion, except left portion. else we are gonna see left portion, except right portion. If r value is less than m value: target can b..

LeetCode 🏔️/Array

153. Find Minimum in Rotated Sorted Array

Description: Solution: I set the right and left pointers to the end of the array. m is the pivot(first set the middle of the array). If m is more than l, then we can throw out the left portion. Now, the new l is the next value of m. Else, we can throw out the right portion, so the new r is the previous value of m. When we get the nums[l] is less than nums[r], we return the res.

KB0129
'분류 전체보기' 카테고리의 글 목록 (5 Page)