Machine Learning Kurs im Rahmen der Studierendentage im SS 2023
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

557 lines
21 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. % Introduction to Data Analysis and Machine Learning in Physics: \ 2. Data modeling and fitting
  2. % Day 1: 11. April 2023
  3. % \underline{Jörg Marks}, Klaus Reygers
  4. ## Data modeling and fitting - introduction
  5. Data analysis is a process of understanding and modeling measured
  6. data. The goal is to find patterns and to obtain inferences allowing to
  7. observe underlying patterns.
  8. * There are 2 approaches to statistical data modeling
  9. * Hypothesis testing: is our data compatible with a certain model?
  10. * Determination of model parameter: use the data to determine the parameters
  11. of a (theoretical) model
  12. * For the determination of model parameter
  13. * Analysis of data distributions $\rightarrow$ mean, variance,
  14. median, FWHM, .... \newline
  15. allows for an approximate determination of model parameter
  16. * Data fitting with the least square method $\rightarrow$ an iterative
  17. process which minimizes the deviation of a model decribed by parameters
  18. from data. This determines the optimal values and uncertainties
  19. of the parameters.
  20. * Maximum likelihood fitting $\rightarrow$ find a set of model parameters
  21. which most likely describe the data by maximizing the probability
  22. distributions.
  23. The parameter determination by minimization is an integral part of machine
  24. learning approaches, here a system learns patterns and predicts
  25. related ones. This is the focus in the upcoming days.
  26. ## Data modeling and fitting - introduction
  27. Data analysis is a process of understanding and modeling measured
  28. data. The goal is to find patterns and to obtain inferences allowing to
  29. observe underlying patterns.
  30. * There are 2 approaches to statistical data modeling
  31. * Hypothesis testing: is our data compatible with a certain model?
  32. * Determination of model parameter: use the data to determine the parameters
  33. of a (theoretical) model
  34. * For the determination of model parameter
  35. * Analysis of data distributions $\rightarrow$ mean, variance,
  36. median, FWHM, .... \newline
  37. allows for an approximate determination of model parameter
  38. * \textcolor{blue}{Data fitting with the least square method $\rightarrow$ an iterative
  39. process which minimizes the deviation of a model decribed by parameters
  40. from data. This determines the optimal values and uncertainties
  41. of the parameters.}
  42. * Maximum likelihood fitting $\rightarrow$ find a set of model parameters
  43. which most likely describe the data by maximizing the probability
  44. distributions.
  45. The parameter determination by minimization is an integral part of machine
  46. learning approaches, here a system learns patterns and predicts
  47. related ones. This is the focus in the upcoming days.
  48. ## Least Square (LS) Method (1)
  49. The method determines the \textcolor{blue}{optimal parameters of functions
  50. to gaussian distributed measurements}.
  51. Lets consider a sample of $n$ measurements $y_{i}$ and a parametrized
  52. description of the measurement $\eta_{i} = f(x_{i} | \theta)$
  53. with a parameter set $\theta = \theta_{1}, \theta_{2} ,.... \theta_{k}$,
  54. dependent values $x_{i}$ and measurement errors $\sigma_{i}$.
  55. The parameter set should be determined such that
  56. \begin{equation*}
  57. \color{blue}{S = \sum \limits_{i=1}^{n} \frac{(y_i-\eta_i)^2}{\sigma_i^2} = \sum \limits_{i=1}^{n} \frac{(y_i- f(x_i|\theta))^2}{\sigma_i^2} \longrightarrow \, minimal }
  58. \end{equation*}
  59. In case of correlated measurements the covariance matrix of the $y_{i}$ has to
  60. be taken into account. This is accomplished by defining a weight matrix from
  61. the covariance matrix of the input data. A decorrelation of the input data
  62. should be considered.
  63. \vspace{0.2cm}
  64. $S$ follows a $\chi^{2}$-distribution with $(n-k)$ degrees of freedom.
  65. ## Least Square (LS) Method (2)
  66. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  67. * Example LS-method
  68. \vspace{0.2cm}
  69. Often the fit function $f(x, \theta)$ is linear in
  70. $\theta = \theta_{1}, \theta_{2} ,.... \theta_{k}$
  71. \vspace{0.2cm}
  72. $f(x | \theta) = \theta_{1} f_{1}(x) + .... + \theta_{k} f_{k}(x)$
  73. \vspace{0.2cm}
  74. If the model is a straight line and our parameters are $\theta_{1}$ and
  75. $\theta_{2}$ $(f_{1}(x) = 1,$ $f_{2}(x) = x)$ we have
  76. $f(x | \theta) = \theta_{1} + \theta_{2} x$
  77. \vspace{0.2cm}
  78. The LS equation is
  79. \vspace{0.2cm}
  80. $\color{blue}{S = \sum \limits_{i=1}^{n} \frac{(y_i-\eta_i)^2}{\sigma_i^2} } \color{black} {= \sum
  81. \limits_{i=1}^{n} \frac{(y_{i} - \theta_{1} - x_{i}
  82. \theta_{2})^2}{\sigma_i^2 }}$ \hspace{0.4cm} and with
  83. \vspace{0.2cm}
  84. $\frac{\partial S}{\partial \theta_1} = \sum\limits_{i=1}^{n} \frac{-2
  85. (y_i - \theta_1 - x_i \theta_2)}{\sigma_i^2} = 0$ \hspace{0.4cm} and \hspace{0.4cm}
  86. $\frac{\partial S}{\partial \theta_2} = \sum\limits_{i=1}^{n} \frac{-2 x_i (y_i - \theta_1 - x_i \theta_2)}{\sigma_i^2} = 0$
  87. \vspace{0.2cm}
  88. the parameters $\theta_{1}$ and $\theta_{2}$ can be determined.
  89. \vspace{0.2cm}
  90. \textcolor{olive}{In case of linear fit functions solutions can be found by matrix inversion}
  91. \vfill
  92. ## Least Square (LS) Method (3)
  93. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  94. * Use of a nonlinear fit function $f(x, \theta)$ like \hspace{0.4cm}
  95. $f(x | \theta) = \theta_{1} \cdot e^{-\theta_{2} x}$
  96. \vspace{0.2cm}
  97. results in the LS equation
  98. \vspace{0.2cm}
  99. $\color{blue}{S = \sum \limits_{i=1}^{n} \frac{(y_i-\eta_i)^2}{\sigma_i^2} } \color{black} {= \sum \limits_{i=1}^{n} \frac{(y_{i} - \theta_{1} \cdot e^{-\theta_{2} x_{i}})^2}{\sigma_i^2 }}$ \hspace{0.4cm}
  100. \vspace{0.2cm}
  101. which we have to minimize
  102. \vspace{0.2cm}
  103. $\frac{\partial S}{\partial \theta_1} = \sum\limits_{i=1}^{n} \frac{ 2 e^{-2 \theta_2 x_i} ( \theta_1 - y_i e^{\theta_2 x_i} )} {\sigma_i^2 } = 0$ \hspace{0.4cm} and \hspace{0.4cm}
  104. $\frac{\partial S}{\partial \theta_2} = \sum\limits_{i=1}^{n} \frac{ 2 \theta_1 x_I e^{-2 \theta_2 x_i} (y_i e^{\theta_2 x_i} - \theta_1)} {\sigma_i^2 } = 0$
  105. \vspace{0.4cm}
  106. In a nonlinear system, the LS Ansatz leads to derivatives which are
  107. functions of the independent variable and the parameters $\color{red}\rightarrow$ \textcolor{olive}{no closed solutions}
  108. \vspace{0.4cm}
  109. In general, we have gradient equations which don't have closed solutions.
  110. There are a couple of methods including approximations which allow together
  111. with numerical methods to find a global minimum, Gauss–Newton algorithm,
  112. Levenberg–Marquardt algorithm, gradient descend methods and also direct
  113. search methods.
  114. ## Minuit - a programm package for minimization (1)
  115. In general data fitting and also solving machine learning algorithms lead
  116. to a minimization problem of functions. In the
  117. 1975-1980 F. James (CERN) developed
  118. a FORTRAN-based package, [\textcolor{violet}{MINUIT}](http://seal.web.cern.ch/seal/documents/minuit/mntutorial.pdf), which is a framework to handle
  119. multiparameter minimization and compute the best-fit parameter values and
  120. uncertainties, including correlations between the parameters.
  121. \vspace{0.2cm}
  122. The user provides a minimization function
  123. $F(X,P)$ with the parameter space $P=(p_1,....p_k)$ and
  124. variable space $X$ (also multi-dimensional). There is an interface via
  125. functions which influences the
  126. minimization process. MINUIT provides
  127. [\textcolor{violet}{error calculations}](http://seal.web.cern.ch/seal/documents/minuit/mnerror.pdf) including correlations for the parameter space by evaluating the shape of the function in some neighbourhood of the minimum.
  128. \vspace{0.2cm}
  129. The package
  130. has now a new object-oriented implementation as [\textcolor{violet}{Minuit2 library}](https://root.cern.ch/root/htmldoc/guides/minuit2/Minuit2.html) , written
  131. in C++.
  132. \vspace{0.2cm}
  133. During the minimization $F(X,P)$ is evaluated for various $X$. For the
  134. choice of $P=(p_1,....p_k)$ different methods are used
  135. ## Minuit - a programm package for minimization (2)
  136. \vspace{0.4cm}
  137. \textcolor{olive}{SEEK}: Search for the minimum with Monte Carlo methods, mostly used at the start
  138. of the minimization with unknown starting values. It is not a converging
  139. algorithm.
  140. \vspace{0.2cm}
  141. \textcolor{olive}{SIMPLX}:
  142. Uses the simplex method of Nelder and Mead. Function values are compared
  143. in the parameter space. Via step size control the minimum is approached.
  144. Parameter errors are only approximate, no covariance matrix is calculated.
  145. \vspace{0.2cm}
  146. <!---
  147. A simplex is the smallest n dimensional figure with n+1 corners. By reflecting
  148. one point in the hyperplane of the other point and adopts itself to the
  149. function plane.
  150. -->
  151. \textcolor{olive}{MIGRAD}:
  152. Uses an algorithm of R. Fletcher, which takes the function and the gradient
  153. to approach the minimum with a variable metric method. An error matrix and
  154. correlation coefficients are available
  155. \vspace{0.2cm}
  156. \textcolor{olive}{HESSE}:
  157. Calculates the hessian matrix of second derivatives and determines the
  158. covariance matrix.
  159. \vspace{0.2cm}
  160. \textcolor{olive}{MINOS}:
  161. Calculates (asymmetric) errors using likelihood profiles.
  162. The algorithm for finding the positive and negative MINOS errors for parameter
  163. $n$ consists of varying $n$ each time minimizing $F(X,P)$ with respect to
  164. all the others.
  165. \vspace{0.2cm}
  166. ## Minuit - a programm package for minimization (3)
  167. \vspace{0.4cm}
  168. Fit process with the minuit package
  169. \vspace{0.2cm}
  170. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  171. * The individual steps decribed above can be called several times and in different order during the minimization process.
  172. * Each of the parameters $p_i$ of $P=(p_1,....p_k)$ can be set constant and
  173. released during the minimization steps.
  174. * Problems are expected in models with strong correlation between
  175. parameters $\rightarrow$ change model to uncorrelated definitions
  176. * Local minima, edges/steps or undefined ranges in $F(X,P)$ are problematic
  177. $\rightarrow$ simplify your model
  178. \vspace{3cm}
  179. ## Minuit2 - The iminuit package
  180. \vspace{0.4cm}
  181. [\textcolor{violet}{iminuit}](https://iminuit.readthedocs.io/en/stable/) is
  182. a Jupyter-friendly Python interface for the Minuit2 C++ library.
  183. \vspace{0.2cm}
  184. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  185. * The class `iminuit.Minuit` instanciates the minuit object. The minimizer
  186. function is given as argument. Basic steering of the fit
  187. like setting start parameters, error definition and print level is also
  188. done here.
  189. \footnotesize
  190. ```python
  191. from iminuit import Minuit
  192. def fcn(x, y, z): # definition of the minimizer function
  193. return (x - 2) ** 2 + (y - x) ** 2 + (z - 4) ** 2
  194. fcn.errordef = Minuit.LEAST_SQUARES # for Minuit to compute errors correctly
  195. m = Minuit(fcn, x=0, y=0, z=0) # instanciate minuit, set start values
  196. ```
  197. \normalsize
  198. * Several methods determine the interaction with the fitting process, calls
  199. to `migrad`, `hesse` or printing of parameters and errors
  200. \footnotesize
  201. ```python
  202. ......
  203. m.migrad() # run optimiser
  204. print(m.values , m.errors) # print results
  205. m.hesse() # run covariance estimator
  206. ```
  207. \normalsize
  208. ## Minuit2 - iminuit example
  209. \vspace{0.2cm}
  210. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  211. * The function `fcn` describes the model with parameters to be determined by
  212. data. `fcn` is minimal when the model parameters agree best with data.
  213. `fcn` has positional arguments, one for each fit parameter. `iminuit`
  214. example fit:
  215. [\textcolor{violet}{02\_fit\_exp\_fit\_iMinuit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_exp_fit_iMinuit.ipynb)
  216. \footnotesize
  217. ```python
  218. ......
  219. x = np.array([....],dtype='d') # measurements x
  220. y = np.array([....],dtype='d') # measurements y
  221. dy = np.array([....],dtype='d') # error in y
  222. def xp(a, b , c):
  223. return a * np.exp(b*x) + c
  224. # least-squares function = sum of data residuals squared
  225. def fcn(a,b,c):
  226. return np.sum((y - xp(a,b,c)) ** 2 / dy ** 2)
  227. # limit the range of b and fix parameter c
  228. m = Minuit(fcn,a=1,b=-0.7,c=1)
  229. m.migrad() # run minimizer
  230. m.fixed["c"] = False / True # fix or release parameter c
  231. m.migrad() # rerun minimizer
  232. # Might be useful to fix parameters or limit the range for some applications
  233. ```
  234. \normalsize
  235. ## Minuit2 - iminuit (3)
  236. \vspace{0.2cm}
  237. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  238. * Results and control information of the fit can be printed and accessed
  239. in the the prorgamm.
  240. \footnotesize
  241. ```python
  242. ......
  243. m = Minuit(fcn,....) # run the initializer
  244. m.migrad() # run minimizer
  245. a_fit = m.values['a'] # get parameter value a
  246. a_fit_error = m.errors['a'] # get parameter error of a
  247. print (m.values,m.errors) # print results
  248. ```
  249. \normalsize
  250. * After processing Hesse, covariance and correlation information of the
  251. fit is available
  252. \footnotesize
  253. ```python
  254. ......
  255. m.hesse() # run covariance estimator
  256. m.matrix() # get covariance matrix
  257. m.covariance # get full covariance matrix
  258. cov = m.covariance # save matrix to access by numpy
  259. print(cov[0, 1]) # print correlation between parameter 1 and 2
  260. ```
  261. \normalsize
  262. ## Minuit2 - iminuit (4)
  263. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  264. * Minos provides asymmetric uncertainty intervals and parameter contours by
  265. scanning one parameter and minimizing the function with respect to all other
  266. parameters for each scan point. Results are displayed with `matplotlib`.
  267. \footnotesize
  268. ```python
  269. ......
  270. m.minos()
  271. print (m.get_merrors()['a'])
  272. m.draw_profile('b')
  273. m.draw_mncontour('a', 'b', cl=[1, 2, 3, 4])
  274. ```
  275. ::: columns
  276. :::: {.column width=40%}
  277. ![](figures/iminuit_minos_scan-1.png)
  278. ::::
  279. :::: {.column width=40%}
  280. ![](figures/iminuit_minos_scan-2.png)
  281. ::::
  282. :::
  283. ## Exercise 3
  284. Plot the following data with matplotlib as in the iminuit example:
  285. \footnotesize
  286. ```
  287. x: 0.2,0.4,0.6,0.8,1.,1.2,1.4,1.6,1.8,2.,2.2,2.4,2.6,2.8,3.,3.2,
  288. 3.4,3.6, 3.8,4.
  289. y: 0.04,0.021,0.035,0.03,0.029,0.019,0.024,0.018,0.019,0.022,0.02,
  290. 0.025,0.018,0.024,0.019,0.021,0.03,0.019,0.03,0.024
  291. dy: 1.792,1.695,1.541,1.514,1.427,1.399,1.388,1.270,1.262,1.228,1.189,
  292. 1.182,1.121,1.129,1.124,1.089,1.092,1.084,1.058,1.057
  293. ```
  294. \normalsize
  295. \setbeamertemplate{itemize item}{\color{red}$\square$}
  296. * Exchange in the example iminuit fit `02_fit_exp_fit_iMinuit.ipynb` the
  297. exponential function by a 3rd order polynomial and perform the fit
  298. * Compare the correlation of the parameters of the exponential and
  299. the polynomial fit
  300. * What defines the fit quality, give an estimate
  301. \small
  302. Solution: [\textcolor{violet}{02\_fit\_ex\_3\_sol.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/solutions/02_fit_ex_3_sol.ipynb) \normalsize
  303. ## Exercise 4
  304. Plot the following data with matplotlib:
  305. \footnotesize
  306. ```
  307. x: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  308. dx: 0.1,0.1,0.5,0.1,0.5,0.1,0.5,0.1,0.5,0.1
  309. y: 1.1,2.3,2.7,3.2,3.1,2.4,1.7,1.5,1.5,1.7
  310. dy: 0.15,0.22,0.29,0.39,0.31,0.21,0.13,0.15,0.19,0.13
  311. ```
  312. \normalsize
  313. \setbeamertemplate{itemize item}{\color{red}$\square$}
  314. * Perform a fit with iminuit. Which model do you use?
  315. * Plot the resulting fit function in the graph with the data
  316. * Print the covariance matrix. Can we improve the errors.
  317. * Can you draw a contour plot of 2 of the fit parameters.
  318. \small
  319. Solution: [\textcolor{violet}{02\_fit\_ex\_4\_sol.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/solutions/02_fit_ex_4_sol.ipynb) \normalsize
  320. ## PyROOT
  321. [\textcolor{violet}{PyROOT}](https://root.cern/manual/python/) is the python binding for the C++ data analysis toolkit [\textcolor{violet}{ROOT}](https://root.cern/) developed with and for the LHC community. You can access the full
  322. ROOT functionality from Python while
  323. benefiting from the performance of the ROOT C++ libraries. The PyROOT bindings
  324. are automatic and dynamic and are able to interoperate with widely-used Python
  325. data-science libraries as `NumPy`, `pandas`, SciPy `scikit-learn` and `tensorflow`.
  326. * ROOT/PyROOT can be installed easily within anaconda3 (ROOT version 6.26.06
  327. or later ) or is available in the
  328. [\textcolor{violet}{CIP jupyter3 Hub}](https://jupyter3.kip.uni-heidelberg.de/)
  329. * Tools for statistical analysis, a math library with optimized algorithms,
  330. multivariate analysis, visualization and simulation of data.
  331. * Storing data including objects and classes with compression in files is a
  332. very powerfull aspect for any data analysis project
  333. * Within PyROOT Minuit2 can be accessed easily either with predefined functions
  334. or your own function definition
  335. * For advanced statistical analyses and data modeling likelihood fitting with
  336. the packages **rooFit** and **rooStats** is available.
  337. ##
  338. * Example reading the invariant mass measurements of a $D^0$ from a text file
  339. and determine $\mu$ and $\sigma$ \hspace{1.0cm} \small
  340. [\textcolor{violet}{02\_fit\_histFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_histFit.ipynb)
  341. \hspace{0.5cm} run with: python3 -i 02_fit_histFit.py
  342. \normalsize
  343. \footnotesize
  344. ```python
  345. import numpy as np
  346. import math
  347. from ROOT import TCanvas, TFile, TH1D, TF1, TMinuit, TFitResult
  348. data = np.genfromtxt('D0Mass.txt', dtype='d') # read data from text file
  349. c = TCanvas('c','D0 Mass',200,10,700,500) # instanciate output canvas
  350. d0 = TH1D('d0','D0 Mass',200,1700.,2000.) # instanciate histogramm
  351. for x in data : # fill data into histogramm d0
  352. d0.Fill(x)
  353. def pyf_tf1_params(x, p): # define fit function
  354. return p[0] * math.exp (-0.5 * ((x[0] - p[1])**2 / p[2]**2))
  355. func = TF1("func",pyf_tf1_params,1840.,1880.,3)
  356. # func = TF1("func",'gaus',1840.,1880.) # use predefined function
  357. func.SetParameters(500.,1860.,5.5) # set start parameters
  358. myfit = d0.Fit(func,"S") # fit function to the histogramm data
  359. print ("Fit results: mean=",myfit.Parameter(0)," +/- ",myfit.ParError(0))
  360. c.Draw() # draw canvas
  361. myfile = TFile('myOutFile.root','RECREATE') # Open a ROOT file for output
  362. c.Write() # Write canvas
  363. d0.Write() # Write histogram
  364. myfile.Close() # close file
  365. ```
  366. \normalsize
  367. ##
  368. * Fit Options
  369. \vspace{0.1cm}
  370. ::: columns
  371. :::: {.column width=2%}
  372. ::::
  373. :::: {.column width=98%}
  374. ![](figures/rootOptions.png)
  375. ::::
  376. :::
  377. ## Exercise 5
  378. Read text file [\textcolor{violet}{FitTestData.txt}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/exercises/FitTestData.txt) and draw a histogramm using PyROOT.
  379. \setbeamertemplate{itemize item}{\color{red}$\square$}
  380. * Determine the mean and sigma of the signal distribution. Which function do
  381. you use for fitting?
  382. * The option S fills the result object.
  383. * Try to improve the errors of the fit values with minos using the option E
  384. and also try the option M to scan for a new minimum, option V provides more
  385. output.
  386. * Fit the background outside the signal region use the option R+ to add the
  387. function to your fit
  388. \small
  389. Solution: [\textcolor{violet}{02\_fit\_ex\_5\_sol.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/solutions/02_fit_ex_5_sol.ipynb) \normalsize
  390. ## iPython Examples for Fitting
  391. The different python packages are used in
  392. \textcolor{blue}{example iPython notebooks}
  393. to demonstrate the fitting of a third order polynomial to the same data
  394. available as numpy arrays.
  395. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  396. * LSQ fit of a polynomial to data using Minuit2 with
  397. \textcolor{blue}{iminuit} and \textcolor{blue}{matplotlib} plot:
  398. \small
  399. [\textcolor{violet}{02\_fit\_iminuitFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_iminuitFit.ipynb)
  400. \normalsize
  401. * Graph fitting with \textcolor{blue}{pyROOT} with options using a python
  402. function including confidence level plot:
  403. \small
  404. [\textcolor{violet}{02\_fit\_fitGraph.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_fitGraph.ipynb)
  405. \normalsize
  406. * Graph fitting with \textcolor{blue}{numpy} and confidence level
  407. plotting with \textcolor{blue}{matplotlib}:
  408. \small
  409. [\textcolor{violet}{02\_fit\_numpyFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_numpyFit.ipynb)
  410. \normalsize
  411. * Graph fitting with a polynomial fit of \textcolor{blue}{scikit-learn} and
  412. plotting with \textcolor{blue}{matplotlib}:
  413. \normalsize
  414. \small
  415. [\textcolor{violet}{02\_fit\_scikitFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_scikitFit.ipynb)
  416. \normalsize