# QuantGaussVector
**QuantGaussVector** is a Python library designed for advanced Gaussian Process Regression (GPR) and Classification with integrated quantization and vectorization techniques. This library includes models optimized for parallel processing, making it suitable for high-performance machine learning tasks.
## Table of Contents
1. [Overview](#overview)
2. [Theoretical Background](#theoretical-background)
- [Gaussian Process Regression (GPR)](#gaussian-process-regression-gpr)
- [Quantization](#quantization)
- [Vectorization](#vectorization)
- [Parallel Processing](#parallel-processing)
3. [Installation](#installation)
4. [Usage](#usage)
- [QGVR Model](#qgvr-model)
- [QVGC Model](#qvgc-model)
- [Parameters](#parameters)
5. [Examples](#examples)
- [Regression with QGVR](#regression-with-qgvr)
- [Classification with QVGC](#classification-with-qvgc)
6. [API Reference](#api-reference)
7. [License](#license)
## Overview
**QuantGaussVector** offers two main models:
1. **QGVR (Quantized Gaussian Vector Regression)**: A regression model based on Gaussian Processes that incorporates quantization and vectorization techniques for enhanced performance.
2. **QVGC (Quantized Vector Gaussian Classification)**: A classification model that leverages Gaussian Processes for probabilistic predictions, incorporating quantization and vectorization.
These models are designed to handle large datasets efficiently, utilizing parallel processing to accelerate computation.
## Theoretical Background
### Gaussian Process Regression (GPR)
Gaussian Process Regression (GPR) is a non-parametric, Bayesian approach to regression that models the distribution over functions. It is particularly useful for making predictions with uncertainty estimates. The core idea is to place a Gaussian Process prior over the function to be predicted, and use observed data to update this prior.
### Quantization
Quantization in machine learning involves reducing the precision of the numbers used to represent data. This technique can reduce memory usage and computational cost, especially when working with large datasets. In **QuantGaussVector**, quantization is applied dynamically, with options for min-max scaling to fit data into a lower precision range.
### Vectorization
Vectorization is a method of optimizing computations by replacing explicit loops with array operations. This is particularly powerful in Python, where operations on NumPy arrays can be executed in C, leading to significant performance improvements. Both **QGVR** and **QVGC** models are fully vectorized to maximize efficiency.
### Parallel Processing
Parallel processing divides tasks into smaller subtasks that can be processed simultaneously on multiple cores. In **QuantGaussVector**, the `joblib` library is used to parallelize the sampling and prediction steps, enabling the models to handle large datasets more efficiently.
## Installation
You can install **QuantGaussVector** using pip:
```bash
pip install QuantGaussVector
```
### Alternatively, you can clone the repository and install the package manually:
```bash
git clone https://github.com/MM21B038/QuantGaussVector.git
cd QuantGaussVector
pip install .
```
## Usage
### QGVR Model
#### The QGVR model is used for regression tasks. Here's how you can use it:
```bash
from QuantGaussVector import QGVR
# Initialize the model
model = QGVR(kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)
# Fit the model on training data
model.fit(X_train, y_train)
# Make predictions
y_mean, y_cov = model.predict(X_test)
```
### QVGC Model
#### The QVGC model is used for classification tasks. Here's how you can use it:
```bash
from QuantGaussVector import QVGC
# Initialize the classifier
classifier = QVGC(kernel='linear', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)
# Fit the model on training data
classifier.fit(X_train, y_train)
# Predict probabilities
probabilities, variances = classifier.predict_proba(X_test)
# Predict class labels
predictions = classifier.predict(X_test)
```
## Parameters
- `kernel`: Type of kernel to use ('rbf' or 'linear').
- `length_scale`: Length scale for the kernel.
- `sigma_f`: Signal variance.
- `sigma_n`: Noise variance.
- `alpha`: Regularization parameter.
- `n_jobs`: Number of parallel jobs.
- `dtype`: Data type for computation.
- `quantize`: Whether to enable dynamic range quantization.
## Examples
### Regression with QGVR
```bash
import numpy as np
from QuantGaussVector import QGVR
# Example dataset
X_train = np.random.rand(100, 3)
y_train = np.sin(X_train[:, 0]) + np.cos(X_train[:, 1])
X_test = np.random.rand(20, 3)
# Initialize and fit model
model = QGVR(kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)
model.fit(X_train, y_train)
# Predict
y_mean, y_cov = model.predict(X_test)
print("Predicted mean:", y_mean)
print("Predicted covariance:", y_cov)
```
### Classification with QVGC
```bash
import numpy as np
from QuantGaussVector import QVGC
# Example dataset
X_train = np.random.rand(100, 3)
y_train = (X_train[:, 0] + X_train[:, 1] > 1).astype(int)
X_test = np.random.rand(20, 3)
# Initialize and fit classifier
classifier = QVGC(kernel='linear', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)
classifier.fit(X_train, y_train)
# Predict probabilities and classes
probabilities, variances = classifier.predict_proba(X_test)
predictions = classifier.predict(X_test)
print("Predicted probabilities:", probabilities)
print("Predicted classes:", predictions)
```
## API Reference
### QGVR
- __init__(self, kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, alpha=1e-10, n_jobs=1, dtype=np.float64, quantize=False): Initializes the QGVR model.
- fit(self, X_train, y_train): Fits the model to the training data.
- predict(self, X_test): Predicts the mean and covariance for the test data.
- sample_y(self, X_test, n_samples=3): Generates samples from the posterior distribution.
- log_marginal_likelihood(self): Computes the log marginal likelihood.
- get_params(self): Returns the model parameters.
- set_params(self, **params): Sets the model parameters.
- score(self, X_test, y_true): Computes the mean squared error of the predictions.
### QVGC
- __init__(self, kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, alpha=1e-10, n_jobs=1, dtype=np.float64, quantize=False): Initializes the QVGC classifier.
- fit(self, X_train, y_train): Fits the classifier to the training data.
- predict_proba(self, X_test): Predicts the probabilities and variances for the test data.
- predict(self, X_test): Predicts the class labels for the test data.
- log_marginal_likelihood(self): Computes the log marginal likelihood.
- get_params(self): Returns the classifier parameters.
- set_params(self, **params): Sets the classifier parameters.
- score(self, X_test, y_test): Computes the accuracy of the predictions.
- decision_function(self, X_test): Computes the decision function for the test data.
## License
This project is licensed under the MIT License. See the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/MM21B038/QuantGaussVector",
"name": "QuantGaussVector",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Manav Gupta",
"author_email": "manav26102002@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/42/65/808894fd4a71da264f98e8215d2c02053d6338af3cbdf9382fc3624c52af/quantgaussvector-1.0.0.tar.gz",
"platform": null,
"description": "# QuantGaussVector\r\n\r\n**QuantGaussVector** is a Python library designed for advanced Gaussian Process Regression (GPR) and Classification with integrated quantization and vectorization techniques. This library includes models optimized for parallel processing, making it suitable for high-performance machine learning tasks.\r\n\r\n## Table of Contents\r\n\r\n1. [Overview](#overview)\r\n2. [Theoretical Background](#theoretical-background)\r\n - [Gaussian Process Regression (GPR)](#gaussian-process-regression-gpr)\r\n - [Quantization](#quantization)\r\n - [Vectorization](#vectorization)\r\n - [Parallel Processing](#parallel-processing)\r\n3. [Installation](#installation)\r\n4. [Usage](#usage)\r\n - [QGVR Model](#qgvr-model)\r\n - [QVGC Model](#qvgc-model)\r\n - [Parameters](#parameters)\r\n5. [Examples](#examples)\r\n - [Regression with QGVR](#regression-with-qgvr)\r\n - [Classification with QVGC](#classification-with-qvgc)\r\n6. [API Reference](#api-reference)\r\n7. [License](#license)\r\n\r\n## Overview\r\n\r\n**QuantGaussVector** offers two main models:\r\n\r\n1. **QGVR (Quantized Gaussian Vector Regression)**: A regression model based on Gaussian Processes that incorporates quantization and vectorization techniques for enhanced performance.\r\n2. **QVGC (Quantized Vector Gaussian Classification)**: A classification model that leverages Gaussian Processes for probabilistic predictions, incorporating quantization and vectorization.\r\n\r\nThese models are designed to handle large datasets efficiently, utilizing parallel processing to accelerate computation.\r\n\r\n## Theoretical Background\r\n\r\n### Gaussian Process Regression (GPR)\r\n\r\nGaussian Process Regression (GPR) is a non-parametric, Bayesian approach to regression that models the distribution over functions. It is particularly useful for making predictions with uncertainty estimates. The core idea is to place a Gaussian Process prior over the function to be predicted, and use observed data to update this prior.\r\n\r\n### Quantization\r\n\r\nQuantization in machine learning involves reducing the precision of the numbers used to represent data. This technique can reduce memory usage and computational cost, especially when working with large datasets. In **QuantGaussVector**, quantization is applied dynamically, with options for min-max scaling to fit data into a lower precision range.\r\n\r\n### Vectorization\r\n\r\nVectorization is a method of optimizing computations by replacing explicit loops with array operations. This is particularly powerful in Python, where operations on NumPy arrays can be executed in C, leading to significant performance improvements. Both **QGVR** and **QVGC** models are fully vectorized to maximize efficiency.\r\n\r\n### Parallel Processing\r\n\r\nParallel processing divides tasks into smaller subtasks that can be processed simultaneously on multiple cores. In **QuantGaussVector**, the `joblib` library is used to parallelize the sampling and prediction steps, enabling the models to handle large datasets more efficiently.\r\n\r\n## Installation\r\n\r\nYou can install **QuantGaussVector** using pip:\r\n\r\n```bash\r\npip install QuantGaussVector\r\n```\r\n### Alternatively, you can clone the repository and install the package manually:\r\n```bash\r\ngit clone https://github.com/MM21B038/QuantGaussVector.git\r\ncd QuantGaussVector\r\npip install .\r\n```\r\n\r\n## Usage\r\n\r\n### QGVR Model\r\n#### The QGVR model is used for regression tasks. Here's how you can use it:\r\n```bash\r\nfrom QuantGaussVector import QGVR\r\n\r\n# Initialize the model\r\nmodel = QGVR(kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)\r\n\r\n# Fit the model on training data\r\nmodel.fit(X_train, y_train)\r\n\r\n# Make predictions\r\ny_mean, y_cov = model.predict(X_test)\r\n```\r\n\r\n### QVGC Model\r\n#### The QVGC model is used for classification tasks. Here's how you can use it:\r\n```bash\r\nfrom QuantGaussVector import QVGC\r\n\r\n# Initialize the classifier\r\nclassifier = QVGC(kernel='linear', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)\r\n\r\n# Fit the model on training data\r\nclassifier.fit(X_train, y_train)\r\n\r\n# Predict probabilities\r\nprobabilities, variances = classifier.predict_proba(X_test)\r\n\r\n# Predict class labels\r\npredictions = classifier.predict(X_test)\r\n```\r\n\r\n## Parameters\r\n- `kernel`: Type of kernel to use ('rbf' or 'linear').\r\n- `length_scale`: Length scale for the kernel.\r\n- `sigma_f`: Signal variance.\r\n- `sigma_n`: Noise variance.\r\n- `alpha`: Regularization parameter.\r\n- `n_jobs`: Number of parallel jobs.\r\n- `dtype`: Data type for computation.\r\n- `quantize`: Whether to enable dynamic range quantization.\r\n\r\n## Examples\r\n\r\n### Regression with QGVR\r\n```bash\r\nimport numpy as np\r\nfrom QuantGaussVector import QGVR\r\n\r\n# Example dataset\r\nX_train = np.random.rand(100, 3)\r\ny_train = np.sin(X_train[:, 0]) + np.cos(X_train[:, 1])\r\n\r\nX_test = np.random.rand(20, 3)\r\n\r\n# Initialize and fit model\r\nmodel = QGVR(kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)\r\nmodel.fit(X_train, y_train)\r\n\r\n# Predict\r\ny_mean, y_cov = model.predict(X_test)\r\nprint(\"Predicted mean:\", y_mean)\r\nprint(\"Predicted covariance:\", y_cov)\r\n```\r\n\r\n### Classification with QVGC\r\n```bash\r\nimport numpy as np\r\nfrom QuantGaussVector import QVGC\r\n\r\n# Example dataset\r\nX_train = np.random.rand(100, 3)\r\ny_train = (X_train[:, 0] + X_train[:, 1] > 1).astype(int)\r\n\r\nX_test = np.random.rand(20, 3)\r\n\r\n# Initialize and fit classifier\r\nclassifier = QVGC(kernel='linear', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, quantize=True)\r\nclassifier.fit(X_train, y_train)\r\n\r\n# Predict probabilities and classes\r\nprobabilities, variances = classifier.predict_proba(X_test)\r\npredictions = classifier.predict(X_test)\r\nprint(\"Predicted probabilities:\", probabilities)\r\nprint(\"Predicted classes:\", predictions)\r\n```\r\n\r\n## API Reference\r\n\r\n### QGVR\r\n- __init__(self, kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, alpha=1e-10, n_jobs=1, dtype=np.float64, quantize=False): Initializes the QGVR model.\r\n- fit(self, X_train, y_train): Fits the model to the training data.\r\n- predict(self, X_test): Predicts the mean and covariance for the test data.\r\n- sample_y(self, X_test, n_samples=3): Generates samples from the posterior distribution.\r\n- log_marginal_likelihood(self): Computes the log marginal likelihood.\r\n- get_params(self): Returns the model parameters.\r\n- set_params(self, **params): Sets the model parameters.\r\n- score(self, X_test, y_true): Computes the mean squared error of the predictions.\r\n\r\n### QVGC\r\n- __init__(self, kernel='rbf', length_scale=1.0, sigma_f=1.0, sigma_n=0.1, alpha=1e-10, n_jobs=1, dtype=np.float64, quantize=False): Initializes the QVGC classifier.\r\n- fit(self, X_train, y_train): Fits the classifier to the training data.\r\n- predict_proba(self, X_test): Predicts the probabilities and variances for the test data.\r\n- predict(self, X_test): Predicts the class labels for the test data.\r\n- log_marginal_likelihood(self): Computes the log marginal likelihood.\r\n- get_params(self): Returns the classifier parameters.\r\n- set_params(self, **params): Sets the classifier parameters.\r\n- score(self, X_test, y_test): Computes the accuracy of the predictions.\r\n- decision_function(self, X_test): Computes the decision function for the test data.\r\n\r\n## License\r\nThis project is licensed under the MIT License. See the LICENSE file for details.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A deep learning library for Gaussian Process Regression with quantization and vectorization.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/MM21B038/QuantGaussVector"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2a318aa4e560017c975af0b2f4c25d250b9fd1acd82abafe44cb37e7a8a21c88",
"md5": "3411fee6bfe2ae95579287db504e1f67",
"sha256": "e5bbf38ee41f8129f84da5052695051711354f670bc805f7efebaac1c2d00073"
},
"downloads": -1,
"filename": "QuantGaussVector-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3411fee6bfe2ae95579287db504e1f67",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7682,
"upload_time": "2024-08-19T04:27:02",
"upload_time_iso_8601": "2024-08-19T04:27:02.277425Z",
"url": "https://files.pythonhosted.org/packages/2a/31/8aa4e560017c975af0b2f4c25d250b9fd1acd82abafe44cb37e7a8a21c88/QuantGaussVector-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4265808894fd4a71da264f98e8215d2c02053d6338af3cbdf9382fc3624c52af",
"md5": "7727b32dd833688d6a6b534e057f3ab7",
"sha256": "185aa989c01b873f5e7df1474a0c341ab6ca5bb6f59e9b3073e19dccacec9371"
},
"downloads": -1,
"filename": "quantgaussvector-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "7727b32dd833688d6a6b534e057f3ab7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 6140,
"upload_time": "2024-08-19T04:27:04",
"upload_time_iso_8601": "2024-08-19T04:27:04.145889Z",
"url": "https://files.pythonhosted.org/packages/42/65/808894fd4a71da264f98e8215d2c02053d6338af3cbdf9382fc3624c52af/quantgaussvector-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-19 04:27:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MM21B038",
"github_project": "QuantGaussVector",
"github_not_found": true,
"lcname": "quantgaussvector"
}