ML is built using the tools of mathematical statistics, numerical methods, mathematical analysis, optimization methods, probability theory, and various techniques for working with data in digital form.
What is it?
\[\begin{cases} \frac{\partial \rho}{\partial t} + \frac{\partial(\rho u_{i})}{\partial x_{i}} = 0 \\ \\ \frac{\partial (\rho u_{i})}{\partial t} + \frac{\partial[\rho u_{i}u_{j}]}{\partial x_{j}} = -\frac{\partial p}{\partial x_{i}} + \frac{\partial \tau_{ij}}{\partial x_{j}} + \rho f_{i} \end{cases} \]In machine learning, there is no pre-set model with equations...
Data matrix (objects and features as rows and columns):
$F = ||f_j(x_i)||_{\ell\times n} = \left[ {\begin{array}{ccc}
f_1(x_1) & \dots & f_n(x_1) \\
\vdots & \ddots & \vdots \\
f_1(x_\ell) & \dots & f_n(x_\ell)
\end{array} } \right]$
$Y = \mathbb{R}\ $ or $\ Y = \mathbb{R}^m$
A model (predictive model) — a parametric family of functions
$A = \{g(x, \theta) | \theta \in \Theta\}$,
where $g: X \times \Theta \to Y$ — a fixed function, $\Theta$ — a set of allowable values of parameter $\theta$
Linear model with vector of parameters $\theta = (\theta_1, \dots, \theta_n), \Theta = \mathbb{R}^n$:
$g(x, \theta) = \sum\limits_{j=1}^n \theta_jf_j(x)$ — for regression and ranking, $Y = \mathbb{R}$
$g(x, \theta) = \mathrm{sign}\left(\sum\limits_{j=1}^n \theta_jf_j(x)\right)$ — for classification, $Y = \{-1, +1\}$
Source: Javascript Tetris, how it works
Combine features into a heuristic score:
(-0.51 * aggHeight + 0.76 * completeLines - 0.36 * holes - 0.18 * bumpiness) $\to\max$
(-0.51 * aggHeight + 0.76 * completeLines - 0.36 * holes - 0.18 * bumpiness) $\to\max$
| Case | Rows | Score |
|---|---|---|
| Heuristic with bugs | 0 | 222 |
| Fixed Possible Moves | 5 | 1 036 |
| Fixed Heigh calculation | 612 | 78 268 |
Ok, looks good, but what about Beam Search?
(-0.51 * aggHeight + 0.76 * completeLines - 0.36 * holes - 0.18 * bumpiness) $\to\max$
| Case | Rows | Score |
|---|---|---|
| Heuristic with bugs | 0 | 222 |
| Fixed Possible Moves | 5 | 1 036 |
| Fixed Heigh calculation | 612 | 78 268 |
| Full Search w\ Next Piece | 44 301 | 5 623 130 |
Time to rewrite it in Python!
Trust Junie to do the hard work:
Prompt 1: Look at the javascript tetris project and come up with the plan of rewriting it in Python. Write all the details in the `python-tetris/plan.md` file.
Prompt 2: Implement the tetris in Python according to the `python-tetris/plan.md`, but replace the `texture.jpg` background to the simple gray grid.
Prompt 3 (fixing bug): The game in Python works, but there is no AI mode, only flag for it.