Skip to content

Commit d536c76

Browse files
committed
quarto
1 parent 532650e commit d536c76

File tree

8 files changed

+161
-2
lines changed

8 files changed

+161
-2
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
22
"features": {
3+
"ghcr.io/rocker-org/devcontainer-features/quarto-cli":
4+
{"installChromium": true, "installTinyTex": true},
5+
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1":
6+
{"packages": "ca-certificates,fonts-liberation,libasound2,libatk-bridge2.0-0,libatk1.0-0,libc6,libcairo2,libcups2,libdbus-1-3,libexpat1,libfontconfig1,libgbm1,libgcc1,libglib2.0-0,libgtk-3-0,libnspr4,libnss3,libpango-1.0-0,libpangocairo-1.0-0,libstdc++6,libx11-6,libx11-xcb1,libxcb1,libxcomposite1,libxcursor1,libxdamage1,libxext6,libxfixes3,libxi6,libxrandr2,libxrender1,libxss1,libxtst6,lsb-release,wget,xdg-utils"},
37
"ghcr.io/rocker-org/devcontainer-features/miniforge:2": {}
48
},
59
"postCreateCommand": "conda env create --file environment.yml"

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
workflow_dispatch:
3+
4+
name: Quarto Publish
5+
6+
jobs:
7+
build-deploy:
8+
runs-on: ubuntu-latest
9+
defaults:
10+
run:
11+
shell: bash -el {0}
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v3
17+
- name: Set up Quarto
18+
uses: quarto-dev/quarto-actions/setup@v2
19+
with:
20+
tinytex: true
21+
# version: "pre-release"
22+
- name: Set up Python
23+
uses: conda-incubator/setup-miniconda@v3
24+
with:
25+
activate-environment: test
26+
auto-update-conda: true
27+
python-version: "3.10"
28+
channels: conda-forge
29+
allow-softlinks: true
30+
channel-priority: flexible
31+
show-channel-urls: true
32+
- name: Install dependencies
33+
run: |
34+
conda install --yes -c numpy scipy scikit-learn statsmodels pandas seaborn jupyter tabulate
35+
- name: Render and Publish
36+
run: |
37+
git config --global user.email "mgraffg@ieee.org"
38+
git config --global user.name "mgraffg"
39+
cd quarto
40+
quarto publish gh-pages CompStats.qmd --no-browser
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,4 @@ cython_debug/
160160
#.idea/
161161

162162
.vscode/settings.json
163+
quarto/CompStats_files/

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"ms-toolsai.jupyter",
88
"ms-python.vscode-pylance",
99
"ms-python.python",
10-
"ms-python.pylint"
10+
"ms-python.pylint",
11+
"quarto.quarto"
1112
],
1213
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
1314
"unwantedRecommendations": [

environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ dependencies:
99
- pytest
1010
- tqdm
1111
- sphinx
12+
- yaml
13+
- jupyter
1214
- pip:
1315
- pandas
1416
- seaborn

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ dependencies = [
66
'numpy',
77
'scikit-learn>=1.3.0',
88
'pandas',
9-
'seaborn>=0.13.0'
9+
'seaborn>=0.13.0',
10+
'statsmodels'
1011
]
1112
dynamic = ['version']
1213

@@ -26,6 +27,9 @@ classifiers = [
2627
[tool.setuptools.dynamic]
2728
version = {attr = 'CompStats.__version__'}
2829

30+
[tool.setuptools]
31+
packages = ['CompStats', 'CompStats.tests']
32+
2933
[project.urls]
3034
Homepage = "https://compstats.readthedocs.io"
3135
Repository = "https://github.com/INGEOTEC/CompStats"

quarto/CompStats.qmd

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: "CompStats"
3+
format:
4+
dashboard:
5+
logo: images/ingeotec.png
6+
orientation: columns
7+
nav-buttons: [github]
8+
theme: cosmo
9+
execute:
10+
freeze: auto
11+
---
12+
13+
# Introduction
14+
15+
## Column
16+
17+
::: {.card title='Introduction'}
18+
Collaborative competitions have gained popularity in the scientific and technological fields. These competitions involve defining tasks, selecting evaluation scores, and devising result verification methods. In the standard scenario, participants receive a training set and are expected to provide a solution for a held-out dataset kept by organizers. An essential challenge for organizers arises when comparing algorithms' performance, assessing multiple participants, and ranking them. Statistical tools are often used for this purpose; however, traditional statistical methods often fail to capture decisive differences between systems' performance. CompStats implements an evaluation methodology for statistically analyzing competition results and competition. CompStats offers several advantages, including off-the-shell comparisons with correction mechanisms and the inclusion of confidence intervals.
19+
:::
20+
21+
::: {.card title='Installing using conda'}
22+
23+
`CompStats` can be install using the conda package manager with the following instruction.
24+
25+
```{sh}
26+
conda install --channel conda-forge CompStats
27+
```
28+
:::
29+
30+
::: {.card title='Installing using pip'}
31+
A more general approach to installing `CompStats` is through the use of the command pip, as illustrated in the following instruction.
32+
33+
```{sh}
34+
pip install CompStats
35+
```
36+
:::
37+
38+
# Quick Start Guide
39+
40+
## Column
41+
42+
To illustrate the use of `CompStats`, the following snippets show an example. The instructions load the necessary libraries, including the one to obtain the problem (e.g., digits), four different classifiers, and the last line is the score used to measure the performance and compare the algorithm.
43+
44+
```{python}
45+
#| echo: true
46+
47+
from sklearn.svm import LinearSVC
48+
from sklearn.naive_bayes import GaussianNB
49+
from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
50+
from sklearn.datasets import load_digits
51+
from sklearn.model_selection import train_test_split
52+
from sklearn.base import clone
53+
from CompStats.metrics import f1_score
54+
```
55+
56+
The first step is to load the digits problem and split the dataset into training and validation sets. The second step is to estimate the parameters of a linear Support Vector Machine and predict the validation set's classes. The predictions are stored in the variable `hy`.
57+
58+
```{python}
59+
#| echo: true
60+
61+
X, y = load_digits(return_X_y=True)
62+
_ = train_test_split(X, y, test_size=0.3)
63+
X_train, X_val, y_train, y_val = _
64+
m = LinearSVC().fit(X_train, y_train)
65+
hy = m.predict(X_val)
66+
```
67+
68+
## Column
69+
70+
Once the predictions are available, it is time to measure the algorithm's performance, as seen in the following code. It is essential to note that the API used in `sklearn.metrics` is followed; the difference is that the function returns an instance with different methods that can be used to estimate different performance statistics and compare algorithms.
71+
72+
```{python}
73+
#| echo: true
74+
75+
score = f1_score(y_val, hy, average='macro')
76+
score
77+
```
78+
79+
The previous code shows the macro-f1 score and its standard error. The actual performance value is stored in the attributes `statistic` function, and `se`
80+
81+
```{python}
82+
#| echo: true
83+
84+
score.statistic, score.se
85+
```
86+
87+
Continuing with the example, let us assume that one wants to test another classifier on the same problem, in this case, a random forest, as can be seen in the following two lines. The second line predicts the validation set and sets it to the analysis.
88+
89+
```{python}
90+
#| echo: true
91+
92+
ens = RandomForestClassifier().fit(X_train, y_train)
93+
score(ens.predict(X_val), name='Random Forest')
94+
```
95+
96+
Let us incorporate another predictions, now with Naive Bayes classifier, and Histogram Gradient Boosting as seen below.
97+
98+
```{python}
99+
#| echo: true
100+
101+
nb = GaussianNB().fit(X_train, y_train)
102+
score(nb.predict(X_val), name='Naive Bayes')
103+
hist = HistGradientBoostingClassifier().fit(X_train, y_train)
104+
score(hist.predict(X_val), name='Hist. Grad. Boost. Tree')
105+
```

quarto/images/ingeotec.png

34 KB
Loading

0 commit comments

Comments
 (0)