qbiocode package#

QBioCode: Quantum Machine Learning for Biological Data Analysis#

QBioCode is a comprehensive Python package for quantum machine learning (QML) research and applications in biological data analysis. It provides tools for data generation, classical and quantum machine learning algorithms, evaluation metrics, and visualization utilities.

Main Modules#

  • learning: Classical and quantum machine learning algorithms

  • embeddings: Feature embedding and encoding methods

  • evaluation: Model, dataset and graph-complexity evaluation tools

  • data_generation: Synthetic dataset generators

  • visualization: Result visualization and correlation analysis

  • utils: Helper functions and utilities

  • apps: Command-line applications (QProfiler, QSage, QuVINE)

Quick Start#

>>> from qbiocode import compute_rf, generate_data
>>> # Generate synthetic data
>>> generate_data(type_of_data='circles', save_path='data/circles')
>>> # Train a random forest model
>>> results = compute_rf(X_train, y_train, X_test, y_test)
>>> # Use QProfiler programmatically
>>> from qbiocode.apps.qprofiler import qprofiler
>>> qprofiler.main(config)

Submodules:

Subpackages:

Summary#

__all__ Functions:

checkpoint_restart

Identify completed datasets from a previous run to enable checkpoint restart.

compute_dt

This function generates a model using a Decision Tree (DT) Classifier method as implemented in scikit-learn.

compute_dt_opt

This function also generates a model using a Decision Tree (DT) Classifier method as implemented in scikit-learn.

compute_lr

This function generates a model using a Logistic Regression (LR) method as implemented in scikit-learn.

compute_lr_opt

This function also generates a model using a Logistic Regression (LR) method as implemented in scikit-learn.

compute_mlp

This function generates a model using a Multi-layer Perceptron (mlp), a neural network, method as implemented in scikit-learn.

compute_mlp_opt

This function also generates a model using a Multi-layer Perceptron (mlp), a neural network, as implemented in scikit-learn (https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html).

compute_nb

This function generates a model using a Gaussian Naive Bayes (NB) Classifier method as implemented in scikit-learn.

compute_nb_opt

This function generates a model using a Gaussian Naive Bayes (NB) Classifier method as implemented in scikit-learn.

compute_pqk

This function generates quantum circuits, computes projections of the data onto these circuits, and evaluates the performance of classical machine learning models on the projected data.

compute_qnn

This function computes a Quantum Neural Network (QNN) model on the provided training data and evaluates it on the test data.

compute_qsvc

This function computes a quantum support vector classifier (QSVC) using the Qiskit Machine Learning library.

compute_results_correlation

This function takes in as input a Pandas Dataframe containing the results and data evaluations for a given dataset.

compute_rf

This function generates a model using a Random Forest (RF) Classifier method as implemented in scikit-learn.

compute_rf_opt

This function also generates a model using a Random Forest (RF) Classifier method as implemented in scikit-learn.

compute_svc

This function generates a model using a Support Vector Classifier (SVC) method as implemented in scikit-learn.

compute_svc_opt

This function generates a model using a Support Vector Classifier (SVC) method as implemented in scikit-learn.

compute_vqc

This function computes a Variational Quantum Classifier (VQC) using the Qiskit Machine Learning library.

compute_xgb

This function generates a model using an Extreme Gradient Boositing (xgb) Classifier method as implemented in xgboost.

compute_xgb_opt

This function generates a model using an Extreme Gradient Boositing (xgb) Classifier method as implemented in xgboost.

evaluate

This function evaluates a dataset and returns a transposed summary DataFrame with various statistical measures, derived from the dataset.

evaluate_graph

Summarize a graph’s complexity as a one-row DataFrame.

feature_encoding

Encode categorical features using various encoding strategies.

generate_circles_datasets

Generate multiple concentric circles datasets with varying parameters.

generate_classification_datasets

Generate multiple high-dimensional classification datasets with varying parameters.

generate_data

Generate synthetic datasets for machine learning benchmarking.

generate_moons_datasets

Generate multiple two-moons datasets with varying parameters.

generate_s_curve_datasets

Generate multiple 3D S-curve datasets with varying parameters.

generate_spheres_datasets

Generate multiple concentric n-dimensional spheres datasets with varying parameters.

generate_spirals_datasets

Generate multiple n-dimensional spiral datasets with varying parameters.

generate_swiss_roll_datasets

Generate multiple 3D Swiss roll datasets with varying parameters.

get_embeddings

Apply an embedding to the training and test datasets.

is_transductive

Return True if embedding is fit on the combined train and test rows.

model_run

This function runs the ML methods, with or without a grid search, as specified in the config.yaml file.

modeleval

Evaluates the model performance using accuracy, F1 score, and AUC.

plot_results_correlation

Plot publication-quality correlation figures from a correlations_df.

pqk

This function generates quantum circuits, computes projections of the data onto these circuits.

publication_style

Return a copy of PUBLICATION_STYLE for use as a matplotlib style.

qml_winner

This function finds data sets where QML was beneficial (higher F1 scores than CML) and create new .csv files with the relevant evaluation and performance for these specific datasets, for further analysis.

scale_train_test

Scale train and test with a single scaler fit on the training set only.

scaler_fn

Apply scaling transformation to input data.

tutorial_data_dirs

Return the directories tutorial_data_path() searches, in order.

tutorial_data_path

Return the absolute path of a tutorial fixture.

__all__ Data:

  • QUVINE_HEADLINE_METHODS

  • QUVINE_METHODS

  • SKLEARN_METHODS

Reference#