---
# System prepended metadata

title: 'Exam Questions Machine Learning for the Natural Sciences :atom_symbol:'

---

# Exam Questions Machine Learning for the Natural Sciences :atom_symbol: 

Sadly, we do not have much training data (past exams) :worried:. But we can generate our own 🎉. Just think about what questions you would ask if you had to make an exam and write them done. Just questions, no answers.

## Syntax

Example question:
* Risk
    * Explain what **risk** is.
    * How is expected risk defined?
    * How can it be approximated?

Example multiple choice question:
* What would be useful features for predicting tomorrow's weather
    * [ ] A vector with the temperatures of the past hours and days
    * [ ] A vector with wind speeds of the past hours and days
    * [ ] An integer of how many people finished their meal today
 
You can use math like normal $\LaTeX$ $f(x) = \frac{1}{x^2}$ 


If you think that there should be a question about a particular topic or aspect, but just can't think of one:

* :thinking_face: Connection between Extended-Connectivity Fingerprints and Graph Convolutions for Molecules

## Lecture 02 - Decision trees, ensemble methods

* :star: List the steps of the greedy training algorithm for decision trees.
* :star: Assume you are training a decision tree using a greedy training strategy and n data points each with k features. Derive and explain the average scaling of the runtime of the algorithm in n and k to train the root node? What is the average depth of the full tree? How does the runtime scale to train the full decision tree (ignore constant prefactors)? Explain all answers.
* How to predict the response variable of an unseen data point using a decision tree for categorical and continuous features? (Inference)
* If we scale the features of the training data, how do the predictions of the decision tree change?
* Impurity Measures:
    * Give the formula for entropy.
    * Give the probability of missclassifying a sample with a decision tree.
    * Give the formula for Gini-Impurity
* Regularization:
    * How can decision trees be regularized? (5 things)
    * Which problem can arise when using information gain as a stopping criteria for decision tree training? Describe a dataset for which the problem occurs.
* Wherein lies the problem when training on correlated features?
* Ensemble Methods:
    * Explain the differences between bagging and boosting during training and inference
    * Derrive the Bias-Variance Decomposition start with the expected error.
    *  Assume that the model predictions are identically distributed. Show that an ensemble has at most the expected error of a single model. What is the expected error if the models are also independent?
    * How can you estimate the generalization error of an ensemble "intrinsically"?
    * How can you interpret the predictions of a random forest? Explain two approaches.
* Explain three approaches for measuring feature importance

## (Lecture 03 - Mathematical foundations)

## Lecture 04 and 05 - Machine learning basics

* Explain the steps necessary to derive the weights for linear regression. State the formula for the initial problem. It is not necessary to do all the calulation steps or state the solution.
* Regularization:
    * Explain Underfitting and Overfitting
    * Why can't you optimize hyperparameters that limit the model capacity on the training set?
    * How should the loss curves of a model change after adequate regularization?
    * Assume you're doing a k-fold cross-validation, on which subsets of the data would you optimize a hyperparameter?
* Losses & Metrics:
    * Draw the (expected) ROC curve of a classifier that outputs uniformly random predictions in a two class setting. Do not forget axis labels
Hint: Given the same model. For any subset of the data how many positives and negatives have been classified as positives (on average)?
    * Assuming $p(y | x, \theta) \sim \mathcal{N}(\hat{y}, \sigma^2)$ show that maximizing the likelihood is equivalent to minizing the MSE.
    * Show that $\underset{\theta}{max}~p(x;\theta) = \underset{\theta}{min}~\text{NLL}(x; \theta) = \underset{\theta}{min}~\text{KL}(p_{data} || p_{model})$.
        * NLL = negative log-likelihood
    * $p(c_j | x) = \frac{e^{z/T}}{\sum_i e^{z_i/T}}$ is the so called temperature-scaled softmax. Why is it called that way?
    * How to measure Accuracy?
* Basic Models:
    * Why is feature selection particularly relevant for k-NN?
    * Perform the kernel trick for an SVM.
    * Give the mathematical model of logistic regression.
    * Derrive the Normal Equation by minimizing the MSE
    * How does the k-means clustering algorithm work?
* Give an example of a geometric scaling law w.r.t to the number of dimensions and relate it to the curse of dimensionality in machine learning.
* Show that an unsupervised problem can be expressed as supervised problems and vice versa.

## Lecture 06 - Neural networks
* What activation functions would you use for a multi-class classification head?
* Why is L1 Regularization also called Least absolute shrinkage and **selection operator** (Lasso)?
* Say you chose an optimization algorithm that relies on curvature information (e.g. BFGS), which activation function should you **avoid** for your network and why? What would be a close alternative?
* Could you put an L1-Penalty on the **representations** of your network and achieve similar results to a lasso objective? Why? Why not?
* Why is Ridge Regression also called "weight decay"?
* Give an example of multi-task learning seen in the lecture and explain how it affected the shared representations.
* Say you wanted to reduce the model capacity of a deep neural net without changing the model size, how would you do that?
* How can you get an uncertainty estimate (variance) from a single Neural Network? You are alowed to infer multiple times. (Hint: How would you do it for a random forest?)

## Lecture 07 - Nano-scale simulations with neural networks
* Give a few examples of nanoscale phenomena that can be simulated.
* What kind of forces and interactions occur in a multi-particle system?
* Name three classical methods for atomic resolution
* If you have a network predicting the energy of a system, how can you make a next step prediction of the particle positions?
* Why use machine learning for atomic simulations?
* What is the problem with representing a molecule as a vector of inverse distances between it's atoms?
* How to create off-equilibrium molecule datasets for atomic simulation? Explain two approaches and compare them.

## Lecture 08 - CNNs and medical image data

* :star: What are the components of a ResNet block (drawing is encouraged)? What is the purpose of skip connections in the ResNet architecture?
* Give an example for an up-convolution that maps a 2D vector to a 5D vector
* You want to do segmentation of cell images. Why are up convolutions necessary?
* What is a "valid" convolution and what is it's output size?
* What would be an advisable precaution when training a CNN with very many layers
* How can you predict the electron density using a CNN?
* What type of architecture could you use for segmenting CT scans?
* What is the result of the deconvolution $\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \oslash \begin{bmatrix} 1 & 1 & 1 \\ 1&1&1\\ 1&1&1\\\end{bmatrix}$

## Lecture 09 - RNNs and reaction prediction
* Write down the operations for an LSTM-Cell
* What is an advantage of GRU over LSTM-Cells?
* What is the similarity between seq2seq models and autoencoders
* What problem of RNNs does the attention mechanism solve?
* What is an attention matrix and how can you interpret it?

## Lecture 10 - Graph neural networks and molecular representations

* :star: You have a very large dataset of molecules and their properties, e.g. their toxicity. You want to train a machine learning model to predict that property. Rank the following ML models according to their expected accuracy, and explain your ranking:
	* a) Feed-forward neural network with molecular fingerprints as input vectors 
	* b) Graph neural networks which learn directly from the adjacency matrix and the molecular geometry
	* c) Easy-to-compute molecular features concatenated to a feature vector used as input for a random forest regression model
* SMILES syntax
    * Draw the molecule described by the SMILES code O=Cc1ccc(O)c(OC)c1
    * Write down a different SMILES code for the same molecule
    * Write down a SMILES code for dopamine ([result](https://www.guidetopharmacology.org/GRAC/LigandDisplayForward?ligandId=940))
![](https://i.imgur.com/5c23VCm.png)
* GNNs
    * Explain a basic message passing operation.
    * Say you were using a Graph Neural Network to predict the bioavailability of a drug. How can you modify the message passing operation to get predictions that are invariant to actions of  $\mathbb{E}(3)$ on the 3D molecular structure? (see. Satorras 2021)
* Molecule Fingerprints
    * Explain how the extended connectivity fingerprint is constructed
    * How is the neural graph fingerprint constructed?
    * How do the representations differ?


## Lecture 11 - Autoencoders and generative models

* What problems occur when using just the loss function $\|(x-g(f(x)))\|_2$ for a vanilla autoencoder. How can this problem be fixed.
* What is the learning objective of a contractive autoencoder? Write down the formula and explain the intuition behind it.
* Explain what the data manifold is. Give an applicatoin example of an relativly big and for an relativly small data manifold.
* What architecture should be used for multiobjective design of molecules?
* Give the adverserial loss and the training objective of a GAN

## Lecture 12 - Bayesian methods for autonomous experiments

* Explain (with formulas) the two steps of Baesian learning
* How would you create the following plot of a gaussian process (uncertainty bands + sample functions)?:
![](https://i.imgur.com/jkCDpWr.png)
* Make an example of a gaussian process with two data points and an unseen sample $x^*$. Explain how to infer $f(x^*)$ given the data.
* How to construct an acqustion function (Upper Confidence Bound Approach)?
* How to construct an acqustion function (Expected Improvement Approach)?

## Lecture 13 - Reinforcement learning

* How could you model the market share of three different companies making up the whole market over time with a markov model? What share does each company posess in the equilibrium state?
* Given an action A with an immediate reward of 10 and an action B with an unknown reward R two steps later. Given a discount factor of 0.5, how large does R at least have to be for the agent to choose action B?
* Derrive the recursive definition of the value function and solve it.
* What are the two components of the bellman equation?
* What do the rows and columns of a Q table represent?
* What is the difference between the value function and the Q function