sklearn-embeddings
Overview
sklearn-embeddings is a Python package that integrates sentence-transformer based embeddings with scikit-learn classifiers and clustering algorithms. This allows users to leverage powerful natural language processing capabilities within the familiar scikit-learn framework.
Installation
To install sklearn-embeddings, you can use pip:
pip install sklearn-embeddings
Usage
Here is a simple example of how to use sklearn-embeddings with a scikit-learn classifier:
import joblib
from sklearn_embeddings import SentenceTransformerEmbedding
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline
# Sample data
documents = ["The food was great.", "Not expensive and good service", "Not worth the money", "I've had better"]
# Labels
is_positive = [True, True, False, False]
# Create a pipeline with the embedding model and a classifier
pipeline = make_pipeline(
SentenceTransformerEmbedding(),
# SentenceTransformerEmbedding('paraphrase-MiniLM-L6-v2'),
# SentenceTransformerEmbedding('/my/local/folder/paraphrase-MiniLM-L6-v2'),
# SentenceTransformerEmbedding(SentenceTransformer('paraphrase-MiniLM-L6-v2')),
LogisticRegression()
)
# Fit the model
pipeline.fit(documents, is_positive)
# Make predictions
predictions = pipeline.predict(["So delicious!", "Not for me"])
# Write the whole pipeline to disk
joblib.dump(pipeline, 'model.joblib')
Perhaps the greatest benefit of this library is that it allows you to use Scikit-learn pipelines to combine encoding and labeling in a single function call.
import joblib
model = joblib.load('model.joblib')
# Use the loaded pipeline as a simple model, it takes care of sentence-transformer encoding for you!
model.predict(["This is a sentence"])
Metadata
Release files for sklearn-embeddings 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sklearn_embeddings-0.1.3.tar.gz | 4.1 kB | Without provenance | Details for sklearn_embeddings-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sklearn_embeddings-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for sklearn_embeddings-0.1.3-py3-none-any.whl |
Total release size: 8.0 kB
Release files / sklearn_embeddings-0.1.3.tar.gz
| Download URL | sklearn_embeddings-0.1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
387573b43a9e22c90029d9b592316783e61955d70ea4d1792672d21f478575c7
|
|
BLAKE2b-256 checksum How to use checksums |
5da90b9d86fd71e38b875bc46dc080f1799366f1f01f699bad257c2b69d1424d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / sklearn_embeddings-0.1.3-py3-none-any.whl
| Download URL | sklearn_embeddings-0.1.3-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f530174ad1e000915416c5084077ee1336c2be4054cc2195a2bc1bf30ed64ce
|
|
BLAKE2b-256 checksum How to use checksums |
3fcbf9d2aa65624fb2d3d6131a536aa24a0f8f2616a641370563ee708f42cee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for sklearn-embeddings 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.