Skip to content

Add a scikit-activeml wrapper for pytorch - #403

Merged
tpham93 merged 57 commits into
scikit-activeml:skorch_wrapperfrom
Cheng-JY:Cheng/feat/classifier
Jun 24, 2025
Merged

tpham93 merged 57 commits into
scikit-activeml:skorch_wrapperfrom
Cheng-JY:Cheng/feat/classifier

Conversation

@Cheng-JY

@Cheng-JY Cheng-JY commented Jun 8, 2024

Copy link
Copy Markdown
Contributor

Description

  1. Add a scikit-activeml wrapper for pytorch
  2. Add a multi-annotator classifier "CrowdLayerClassifier" from Rodrigues and Pereira (2017)

Features

  1. Add a scikit-activeml wrapper for pytorch
  2. Add a multi-annotator classifier "CrowdLayerClassifier"
  3. Add the corresponding test

Side Notes

  1. The Tests work for me right now. Bug with Exit Code is fixed with the new environment.
  2. Add a flag for the function predict_prob

@Cheng-JY
Cheng-JY changed the base branch from master to development June 18, 2024 19:29
Comment thread README.rst Outdated
:target: https://app.codecov.io/gh/scikit-activeml/scikit-activeml

.. |PythonVersion| image:: https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove changes from README.

Comment thread requirements.txt
matplotlib>=3.7.3
iteration-utilities>=0.12.0
makefun>=1.15.3 No newline at end of file
makefun>=1.15.3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove changes from requirements.

Comment thread skactiveml/classifier/_wrapper.py Outdated

Implementation of a wrapper class for scikit-learn classifiers such that
missing labels can be handled. Therefor, samples with missing labels are
missing labels can be handled. Therefore, samples with missing labels are

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Therefore" was correct and means "Hierfür".

Comment thread skactiveml/classifier/_wrapper.py Outdated
Implement a wrapper class, to make it possible to use `PyTorch` with
`skactiveml`. This is achieved by providing a wrapper around `PyTorch`
that has a skactiveml interface and also be able to handle missing labels.
This wrapper is based on the open-source library `skorch` [1].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This wrapper is based on the open-source library `skorch` [1].
This wrapper is based on the open-source library `skorch` [1]_.

Comment thread skactiveml/classifier/_wrapper.py Outdated
Comment on lines +736 to +738
criterion : torch criterion (class), default: nn.NLLoss()
The uninitialized criterion (loss) used to optimize the
module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
criterion : torch criterion (class), default: nn.NLLoss()
The uninitialized criterion (loss) used to optimize the
module.
criterion : nn.Module.__class__, default=nn.NLLoss
The uninitialized criterion (loss) used to optimize the module. \
By default, `nn.NLLoss` is used as criterion.

"y_pred": y_pred,
}

def predict_P_annot(self, X):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def predict_P_annot(self, X):
def predict_proba_annot(self, X):


Parameters
----------
X : matrix-like, shape (n_samples, n_features)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
X : matrix-like, shape (n_samples, n_features)
X : matrix-like of shape (n_samples, n_features)


class CrowdLayerModule(nn.Module):
"""
CrowdLayerModule

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CrowdLayerModule
Crowd Layer Module

"""
CrowdLayerModule

CrowdLayer [1] is a layer added at the end of a classifying neural network

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CrowdLayer [1] is a layer added at the end of a classifying neural network
Crowd Layer [1]_ is a layer added at the end of a classifying neural network

Comment on lines +248 to +249
[1] Rodrigues, Filipe, and Francisco Pereira. "Deep learning from crowds." In Proceedings
of the AAAI conference on artificial intelligence, vol. 32, no. 1. 2018.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[1] Rodrigues, Filipe, and Francisco Pereira. "Deep learning from crowds." In Proceedings
of the AAAI conference on artificial intelligence, vol. 32, no. 1. 2018.
.. [1] Rodrigues, Filipe, and Francisco Pereira. "Deep learning from crowds." AAAI
Conference on Artificial Intelligence, 2018.

@tpham93
tpham93 changed the base branch from development to skorch_wrapper June 24, 2025 11:55
@tpham93
tpham93 merged commit 40b0ef2 into scikit-activeml:skorch_wrapper Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants