data-science-concepts 2026.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ """Helper functions for the Concepts in Data Science practicals (Wageningen University)."""
2
+ from importlib.metadata import version
3
+
4
+ from .decision_boundary import plot_decision_boundary
5
+ from .pca_example import make_pca_example_figure
6
+
7
+ __version__ = version("data-science-concepts")
8
+ __all__ = ["make_pca_example_figure", "plot_decision_boundary"]
@@ -0,0 +1,31 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import seaborn as sns
4
+
5
+
6
+ def plot_decision_boundary(X, y, feature_names, clf, ax=None, proba=True):
7
+ """
8
+ Utility function for plotting a binary classication boundary in a 2D dataset
9
+ This function does not work for any other classification problem (e.g. multiclass) or feature dimensionality
10
+ """
11
+ if ax is None:
12
+ fig, ax = plt.subplots(figsize=(10,10))
13
+ # Plot the decision boundary by assigning a color to each point in the mesh [x_min, x_max]x[y_min, y_max].
14
+ x_min, x_max = X[feature_names[0]].min() - 1, X[feature_names[0]].max() + 1
15
+ y_min, y_max = X[feature_names[1]].min() - 1, X[feature_names[1]].max() + 1
16
+ step = 0.05
17
+ xx, yy = np.meshgrid(np.arange(x_min, x_max, step),
18
+ np.arange(y_min, y_max, step))
19
+
20
+ # Predict on all data points
21
+ if proba:
22
+ Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
23
+ else:
24
+ Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
25
+
26
+ # Put the result into a color plot
27
+ Z = Z.reshape(xx.shape)
28
+ ax.contourf(xx, yy, Z, alpha=0.6, cmap="RdYlBu_r")
29
+
30
+ # Plot data points
31
+ sns.scatterplot(data=X, x=feature_names[0], y=feature_names[1], hue=y, s=30, palette="RdYlBu_r", ax=ax, edgecolor='black')
@@ -0,0 +1,148 @@
1
+ import numpy as np
2
+ import plotly.graph_objects as go
3
+ from plotly.subplots import make_subplots
4
+ from sklearn.decomposition import PCA
5
+
6
+
7
+ def make_pca_example_figure():
8
+ """Interactive figure of PCA on a simulated 3D dataset: the data space with the
9
+ first two principal components (left) and the projection onto those components (right)."""
10
+ np.random.seed(0)
11
+ X1 = np.random.normal(0, 15, 50)
12
+ X2 = X1 + np.random.normal(0, 10, 50)
13
+ X3 = X1 + np.random.normal(0, 10, 50)
14
+
15
+ dat = np.array([X1, X2, X3]).T
16
+ mu = dat.mean(axis=0)
17
+
18
+ n_comp = 2
19
+
20
+ pca = PCA(n_components=2).fit(dat)
21
+ latent_points = pca.transform(dat).T
22
+
23
+ pc1_latent = np.array([
24
+ [0, -30],
25
+ [0, 30]
26
+ ])
27
+ pc1 = np.dot(pc1_latent, pca.components_[:n_comp,:]) + mu[0]
28
+
29
+ pc2_latent = np.array([
30
+ [-80, 0],
31
+ [80, 0]
32
+ ])
33
+ pc2 = np.dot(pc2_latent, pca.components_[:n_comp,:]) + mu[1]
34
+
35
+ fig = make_subplots(
36
+ specs=[[
37
+ dict(type='scene'),
38
+ dict(type='xy')
39
+ ]],
40
+ subplot_titles=['Data space (3D)', 'Principal Component space (2D)'],
41
+ rows=1,
42
+ cols=2)
43
+
44
+ # Data space (3D)
45
+ fig.add_trace(
46
+ go.Scatter3d(
47
+ x=X1,
48
+ y=X2,
49
+ z=X3,
50
+ mode='markers',
51
+ marker=dict(
52
+ size=4,
53
+ color='darkblue',
54
+ opacity=.7
55
+ ),
56
+ showlegend=False
57
+ ),
58
+ row=1,col=1
59
+ )
60
+
61
+ fig.add_trace(
62
+ go.Scatter3d(
63
+ x=pc1.T[0],
64
+ y=pc1.T[1],
65
+ z=pc1.T[2],
66
+ mode='lines',
67
+ marker=dict(
68
+ color='orange'
69
+ ),
70
+ showlegend=False
71
+ ),
72
+ row=1,col=1
73
+ )
74
+
75
+ fig.add_trace(
76
+ go.Scatter3d(
77
+ x=pc2.T[0],
78
+ y=pc2.T[1],
79
+ z=pc2.T[2],
80
+ mode='lines',
81
+ marker=dict(
82
+ color='darkgreen'
83
+ ),
84
+ showlegend=False
85
+ ),
86
+ row=1,col=1
87
+ )
88
+
89
+ # Latent space (2D)
90
+ fig.add_trace(
91
+ go.Scatter(
92
+ x=latent_points[0],
93
+ y=latent_points[1],
94
+ mode='markers',
95
+ marker=dict(
96
+ size=8,
97
+ color='darkblue',
98
+ opacity=.7
99
+ ),
100
+ showlegend=False
101
+ ),
102
+ row=1,
103
+ col=2
104
+ )
105
+
106
+ fig.add_trace(
107
+ go.Scatter(
108
+ x=pc1_latent.T[0],
109
+ y=pc1_latent.T[1],
110
+ mode='lines',
111
+ marker=dict(
112
+ color='orange'
113
+ ),
114
+ showlegend=False
115
+ ),
116
+ row=1,col=2
117
+ )
118
+
119
+ fig.add_trace(
120
+ go.Scatter(
121
+ x=pc2_latent.T[0],
122
+ y=pc2_latent.T[1],
123
+ mode='lines',
124
+ marker=dict(
125
+ color='darkgreen'
126
+ ),
127
+ showlegend=False
128
+ ),
129
+ row=1,col=2
130
+ )
131
+
132
+ fig.update_xaxes(
133
+ title_text=f'PC1 ({pca.explained_variance_ratio_[0] * 100:.4}% variance)',
134
+ range=(-100, 100),
135
+ row=1,
136
+ col=2
137
+ )
138
+ fig.update_yaxes(
139
+ title_text=f'PC2 ({pca.explained_variance_ratio_[1] * 100:.3}% variance)',
140
+ range=(-50, 50),
141
+ row=1,
142
+ col=2
143
+ )
144
+
145
+
146
+ fig.update_layout(margin=dict(l=0, r=40, b=100, t=100))
147
+ #fig.show()
148
+ return fig
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.5
2
+ Name: data-science-concepts
3
+ Version: 2026.0.0
4
+ Summary: Helper functions for the Concepts in Data Science practicals (Wageningen University)
5
+ Project-URL: Repository, https://github.com/wur-bioinformatics/data-science-concepts
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: numpy
11
+ Requires-Dist: plotly
12
+ Requires-Dist: scikit-learn
13
+ Requires-Dist: seaborn
14
+ Description-Content-Type: text/markdown
15
+
16
+ # _INF34306_ Concepts in Data Science
17
+
18
+ Notebooks and datasets for Concepts in Data Science practicals.
19
+
20
+ ### Using the notebooks
21
+
22
+ The notebooks are meant to be used in [Google Colab](https://colab.research.google.com). Open a notebook with one of the links below, then use *File → Save a copy in Drive* to keep your changes.
23
+
24
+ | Block | Tutorial | Project |
25
+ |---|---|---|
26
+ | 1 - Introduction | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block1_introduction/tutorial_1.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block1_introduction/project_1.ipynb) |
27
+ | 2 - Python libraries, Visualization, and the Grammar of Graphics | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block2_visualisation/tutorial_2.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block2_visualisation/project_2.ipynb) |
28
+ | 3 - Data exploration I | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block3_exploration_1/tutorial_3.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block3_exploration_1/project_3.ipynb) |
29
+ | 4 - Data exploration II | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block4_exploration_2/tutorial_4.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wur-bioinformatics/data-science-concepts/blob/main/notebooks/block4_exploration_2/project_4.ipynb) |
30
+
31
+ In blocks 1 and 2, students download the datasets from Kaggle themselves and upload them to Colab (`files.upload()`). From block 3 onwards, the notebooks read datasets directly from this repository on GitHub (`DATA_URL` in the notebooks). Note that this points to the `main` branch: files that are not on `main` yet will not load.
32
+
33
+ ### Repository structure
34
+
35
+ Notebooks with exercises and examples are in the `notebooks` folder, with one subfolder per block. Datasets (when not available through APIs) are in the `datasets` folder, with informative filenames.
36
+
37
+ ```
38
+ |-- README.md
39
+ |-- TODO.md
40
+ |-- datasets
41
+ | |-- UniComplaints.csv
42
+ | |-- anscombe_quartet.csv
43
+ | |-- automobile.csv
44
+ | |-- breast-cancer.csv
45
+ | |-- iris.csv
46
+ | |-- titanic.csv
47
+ | |-- top_1000_popular_movies_tmdb.csv
48
+ | `-- ... (not used by the current notebooks, see TODO.md)
49
+ |-- notebooks
50
+ | |-- block1_introduction
51
+ | | |-- tutorial_1.ipynb
52
+ | | `-- project_1.ipynb
53
+ | |-- block2_visualisation
54
+ | | |-- tutorial_2.ipynb
55
+ | | `-- project_2.ipynb
56
+ | |-- block3_exploration_1
57
+ | | |-- tutorial_3.ipynb
58
+ | | `-- project_3.ipynb
59
+ | `-- block4_exploration_2
60
+ | |-- tutorial_4.ipynb
61
+ | `-- project_4.ipynb
62
+ |-- pyproject.toml
63
+ |-- requirements.txt
64
+ `-- src
65
+ `-- data_science_concepts (course package, see below)
66
+ ```
67
+
68
+ Images used in the notebooks are stored next to the notebooks and linked by their GitHub URL, because Colab does not resolve relative image paths.
69
+
70
+ ### Course package
71
+
72
+ Helper functions used in the notebooks (e.g. `plot_decision_boundary`) are in the `data-science-concepts` package in `src/data_science_concepts`. The notebooks install it with
73
+
74
+ ```python
75
+ %pip install -q "data-science-concepts==2026.*"
76
+ import data_science_concepts as dsc
77
+ ```
78
+
79
+ To release a new version, create a GitHub release with a tag of the form `vYEAR.MINOR.PATCH` (e.g. `v2026.0.1`). The `Package` workflow (`.github/workflows/package.yml`) builds the package and publishes it to [PyPI](https://pypi.org/project/data-science-concepts/); the version number is taken from the tag. Notebooks pin the course year, so a release for the next year (`v2027.0.0`) does not affect notebooks of the current year.
@@ -0,0 +1,7 @@
1
+ data_science_concepts/__init__.py,sha256=YmDZwG97UYvSuS-zTy166BMr26f5kHL_za7eh_G3ZzQ,347
2
+ data_science_concepts/decision_boundary.py,sha256=Q2BDFcHb2Ee2sU1sWIHVH-684xRdWHxvv_kGUBfFdUs,1288
3
+ data_science_concepts/pca_example.py,sha256=PN_WHpgvLPuW-Hy23HH-p3MhVOIMUcordpTQMF3isFU,3360
4
+ data_science_concepts-2026.0.0.dist-info/METADATA,sha256=tKM-FnU96O-RMIOaf0L_DqfHPEYfinr1XQaqiVNITEc,4940
5
+ data_science_concepts-2026.0.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
6
+ data_science_concepts-2026.0.0.dist-info/licenses/LICENSE,sha256=FofaOuRtJbvHY4QxuOEvcqg9S7aTER1dJhdlOtxHA_g,1075
7
+ data_science_concepts-2026.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WUR Bioinformatics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.