Galaxy-ML is a web machine learning end-to-end pipeline building framework, with special support to biomedical data. Under the management of unified scikit-learn APIs, cutting-edge machine learning libraries are combined together to provide thousands of different pipelines suitable for various needs. In the form of Galalxy tools, Galaxy-ML provides scalabe, reproducible and transparent machine learning computations.
- simple web UI
- no coding or minimum coding requirement
- fast model deployment and model selection, specialized in hyperparameter tuning using
GridSearchCV - high level of parallel and automated computation
A typic machine learning pipeline is composed of a main estimator/model and optional preprocessing component(s).
-
- sklearn.ensemble
- sklearn.linear_model
- sklearn.naive_bayes
- sklearn.neighbors
- sklearn.svm
- sklearn.tree
-
- XGBClassifier
- XGBRegressor
-
- StackingCVClassifier
- StackingClassifier
- StackingCVRegressor
- StackingRegressor
-
Keras (Deep learning models are re-implemented to fully support sklearn APIs. Supports parameter, including layer subparameter, swaps or searches. Supports
callbacks)- KerasGClassifier
- KerasGRegressor
- KerasGBatchClassifier (works best with online data generators, processing images, genomic sequences and so on)
-
BinarizeTargetClassifier/BinarizeTargetRegressor
- scikit-learn
- sklearn.preprocessing
- sklearn.feature_selection
- sklearn.decomposition
- sklearn.kernel_approximation
- sklearn.cluster
- imblanced-learn
- imblearn.under_sampling
- imblearn.over_sampling
- imblearn.combine
- skrebate
- ReliefF
- SURF
- SURFstar
- MultiSURF
- MultiSURFstar
- TDMScaler
- DyRFE/DyRFECV
- Z_RandomOverSampler
- GenomeOneHotEncoder
- ProteinOneHotEncoder
- FastaDNABatchGenerator
- FastaRNABatchGenerator
- FastaProteinBatchGenerator
- GenomicIntervalBatchGenerator
- GenomicVariantBatchGenerator
- ImageDataFrameBatchGenerator
This source version targets Python 3.12. Dependency versions are pinned in
requirements.txt.
Previously saved models may need to be retrained with the updated stack.
The Galaxy tool definitions target the 0.11.0 package and container. The local Dockerfile builds from this checkout.
APIs for models, preprocessors and utils implemented in Galaxy-ML can be installed separately.
The Bioconda build of Galaxy-ML 0.11.0 is available for Linux x86_64. With mamba installed, create and activate a new environment:
mamba create -n galaxy-ml \
--override-channels \
-c conda-forge \
-c bioconda \
--strict-channel-priority \
galaxy-ml=0.11.0
mamba activate galaxy-mlFor conda, replace mamba with conda in both commands.
Bioconda relies on dependencies from conda-forge, which must have higher
priority than bioconda. --override-channels uses only the channels listed
above, while --strict-channel-priority enforces their order. Specifying only
-c bioconda without a configured conda-forge channel can cause missing
dependency errors, such as an unavailable asteval package. See the
Bioconda channel setup guide.
pip install -U Galaxy-ML
python -m pip install .
python -m pip install -e .
To install Galaxy-ML tools in Galaxy, please refer to https://galaxyproject.org/admin/tools/add-tool-from-toolshed-tutorial/.
Maintainers: see Publishing to PyPI for release automation with Trusted Publishing.
GitHub Actions runs Python lint and API tests on pushes and pull requests. Galaxy tool lint and tests run separately for changed tools.
Before running the tests, run the following commands:
conda create --name galaxy_ml python=3.12
conda activate galaxy_ml
pip install -e .
pip install pytest pytest-html
cd galaxy_ml
To run all tests and generate an HTML report:
python -m pytest ./tests --html=./report.html
To run tests in a specific file (e.g., test_keras_galaxy.py file) and generate an HTML report
python -m pytest ./tests/test_keras_galaxy.py --html=./report.html
To run a specific test in a specific file (e.g., test_multi_dimensional_output test in test_keras_galaxy.py file) and generate an HTML report
python -m pytest ./tests/test_keras_galaxy.py::test_multi_dimensional_output --html=./report.html
# handle imports
from keras.models import Sequential
from keras.layers import Dense, Activation
from sklearn.model_selection import GridSearchCV
from galaxy_ml.keras_galaxy_models import KerasGClassifier
# build a DNN classifier
model = Sequential()
model.add(Dense(64))
model.add(Activation(‘relu'))
model.add((Dense(1, activation=‘sigmoid’)))
config = model.get_config()
classifier = KerasGClassifier(config, random_state=42)
# clone a classifier
clf = clone(classifier)
# Get parameters
params = clf.get_params()
# Set parameters
new_params = dict(
epochs=60,
lr=0.01,
layers_1_Dense__config__kernel_initializer__config__seed=999,
layers_0_Dense__config__kernel_initializer__config__seed=999
)
clf.set_params(**new_params)
# model evaluation using GridSearchCV
grid = GridSearchCV(clf, param_grid={}, scoring=‘roc_auc’, cv=5, n_jobs=2)
grid.fit(X, y)
from galaxy_ml.model_persist import (dump_model_to_h5,
load_model_from_h5)
# dump model to hdf5
dump_model_to_h5(model, `save_path`,
store_hyperparameter=True)
# load model from hdf5
model = load_model_from_h5(`path_to_hdf5`)
Galaxy-ML's HDF5 saving utils perform faster than cPickle for large, array-rich models.
Loading model using pickle...
(1.2471628189086914 s)
Dumping model using pickle...
(3.6942389011383057 s)
File size: 930712861
Dumping model to hdf5...
(3.006715774536133 s)
File size: 930729696
Loading model from hdf5...
(0.6420958042144775 s)
Pipeline(memory=None,
steps=[('robustscaler',
RobustScaler(copy=True, quantile_range=(25.0, 75.0),
with_centering=True, with_scaling=True)),
('kneighborsclassifier',
KNeighborsClassifier(algorithm='auto', leaf_size=30,
metric='minkowski', metric_params=None,
n_jobs=1, n_neighbors=100, p=2,
weights='uniform'))],
verbose=False)
Gu Q, Kumar A, Bray S, Creason A, Khanteymoori A, Jalili V, et al. (2021) Galaxy-ML: An accessible, reproducible, and scalable machine learning toolkit for biomedicine. PLoS Comput Biol 17(6): e1009014. https://doi.org/10.1371/journal.pcbi.1009014