A Python Distribution for Neuroscience
Ernst Strüngmann Institute
Frankfurt
Brain Research Institute
Universität Bremen
November 9, 2023
Outline
Why
What
How
Outline
Why
What
How
Data Analysis!
Statistics!
[1]: import statsmodels.api as sm
x = np.linspace(0, 10, 100); X = np.column_stack((x, x ** 2))
beta = np.array([1, 0.1, 10]); e = np.random.normal(size=100)
X = sm.add_constant(X); y = np.dot(X, beta) + e
model = sm.OLS(y, X); results = model.fit()
print(results.summary())
OLS Regression Results
==============================================================================
Dep. Variable: y R-squared: 1.000
Model: OLS Adj. R-squared: 1.000
Method: Least Squares F-statistic: 4.020e+06
Date: Wed, 25 Oct 2023 Prob (F-statistic): 2.83e-239
Time: 11:13:17 Log-Likelihood: -146.51
No. Observations: 100 AIC: 299.0
Df Residuals: 97 BIC: 306.8
Df Model: 2
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
const 1.3423 0.313 4.292 0.000 0.722 1.963
x1 -0.0402 0.145 -0.278 0.781 -0.327 0.247
x2 10.0103 0.014 715.745 0.000 9.982 10.038
==============================================================================
Omnibus: 2.042 Durbin-Watson: 2.274
Prob(Omnibus): 0.360 Jarque-Bera (JB): 1.875
Skew: 0.234 Prob(JB): 0.392
Kurtosis: 2.519 Cond. No. 144.
==============================================================================
Machine Learning!
[1]:
from sklearn.cluster import MeanShift, estimate_bandwidth
from sklearn.datasets import make_blobs
centers = [[1, 1], [-1, -1], [1, -1]]
X, _ = make_blobs(n_samples=10000, centers=centers, cluster_std=0.6)
bandwidth = estimate_bandwidth(X, quantile=0.2, n_samples=500)
ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)
ms.fit(X)
See seaborn, statsmodels and scikit-learn
See the Official Python Documentation
Taken from xkcd
See the Official conda Documentation
Outline
Why
What
How
A Python Distribution for Neuroscience
What’s Inside?
Outline
Why
What
How
Windows 10/11 (PowerShell)
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help
In [1]: _
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help
In [1]: _
+ Open a terminal window
(neuro-conda-2023b) myusername@mycomputer ~ % _
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help
In [1]: _
+ Open a terminal window
(neuro-conda-2023b) myusername@mycomputer ~ % _
(neuro-conda-2023b) myusername@mycomputer ~ % ipython
Open a PowerShell window
(neuro-conda-2023b) PS C:\Users\myusername > _
(neuro-conda-2023b) PS C:\Users\myusername > ipython
Python 3.10.12 (main, Jul 5 2023, 18:54:27) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help
In [1]: _
+ Open a terminal window
(neuro-conda-2023b) myusername@mycomputer ~ % _
(neuro-conda-2023b) myusername@mycomputer ~ % ipython
Python 3.10.11 (main, Jul 5 2023, 13:41:39) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: _
neuro-conda 🧠🐍
Thank You For Your Attention!
Stefan @pantaray stefan.fuertinger@esi-frankfurt.de
Joscha @joschaschmiedt schmiedt@brain.uni-bremen.de