We are building an Ads ranking ML system from scratch. The basic idea is this: think about Facebook or Instagram. The platform has millions of ads to show, but it needs algorithms to decide which ads to show. Why? Because, if it shows you ads randomly, you’ll get annoyed and leave the platform, let alone clicking the ads and purchasing. What Meat wants: You keep happy and like the ads, and…
A minimal example project for running Large Language Model (LLM) inference on CHTC GPU Lab at UW-Madison. Why This Project? CHTC’s documentation is great, but setting up LLM inference involves several gotchas: GPU Lab nodes cannot directly access /staging via paths in submit files Version conflicts between container PyTorch and pip-installed packages Efficient environment management to avoid…
I knew about this event only three days before it occurred. Luckily, Maria, one of the organizers, emailed me that I could still register. I did and it only cost $25 for students. On the first day of this event, I got up at around 4 AM and drove from Madison to Chicago. After I arrived, I parked at a nearby place and walked to the Logan center for the arts, where the event was held.
I really enjoyed my experiences at MEB 2025 . It was very memorable, meaningful and helpful for me. MEB Program Overview The first day I was so tired and constantly sleepy during lectures. That was because of three reasons: 1) I didn’t sleep well the day before and 2) The lectures on the first day were boring to me; 3) Being among a large group of people was exhausting to me.
First, find the top largest files find ~ -type f -exec du -h {} + | sort -rh | head -n 20 Clean conda: conda clean -a -y , this will remove Tarballs and extracted packages, Index caches, and Logs Conda envs: List all envs: conda info --envs Remove one: conda env remove --name YOURENVNAME clean pip cache: pip cache purge
Matthew Conlen explains KDE well with a dynamic visualization , worth referring to. Origin KDE is a very important concept. It’s particularly useful when the true underlying distribution of data is uncertain and likely doesn’t follow a standard distribution (like a normal distribution). Let’s use the data from Gaussian Mixture Distribution as an example: import numpy as np import…
I have been using HT Condor (through UW Madison’s CHTC) a lot. They are really amazing resources. Conda I just realized we can install conda for python enviroments management. # Download Miniconda installer wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh # Install Miniconda in your home directory bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda #…
Motivationn & Definition In this post, we explain the concept of Log-Sum-Exp . Suppose we have three extremely small numbers: $a_1 = e^{-200}, a_2 = e^{-201}, a_3 = e^{-202}$ . We are interested in the log of their sum. There are two issues to solve here: The sum will still be very small. To make the result more readible, we want to take the logarithm of it. Dealing with extremely small numbers…
Concept Explanation The Infinite Gaussian Mixture Model (IGMM) is an extension of the Gaussian Mixture Model . It handles situations where we don’t know how many clusters exist. There are generally two approaches to solve this problem. The first is to test different numbers of clusters and compare which result is better, using common methods like the Elbow method (using Sum of Squared…
How do you plan to contribute to the field of Computer Science or Statistics in your future career? (300 word count) As a PhD student in Computer Sciences with a background in liberal arts and social sciences, I aim to contribute to the field by (1) showcasing that it is possible to conduct computer science research even if you are from a non-STEM background; (2) democratizing technical skills…
I saw this post on Stackoverflow. This answer is mostly correct but it omits lots of details. For example, I don’t have a .zshrc file in the begining, how do I create it first. After entering export PATH="/opt/homebrew/bin:$PATH" , how do I save and exit? This post is to help solve this problem. First of all, open your Terminal. If you don’t have a .zshrc file, input touch .zshrc Then,…
The first step is to create the context, for example, UsernameContext.js : import { createContext } from 'react'; const UsernameContext = createContext(""); export default UsernameContext; The second step is (1) initiate the context values and (2) use the context provider. Note that this should be done at the parent level. import { useState, useContext } from 'react'; import UsernameContext from…
There are two ways to create a form in React. One is controlled and the other is uncontrolled. The basic idea behind the controlled method is to use useState and onChange whereas uncontrolled method use useRef . Controlled Note that the following codes are just prototypes. import React, { useState } from 'react'; import { Form, Button } from 'react-bootstrap'; export default function…
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . Least squares Matrix equations: $Ax = b$ If you have more equations than variables, i.e., when $A$ is tall ( overdetermined ), for example $$ A = \begin{bmatrix} 2 & 3 \\ 4 & -1 \\ 2 & 1 \end{bmatrix} $$ And $$ x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} $$ $$ b =…
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . The standard form of linear optimization problems is: $$ \begin{align*} \underset{x\in \mathbb{R}^n}{\text{maximize}}\qquad& c^{T} x\\ \text{subject to:}\qquad& Ax \le b\\ & x \ge 0 \end{align*} $$ Transformation tricks Conversion between min and max: $min f(x) = -…
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . TopBrass Revisited Back to the TopBrass problem: Top Brass Trophy Company makes large championship trophies for youth athletic leagues. At the moment, they are planning production for fall sports: football and soccer. Each football trophy has a wood base, an…
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . This post introduces basic linear optimizaiton through the example of TopBrass. TopBrass Top Brass Trophy Company makes large championship trophies for youth athletic leagues. At the moment, they are planning production for fall sports: football and soccer. Each…
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . If to complete a project, we need to finish all these tasks, from l to s. The number besides each task indicates the number of days it takes to complete that task. Note that we are allowed to work on multiple tasks simultaneously.
Images in this posst came from the slides of CS524 at UW-Madison , 2023Spring This notebook runs in Julia and is rendered by Hupyter . Sailco, a simple example Sailco manufactures sailboats. During the next 4 months the company must meet the following demands for their sailboats: Month 1 2 3 4 Number of boats 40 60 70 25 At the beginning of Month 1, Sailco has 10 boats in inventory. Each month it…
Notes taken on Professor Xiaopeng Li ’s class of CIV ENGR 679 Connected and Automated Transport, 2023Spring level 1: driver assistance. Only one assistance technology, mainly longitudinal. That is say, the car can control the gas pedal and the break pedal. level 2: partial automation. Both longitudinal and lateral. That is to say, the car can control its steering wheel as well. level 3:…
Three are three requirements for passing the qual at UW CS: The committee should comprise of at least three faculty members. At least two of committee members should be core CS faculty members (not affiliates). You can have one faculty member who is not a CS core faculty member (S/he does not even has to be a CS affiliate). The advisor can be anyone of the three, which means your advisor does not…
The material below is based on Professor Xiaopeng Li ’s course of CIV ENGR 679 Connected and Automated Transport This notebook runs in Julia and is rendered by Hupyter . ACC-Automated Car Following Model ACC is short for “Adaptive cruise control”. It is a control model based on acceleration. It has the following formula: $$a_{AV} (t) = k_1 (g(t) - \tau v_{AV}(t)) + k_2 \Delta v$$…
The material below is based on Professor Xiaopeng Li ’s course of CIV ENGR 679 Connected and Automated Transport This notebook runs in Julia and is rendered by Hupyter . PID controller PID is short for “Proportional-Integral-Derivative”. What it does is that if you have a planned trajectory for a vehicle which is now at a specific location and have a specific initial speed, PID…
I was not able to fully master the directory specification in .gitignore but I do not have to. Sometimes, it’s enough to have a .gitignore file that says: “please ignore everything expect this .gitignore file”. Change directory to the folder where you want to ignore, and then: touch .gitignore Press Shift + Command + . , then you’ll be able to see .gitignore file. Open it,…
Through this tutorial, I want to explain how to compuate the multiplications of non-square matrix; for example, the result of multiplying a $2 \times 5$ matrix by a $5 \times 2$ matrix ( a by c in the following example.) import numpy as np a = np.array([[1, 2,7,9,10], [3, 4,5,12,11]]) a array([[ 1, 2, 7, 9, 10], [ 3, 4, 5, 12, 11]]) a is a $2 \times 5$ matrix. It means the transformation from a 5d…
What is the derivative of $f(x) = log(x)$ ? This post tries to prove that it is $\frac{1}{x}$ when the log base is $e$ . Derivative of exponential function and the definition of e Before talking about the derivative of log function, let us review the definition of $e$ . It is related to the derivative of the exponential function, for example, $f(x) = 2^x$ . According to the definition of…
This blog post is inspired by MLDawn’s video on the same topic. Suppose we have a vector: $[z_1, z_2, z_3]$ . Softmax function is in the form of: $$S(z_1) = \frac{e^{z_1}}{e^{z_1} + e^{z_2} + e^{z_3}}$$ $$S(z_2) = \frac{e^{z_2}}{e^{z_1} + e^{z_2} + e^{z_3}}$$ $$S(z_3) = \frac{e^{z_3}}{e^{z_1} + e^{z_2} + e^{z_3}}$$ Now, we want to take the derivative of $S(z_1)$ . Let’s do it now. It…
Given that we have the sigmoid function: $$\sigma(x) = \frac{1}{1 + e^{-x}}$$ What is its derivative? It can be rewritten as $$\sigma (x) = (1 + e^{-x})^{-1}$$ Say that we have: $$m(x) = -x$$ $$t(m) = e^{m}$$ $$h(t) = 1 + t$$ $$g(h) = h^{-1}$$ Then, we have $$\sigma(x) = g(h)$$ So: $$\begin{aligned} \frac{d\sigma}{dx} & = \frac{dg}{dh}\cdot \frac{dh}{dt}\cdot \frac{dt}{dm}\cdot \frac{dm}{dx} \\ &=…
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import altair as alt Download data here: aiddata.csv Data import and basic manipulation df = pd.read_csv('../static/files/aiddata.csv') # df.head() # don't actually need the first two columns: df = df.iloc[:, 2:] # rename the columns df.columns = ['year', 'donor', 'recipient', 'amount', 'purpose_code',…
Lesson 1: Preview Think about the area of a circile. We know that it’s area is $\pi R^2$ . But, why? We can solve the problem this way. Imagine that we divide a radius of this circle into many smaller pieces, each with a width of $dr$ . Then this circle will be composed of many rings. If we tear a ring open and flatten it, it will become a rectangle-ish shape. The length of this…
To me, K Nearest Neighbors (KNN) is very intuitive. Take classification tasks as an example. What KNN does is to find K training examples that are “closest” to the test example. These K training examples have K labels. We find the most common label, and it is the predicted label for the test example in question. How to quantify “closest”? Two simple methods are Euclidean…
This is how you update a value at a specific cell: Suppose the row index of the cell is row_idx , and the column label is 'colname' , then you can update the cell value this way: df.at[row_idx, 'colname'] = new_value . Or: Suppose the row index of the cell is row_idx , and the column index is col_idx , then you can update the cell value this way: df.iat[row_idx, col_idx] = new_value . I got this…
I attended the writing group led by YY on September 22, 2022 where YY, Vincent Wong, and I attended. The topic is “How to stay positive and have confidence in academia”. The following are some of the key points: Don’t compare yourself with others. I know this is cliche but it’s difficult as well as important to do. There will always be super stars around you. If you keep…
Rolling a die Imagine you have a 4-sided fair die, with numbers of ‘1’, ‘2’, ‘3’, and ‘4’. You roll the die once and ask your friend, who have his eyes closed, to figure out the outcome. Your friend can ask you any questions, for example, ‘Is the outcome 1?’ or ‘Is it below 3?’. However, you can only respond with…
What is knowledge? How many kinds of knowledge are there? How to represent knowledge? Language? Graph? Image? Energy? If statement? A new computer language? Until we are able to encode, store, and decode knowledge, we are not able to let computers accumulate knowledge, or learn like babies. At the core of General Artificial Intelligence is the ability to reason. At the core of reasoning is the…
1. $y = \frac{1}{x}$ The derivative of $y = \frac{1}{x}$ can be computed in the following way. First, I highly recommend you to watch this clip , where 3blue1brown visualizes this function. The key part of the proof is that Since A and B are both on the curve of $y = \frac{1}{x}$ , the x coordinate times the y coordinate is 1. That is to say: $A_x \cdot A_y = 1$ and $B_x \cdot B_y = 1$ . If you…
Please refer to the documentation of hupyter repo . I love writing tutorials in Jupyter Notebooks and I want to convert them to Hugo posts on my blog . I tried nb2hugo by vlunot but it lacks two functions: It seems that if I’ve converted it before, then I have to delete the converted blog posts in /content/ before I can convert again. It does not update the image path automatically. I have…
The other day I was thinking about the meaning of standard deviation: $$\sigma = \frac{\sum_{i=1}^{N}(x_i - \bar{x})}{N-1}$$ What is it about? I think it is measuring the expectation of the deviation of a variable from its mean. Then why don’t we just measure the absolute deviation: $E|x_i - \bar{x}|$ ? I saw this discussion on Stack Overflow and was taken aback by it. Reed’s answer…
In this post, I’ll explain what hierarchical clustering is and how to implement it with Python . import pandas as pd import numpy as np import matplotlib.pyplot as plt np.random.seed(1234) N = 10 # number of points matrix = np.random.rand(N, 2) # N points in 2 dimensional space M = matrix * 10 # multiply ten so that the numbers are easier to understand. # Otherwise, all numbers are between 0…
Everyone seems to know correlation but they do not. At least I didn’t. To understand correlation, we need to first understand covariance. As the name suggests, covariance measures the extent to which two variables covary , i.e., vary together. But the questions are: what does “vary” mean, and how do we quantify “together”? For example, I give you these two vectors:…
Ask anyone who has attended Stats101 and s/he will tell you that they understand Z-score. But, really? Could you answer the following questions without thinking? What is the mean of z-scores? What is the standard deviation of z-scores? What is the sum of squared z-scores? Is the z-score distribution the same as the original distribution of sample values? What do z-scores above 0 mean? If you…
I just learned this several days ago: set in python is unsorted and changes from time to time. For example: a = ['a', 'b', 'b', 'c', 'd', 'd', 'e'] set(a) If you run the codes twice (in two different notebooks or scripts), the results are different. To solve this problem: ls = list(set(a)) ls.sort() ls
The plots were not showing in a hugo post by Blogdown. Following Conor Neilson’s suggestion , I added this snippet at the start of my post and it solved the problem. knitr::opts_chunk$set(echo = TRUE, fig.path = "static") Thank you so much Conor!
I found the output of Inscape is not optimal. svg2pdf.js is much better! First, download inkscape. Then run this code in your Terminal ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \ /usr/local/bin/inkscape The source of the above code is: https://stackoverflow.com/a/22085247 After running the above snippet, you should be able to call inkscape from the command line. Then: inkscape…
To put year in parenthesis when citing in LaTex using APA format, for exmaple, According to Goodguy (1990), blablabla... , we can use this: \newcommand{\citeauthorandyear}[2][]{ \citeauthor{#2} (\citeyear[#1]{#2}) } This solution is by Felix K. .