Skip to content

Commit 1aa4cca

Browse files
added documentation
1 parent 433958f commit 1aa4cca

28 files changed

+3918
-893
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
- simple_dataloaders
8+
permissions:
9+
contents: write
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Configure Git Credentials
16+
run: |
17+
git config user.name github-actions[bot]
18+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
23+
- uses: actions/cache@v4
24+
with:
25+
key: mkdocs-material-${{ env.cache_id }}
26+
path: .cache
27+
restore-keys: |
28+
mkdocs-material-
29+
- run: pip install mkdocs-material
30+
- run: pip install mkdocs-material-extensions
31+
- run: pip install mkdocs-jupyter
32+
- run: pip install mkdocs-redirects
33+
- run: pip install mkdocs-autorefs
34+
- run: pip install mkdocs-awesome-pages-plugin
35+
- run: pip install mkdocstrings
36+
- run: pip install mkdocstrings-python
37+
- run: pip install mknotebooks
38+
- run: mkdocs gh-deploy --force

README.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,58 @@ PyPi link https://pypi.org/project/openml-pytorch/
1111
#### Usage
1212
Import openML libraries
1313
```python
14-
import openml
15-
import openml_pytorch
16-
import openml_pytorch.layers
14+
import torch.nn
15+
import torch.optim
16+
1717
import openml_pytorch.config
18+
import openml
19+
import logging
20+
21+
from openml_pytorch.trainer import OpenMLTrainerModule
22+
from openml_pytorch.trainer import OpenMLDataModule
23+
from torchvision.transforms import Compose, Resize, ToPILImage, ToTensor, Lambda
24+
import torchvision
25+
from openml_pytorch.trainer import convert_to_rgb
1826

1927
```
20-
Create a torch model
28+
Create a pytorch model and get a task from openML
2129
```python
22-
model = torch.nn.Sequential(
23-
processing_net,
24-
features_net,
25-
results_net
30+
model = torchvision.models.efficientnet_b0(num_classes=200)
31+
# Download the OpenML task for tiniest imagenet
32+
task = openml.tasks.get_task(362127)
33+
```
34+
Download the task from openML and define Data and Trainer configuration
35+
```python
36+
transform = Compose(
37+
[
38+
ToPILImage(), # Convert tensor to PIL Image to ensure PIL Image operations can be applied.
39+
Lambda(
40+
convert_to_rgb
41+
), # Convert PIL Image to RGB if it's not already.
42+
Resize(
43+
(64, 64)
44+
), # Resize the image.
45+
ToTensor(), # Convert the PIL Image back to a tensor.
46+
]
47+
)
48+
data_module = OpenMLDataModule(
49+
type_of_data="image",
50+
file_dir="datasets",
51+
filename_col="image_path",
52+
target_mode="categorical",
53+
target_column="Class_encoded",
54+
batch_size = 64,
55+
transform=transform
56+
)
57+
trainer = OpenMLTrainerModule(
58+
data_module=data_module,
59+
verbose = True,
60+
epoch_count = 1,
2661
)
62+
openml_pytorch.config.trainer = trainer
2763
```
28-
Download the task from openML and run the model on task.
64+
Run the model on the task
2965
```python
30-
task = openml.tasks.get_task(3573)
3166
run = openml.runs.run_model_on_task(model, task, avoid_duplicate_runs=False)
3267
run.publish()
3368
print('URL for run: %s/run/%d' % (openml.config.server, run.run_id))

docs/API reference/Callbacks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Callbacks
2+
Callbacks module contains classes and functions for handling callback functions during an event-driven process. This makes it easier to customize the behavior of the training loop and add additional functionality to the training process without modifying the core code.
3+
4+
To use a callback, create a class that inherits from the Callback class and implement the necessary methods. Callbacks can be used to perform actions at different stages of the training process, such as at the beginning or end of an epoch, batch, or fitting process. Then pass the callback object to the Trainer.
5+
6+
::: callbacks

docs/API reference/Custom Datasets.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Custom Datasets
2+
This module contains custom dataset classes for handling image and tabular data from OpenML in PyTorch. To add support for new data types, new classes can be added to this module.
3+
4+
::: custom_datasets

docs/API reference/Metrics.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Metrics
2+
This module provides utility functions for evaluating model performance and activation functions.
3+
It includes functions to compute the accuracy, top-k accuracy of model predictions, and the sigmoid function.
4+
5+
::: metrics
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# OpenML Connection
2+
3+
This module defines the Pytorch wrapper for OpenML-python.
4+
5+
::: extension

docs/API reference/Trainer.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Trainer
2+
3+
This module provides classes and methods to facilitate the configuration, data handling, training, and evaluation of machine learning models using PyTorch and OpenML datasets. The functionalities include:
4+
- Generation of default configurations for models.
5+
- Handling of image and tabular data.
6+
- Training and evaluating machine learning models.
7+
- Exporting trained models to ONNX format.
8+
- Managing data transformations and loaders.
9+
10+
::: trainer

0 commit comments

Comments
 (0)