Skip to content

Commit

Permalink
Merge pull request #36 from EBjerrum/contribution
Browse files Browse the repository at this point in the history
Added a contribution file
  • Loading branch information
EBjerrum committed Sep 22, 2023
2 parents 6b77559 + 72252fb commit 83f0401
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 21 deletions.
59 changes: 59 additions & 0 deletions CONTRIBUTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Contribution

Thanks for your interest in contributing to the project. Please read on in the sections that apply.


## Slack channel
We have a slack channel for communication, ask for an invite: esbenbjerrum+scikit_mol@gmail.com


## Installation
Clone and install in editable more like this

git clone git@github.com:EBjerrum/scikit-mol.git
pip install -e .[dev]

If you get issues that the editable mode install needs a setup.py, you should update your pip

## Adding transformers
The projects transformers subclasses the BaseEstimator and Transformer mixin classes from sklearn. Their documentation page contains information on what requisites are necessary [https://scikit-learn.org/stable/developers/develop.html](https://scikit-learn.org/stable/developers/develop.html). Most notably:
* The arguments accepted by __init__ should all be keyword arguments with a default value.
* Every keyword argument accepted by __init__ should correspond to an attribute on the instance.
* * There should be no logic, not even input validation, and the parameters should not be changed.
Scikit-learn classes depends on this in order to for e.g. the .get_params(), .set_params(), cloning abilities and representation rendering to work.

### Tips
* We have observed that some external tools used "exotic" types such at np.int64 when doing hyperparameter tuning. It is thus necessary to cast to standard types before making calls to rdkit functions. This behaviour is tested in the test_parameter_types test

* @property getters and setters can be used if additional logic are needed when setting the attributes from the keywords while at the same time adhering to the sklearn requisites.

* Some RDKit features uses objects as generators which may not be picklable. If instantiated and added to the object as an attribute rather than instantiated at each function call for individual molecules, these should thus be removed and recreated via overloading the _get_state() and _set_state() methods. See MHFingerprintTransformer for an example.


## Module organisation
Currently we have multiple classes in the same file, if they are the same type. This may change in the future.

## Docstrings
We should ultimately consolidate on the NumPy docstring format [https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) which is also used by SciPy and other scikits.

## Typehints
parameters and output of methods should preferably be using typehints

## Testing
New transformer classes should be added to the pytest tests in the tests directory. A lot of tests are made general, and tests aspects of the transformers that are needed for sklearn compliance or other features. The transformer is then added to a fixture and can be added to the lists of transformer objects that are run by these test. Specific tests may also be necessary to set up. As exampe the assert_transformer_set_params needs a list of non-default parameters in order to set the set_params functionality of the object.

## Notebooks
Another way of contributing is by providing notebooks with examples on how to use the project to build models together with Scikit-Learn and other tools. There is both .ipynb and #%% delimited .py files in the notebook directory as the first are useful for online rendering on github, whereas the later is useful for sub version control.

There are three scripts for handling the notebooks and their associated python:percent scripts (with much nicer diff for git).

`pair_notebook.sh` create a pair of a notebook or percent:py script

`sync_notebooks.sh` uses jupytext to sync .py and ipynb. Jupytext is available via conda-forge or pip

`update_notebooks.sh` will sync, run and save the notebooks, expects a ipython kernel with scikit-mol installed called Python3.





14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ Bleeding edge

pip install git+https://github.com:EBjerrum/scikit-mol.git

Developers

git clone git@github.com:EBjerrum/scikit-mol.git
pip install -e .

## Documentation

There are a collection of notebooks in the notebooks directory which demonstrates some different aspects and use cases
Expand All @@ -75,17 +70,24 @@ There are a collection of notebooks in the notebooks directory which demonstrate
* [Sanitizing SMILES input](https://github.com/EBjerrum/scikit-mol/blob/main/notebooks/05_smiles_sanitaztion.ipynb)
* [Integrated hyperparameter tuning of Scikit-Learn estimator and Scikit-Mol transformer](https://github.com/EBjerrum/scikit-mol/blob/main/notebooks/06_hyperparameter_tuning.ipynb)
* [Using parallel execution to speed up descriptor and fingerprint calculations](https://github.com/EBjerrum/scikit-mol/blob/main/notebooks/07_parallel_transforms.ipynb)
* [Testing different fingerprints as part of the hyperparameter optimization](https://github.com/EBjerrum/scikit-mol/blob/main/notebooks/09_Combinatorial_Method_Usage_with_FingerPrint_Transformers.ipynb)

## Contributing

There are more information about how to contribute to the project in [CONTRIBUTION.md](https://github.com/EBjerrum/scikit-mol/CONTRIBUTION.md)

## BUGS
Probably still, please check issues at GitHub and report there

## Contributers:
* Esben Jannik Bjerrum [@ebjerrum](https://github.com/ebjerrum), esbenbjerrum+cheminformania@gmail.com
* Esben Jannik Bjerrum [@ebjerrum](https://github.com/ebjerrum), esbenbjerrum+scikit_mol@gmail.com
* Carmen Esposito [@cespos](https://github.com/cespos)
* Son Ha, sonha@uni-mainz.de
* Oh-hyeon Choung, ohhyeon.choung@gmail.com
* Andreas Poehlmann, [@ap--](https://github.com/ap--)
* Ya Chen, [@anya-chen](https://github.com/anya-chen)
* Rafał Bachorz [@rafalbachorz](https://github.com/rafalbachorz)
* Adrien Chaton [@adrienchaton](https://github.com/adrienchaton)
* @VincentAlexanderScholz
* @RiesBen

10 changes: 5 additions & 5 deletions notebooks/06_hyperparameter_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

# %%

mol_list_train, mol_list_test, y_train, y_test = train_test_split(data.ROMol, data.pXC50, random_state=0)
mol_list_train, mol_list_test, y_train, y_test = train_test_split(data.ROMol, data.pXC50, random_state=42)


# %% [markdown]
Expand Down Expand Up @@ -111,10 +111,10 @@
# %%

param_dist = {'ridge__alpha': loguniform(1e-2, 1e3),
"morgantransformer__nBits": [256,512,1024,2048,4096],
'morgantransformer__radius':[1,2,3,4],
'morgantransformer__useCounts': [True,False],
'morgantransformer__useFeatures':[True,False]}
"morganfingerprinttransformer__nBits": [256,512,1024,2048,4096],
'morganfingerprinttransformer__radius':[1,2,3,4],
'morganfingerprinttransformer__useCounts': [True,False],
'morganfingerprinttransformer__useFeatures':[True,False]}

# %% [markdown]
# The report function was taken from [this example](https://scikit-learn.org/stable/auto_examples/model_selection/plot_randomized_search.html#sphx-glr-auto-examples-model-selection-plot-randomized-search-py) from the scikit learn documentation.
Expand Down
11 changes: 1 addition & 10 deletions notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,4 @@ This is a collection of notebooks in the notebooks directory which demonstrates
* [Sanitizing SMILES input](https://github.com/EBjerrum/scikit-mol/tree/main/notebooks/05_smiles_sanitaztion.ipynb)
* [Integrated hyperparameter tuning of Scikit-Learn estimator and Scikit-Mol transformer](https://github.com/EBjerrum/scikit-mol/tree/main/notebooks/06_hyperparameter_tuning.ipynb)
* [Using parallel execution to speed up descriptor and fingerprint calculations](https://github.com/EBjerrum/scikit-mol/tree/main/notebooks/07_parallel_transforms.ipynb)


## Developers
There are three scripts for handling the notebooks and their associated python:percent scripts (with much nicer diff for git)

`pair_notebook.sh` create a pair of a notebook or percent:py script

`sync_notebooks.sh` uses jupytext to sync .py and ipynb. Jupytext is available via conda-forge or pip

`update_notebooks.sh` will sync, run and save the notebooks, expects a ipython kernel with scikit-mol installed called Python3.
* [Testing different fingerprints as part of the hyperparameter optimization](https://github.com/EBjerrum/scikit-mol/blob/main/notebooks/09_Combinatorial_Method_Usage_with_FingerPrint_Transformers.ipynb)
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ exclude =
dev =
pytest>=6
pytest-cov
jupytext

0 comments on commit 83f0401

Please sign in to comment.