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.

558 lines
21 KiB

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. determination of $P=(p_1,....p_k)$ least square or
  135. likelihood methods are used. Several minimization methods are available
  136. ## Minuit - a programm package for minimization (2)
  137. \vspace{0.4cm}
  138. \textcolor{olive}{SEEK}: Search for the minimum with Monte Carlo methods, mostly used at the start
  139. of the minimization with unknown starting values. It is not a converging
  140. algorithm.
  141. \vspace{0.2cm}
  142. \textcolor{olive}{SIMPLX}:
  143. Uses the simplex method of Nelder and Mead. Function values are compared
  144. in the parameter space. Via step size control the minimum is approached.
  145. Parameter errors are only approximate, no covariance matrix is calculated.
  146. \vspace{0.2cm}
  147. <!---
  148. A simplex is the smallest n dimensional figure with n+1 corners. By reflecting
  149. one point in the hyperplane of the other point and adopts itself to the
  150. function plane.
  151. -->
  152. \textcolor{olive}{MIGRAD}:
  153. Uses an algorithm of R. Fletcher, which takes the function and the gradient
  154. to approach the minimum with a variable metric method. An error matrix and
  155. correlation coefficients are available
  156. \vspace{0.2cm}
  157. \textcolor{olive}{HESSE}:
  158. Calculates the hessian matrix of second derivatives and determines the
  159. covariance matrix.
  160. \vspace{0.2cm}
  161. \textcolor{olive}{MINOS}:
  162. Calculates (asymmetric) errors using likelihood profiles.
  163. The algorithm for finding the positive and negative MINOS errors for parameter
  164. $n$ consists of varying $n$ each time minimizing $F(X,P)$ with respect to
  165. all the others.
  166. \vspace{0.2cm}
  167. ## Minuit - a programm package for minimization (3)
  168. \vspace{0.4cm}
  169. Fit process with the minuit package
  170. \vspace{0.2cm}
  171. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  172. * The individual steps decribed above can be called several times and in different order during the minimization process.
  173. * Each of the parameters $p_i$ of $P=(p_1,....p_k)$ can be set constant and
  174. released during the minimization steps.
  175. * Problems are expected in models with strong correlation between
  176. parameters $\rightarrow$ change model to uncorrelated definitions
  177. * Local minima, edges/steps or undefined ranges in $F(X,P)$ are problematic
  178. $\rightarrow$ simplify your model
  179. \vspace{3cm}
  180. ## Minuit2 - The iminuit package
  181. \vspace{0.4cm}
  182. [\textcolor{violet}{iminuit}](https://iminuit.readthedocs.io/en/stable/) is
  183. a Jupyter-friendly Python interface for the Minuit2 C++ library.
  184. \vspace{0.2cm}
  185. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  186. * The class `iminuit.Minuit` instanciates the minuit object. The minimizer
  187. function is given as argument. Basic steering of the fit
  188. like setting start parameters, error definition and print level is also
  189. done here.
  190. \footnotesize
  191. ```python
  192. from iminuit import Minuit
  193. def fcn(x, y, z): # definition of the minimizer function
  194. return (x - 2) ** 2 + (y - x) ** 2 + (z - 4) ** 2
  195. fcn.errordef = Minuit.LEAST_SQUARES # for Minuit to compute errors correctly
  196. m = Minuit(fcn, x=0, y=0, z=0) # instanciate minuit, set start values
  197. ```
  198. \normalsize
  199. * Several methods determine the interaction with the fitting process, calls
  200. to `migrad`, `hesse` or printing of parameters and errors
  201. \footnotesize
  202. ```python
  203. ......
  204. m.migrad() # run optimiser
  205. print(m.values , m.errors) # print results
  206. m.hesse() # run covariance estimator
  207. ```
  208. \normalsize
  209. ## Minuit2 - iminuit example
  210. \vspace{0.2cm}
  211. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  212. * The function `fcn` describes the model with parameters to be determined by
  213. data. `fcn` is minimal when the model parameters agree best with data.
  214. `fcn` has positional arguments, one for each fit parameter. `iminuit`
  215. example fit:
  216. [\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)
  217. \footnotesize
  218. ```python
  219. ......
  220. x = np.array([....],dtype='d') # measurements x
  221. y = np.array([....],dtype='d') # measurements y
  222. dy = np.array([....],dtype='d') # error in y
  223. def xp(a, b , c):
  224. return a * np.exp(b*x) + c
  225. # least-squares function = sum of data residuals squared
  226. def fcn(a,b,c):
  227. return np.sum((y - xp(a,b,c)) ** 2 / dy ** 2)
  228. # limit the range of b and fix parameter c
  229. m = Minuit(fcn,a=1,b=-0.7,c=1)
  230. m.migrad() # run minimizer
  231. m.fixed["c"] = False / True # fix or release parameter c
  232. m.migrad() # rerun minimizer
  233. # Might be useful to fix parameters or limit the range for some applications
  234. ```
  235. \normalsize
  236. ## Minuit2 - iminuit (3)
  237. \vspace{0.2cm}
  238. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  239. * Results and control information of the fit can be printed and accessed
  240. in the the prorgamm.
  241. \footnotesize
  242. ```python
  243. ......
  244. m = Minuit(fcn,....) # run the initializer
  245. m.migrad() # run minimizer
  246. a_fit = m.values['a'] # get parameter value a
  247. a_fit_error = m.errors['a'] # get parameter error of a
  248. print (m.values,m.errors) # print results
  249. ```
  250. \normalsize
  251. * After processing Hesse, covariance and correlation information of the
  252. fit is available
  253. \footnotesize
  254. ```python
  255. ......
  256. m.hesse() # run covariance estimator
  257. m.matrix() # get covariance matrix
  258. m.covariance # get full covariance matrix
  259. cov = m.covariance # save matrix to access by numpy
  260. print(cov[0, 1]) # print correlation between parameter 1 and 2
  261. ```
  262. \normalsize
  263. ## Minuit2 - iminuit (4)
  264. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  265. * Minos provides asymmetric uncertainty intervals and parameter contours by
  266. scanning one parameter and minimizing the function with respect to all other
  267. parameters for each scan point. Results are displayed with `matplotlib`.
  268. \footnotesize
  269. ```python
  270. ......
  271. m.minos()
  272. print (m.get_merrors()['a'])
  273. m.draw_profile('b')
  274. m.draw_mncontour('a', 'b', cl=[1, 2, 3, 4])
  275. ```
  276. ::: columns
  277. :::: {.column width=40%}
  278. ![](figures/iminuit_minos_scan-1.png)
  279. ::::
  280. :::: {.column width=40%}
  281. ![](figures/iminuit_minos_scan-2.png)
  282. ::::
  283. :::
  284. ## Exercise 3
  285. Plot the following data with matplotlib as in the iminuit example:
  286. \footnotesize
  287. ```
  288. 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,
  289. 3.4,3.6, 3.8,4.
  290. y: 0.04,0.021,0.035,0.03,0.029,0.019,0.024,0.018,0.019,0.022,0.02,
  291. 0.025,0.018,0.024,0.019,0.021,0.03,0.019,0.03,0.024
  292. dy: 1.792,1.695,1.541,1.514,1.427,1.399,1.388,1.270,1.262,1.228,1.189,
  293. 1.182,1.121,1.129,1.124,1.089,1.092,1.084,1.058,1.057
  294. ```
  295. \normalsize
  296. \setbeamertemplate{itemize item}{\color{red}$\square$}
  297. * Exchange in the example iminuit fit `02_fit_exp_fit_iMinuit.ipynb` the
  298. exponential function by a 3rd order polynomial and perform the fit
  299. * Compare the covariance/correlation of the parameters of the exponential and
  300. the polynomial fit
  301. * What defines the fit quality, give an estimate
  302. \small
  303. 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
  304. ## Exercise 4
  305. Plot the following data with matplotlib:
  306. \footnotesize
  307. ```
  308. x: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  309. dx: 0.1,0.1,0.5,0.1,0.5,0.1,0.5,0.1,0.5,0.1
  310. y: 1.1,2.3,2.7,3.2,3.1,2.4,1.7,1.5,1.5,1.7
  311. dy: 0.15,0.22,0.29,0.39,0.31,0.21,0.13,0.15,0.19,0.13
  312. ```
  313. \normalsize
  314. \setbeamertemplate{itemize item}{\color{red}$\square$}
  315. * Perform a fit with iminuit. Which model do you use?
  316. * Plot the resulting fit function in the graph with the data
  317. * Print the covariance matrix. Can we improve the errors.
  318. * Can you draw a contour plot of 2 of the fit parameters.
  319. \small
  320. 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
  321. ## PyROOT
  322. [\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
  323. ROOT functionality from Python while
  324. benefiting from the performance of the ROOT C++ libraries. The PyROOT bindings
  325. are automatic and dynamic and are able to interoperate with widely-used Python
  326. data-science libraries as `NumPy`, `pandas`, SciPy `scikit-learn` and `tensorflow`.
  327. * ROOT/PyROOT can be installed easily within anaconda3 (ROOT version 6.26.06
  328. or later ) or is available in the
  329. [\textcolor{violet}{CIP jupyter3 Hub}](https://jupyter3.kip.uni-heidelberg.de/)
  330. * Tools for statistical analysis, a math library with optimized algorithms,
  331. multivariate analysis, visualization and simulation of data.
  332. * Storing data including objects and classes with compression in files is a
  333. very powerfull aspect for any data analysis project
  334. * Within PyROOT Minuit2 can be accessed easily either with predefined functions
  335. or your own function definition
  336. * For advanced statistical analyses and data modeling likelihood fitting with
  337. the packages **rooFit** and **rooStats** is available.
  338. ##
  339. * Example reading the invariant mass measurements of a $D^0$ from a text file
  340. and determine $\mu$ and $\sigma$ \hspace{1.0cm} \small
  341. [\textcolor{violet}{02\_fit\_histFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_histFit.ipynb)
  342. \hspace{0.5cm} run with: python3 -i 02_fit_histFit.py
  343. \normalsize
  344. \footnotesize
  345. ```python
  346. import numpy as np
  347. import math
  348. from ROOT import TCanvas, TFile, TH1D, TF1, TMinuit, TFitResult
  349. data = np.genfromtxt('D0Mass.txt', dtype='d') # read data from text file
  350. c = TCanvas('c','D0 Mass',200,10,700,500) # instanciate output canvas
  351. d0 = TH1D('d0','D0 Mass',200,1700.,2000.) # instanciate histogramm
  352. for x in data : # fill data into histogramm d0
  353. d0.Fill(x)
  354. def pyf_tf1_params(x, p): # define fit function
  355. return p[0] * math.exp (-0.5 * ((x[0] - p[1])**2 / p[2]**2))
  356. func = TF1("func",pyf_tf1_params,1840.,1880.,3)
  357. # func = TF1("func",'gaus',1840.,1880.) # use predefined function
  358. func.SetParameters(500.,1860.,5.5) # set start parameters
  359. myfit = d0.Fit(func,"S") # fit function to the histogramm data
  360. print ("Fit results: mean=",myfit.Parameter(0)," +/- ",myfit.ParError(0))
  361. c.Draw() # draw canvas
  362. myfile = TFile('myOutFile.root','RECREATE') # Open a ROOT file for output
  363. c.Write() # Write canvas
  364. d0.Write() # Write histogram
  365. myfile.Close() # close file
  366. ```
  367. \normalsize
  368. ##
  369. * Fit Options
  370. \vspace{0.1cm}
  371. ::: columns
  372. :::: {.column width=2%}
  373. ::::
  374. :::: {.column width=98%}
  375. ![](figures/rootOptions.png)
  376. ::::
  377. :::
  378. ## Exercise 5
  379. 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.
  380. \setbeamertemplate{itemize item}{\color{red}$\square$}
  381. * Determine the mean and sigma of the signal distribution. Which function do
  382. you use for fitting?
  383. * The option S fills the result object.
  384. * Try to improve the errors of the fit values with minos using the option E
  385. and also try the option M to scan for a new minimum, option V provides more
  386. output.
  387. * Fit the background outside the signal region use the option R+ to add the
  388. function to your fit
  389. \small
  390. 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
  391. ## iPython Examples for Fitting
  392. The different python packages are used in
  393. \textcolor{blue}{example iPython notebooks}
  394. to demonstrate the fitting of a third order polynomial to the same data
  395. available as numpy arrays.
  396. \setbeamertemplate{itemize item}{\color{red}\tiny$\blacksquare$}
  397. * LSQ fit of a polynomial to data using Minuit2 with
  398. \textcolor{blue}{iminuit} and \textcolor{blue}{matplotlib} plot:
  399. \small
  400. [\textcolor{violet}{02\_fit\_iminuitFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_iminuitFit.ipynb)
  401. \normalsize
  402. * Graph fitting with \textcolor{blue}{pyROOT} with options using a python
  403. function including confidence level plot:
  404. \small
  405. [\textcolor{violet}{02\_fit\_fitGraph.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_fitGraph.ipynb)
  406. \normalsize
  407. * Graph fitting with \textcolor{blue}{numpy} and confidence level
  408. plotting with \textcolor{blue}{matplotlib}:
  409. \small
  410. [\textcolor{violet}{02\_fit\_numpyFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_numpyFit.ipynb)
  411. \normalsize
  412. * Graph fitting with a polynomial fit of \textcolor{blue}{scikit-learn} and
  413. plotting with \textcolor{blue}{matplotlib}:
  414. \normalsize
  415. \small
  416. [\textcolor{violet}{02\_fit\_scikitFit.ipynb}](https://www.physi.uni-heidelberg.de/~reygers/lectures/2023/ml/examples/02_fit_scikitFit.ipynb)
  417. \normalsize