TFIDFVectorizer
TFIDFVectorizer is a custom implementation of the TF-IDF transformation algorithm, using scikit-learn's TfidfVectorizer as a base. The implementation is written in Python, making use of numpy, scikit-learn and other commonly used packages.
The main aim of this implementation is to provide a simple and efficient way of transforming a collection of text documents into a matrix representation, which can then be used as input to various machine learning algorithms.
Installation
The package can be installed using pip:
pip install tfIdfInheritVectorizer
Usage
To use the TFIDFVectorizer, simply create an instance of the class and call its fit_transform method. The method takes a list of text documents as input, and returns a sparse matrix representation of the TF-IDF scores for each document.
from tfIdfInheritVectorizer.feature_extraction.vectorizer import TFIDFVectorizer
text_data = [ "This is the first document.", "This is the second document.", "And this is the third one.", "Is this the first document?"]
vectorizer = TFIDFVectorizer()
tfidf = vectorizer.fit_transform(text_data)
In addition to the fit_transform method, the TFIDFVectorizer also has a transform method that can be used to transform new text data into a matrix representation, given the model has already been fit to the training data.
new_text_data = [
"This is a new document.",
"Is this a new one?"
]
new_tfidf = vectorizer.transform(new_text_data)
Configuration
The TFIDFVectorizer has several parameters that can be configured to customize its behavior. Some of the most important parameters are:
- stop_words: a list of stop words that will be ignored during the tokenization process
vectorizer = TFIDFVectorizer(stop_words=["is", "the", "this"])
- max_features: the maximum number of features to keep, based on term frequency across the entire corpus.
vectorizer = TFIDFVectorizer(max_features=50)
- use_idf: a flag indicating whether to use the inverse document frequency (IDF) weighting.
vectorizer = TFIDFVectorizer(use_idf=False)
For a full list of parameters, see the scikit-learn documentation
Conclusion
TFIDFVectorizer is a simple and efficient implementation of the TF-IDF transformation algorithm, suitable for use in various machine learning applications. By using scikit-learn as a base, it provides a wide range of customization options and can be easily integrated into existing machine learning workflows.
License
Metadata
Release files for tfIdfInheritVectorizer 0.1
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 |
|---|---|---|---|---|
| tfIdfInheritVectorizer-0.1.tar.gz | 4.5 kB | Without provenance | Details for tfIdfInheritVectorizer-0.1.tar.gz |
Release files / tfIdfInheritVectorizer-0.1.tar.gz
| Download URL | tfIdfInheritVectorizer-0.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5466c939bc6b2471100fcb18aedaf5712653c800d4844ee8eb05dd81630f46fd
|
|
BLAKE2b-256 checksum How to use checksums |
fc8014a1edd3773972d02da249a71b92262b543f56e064d7ba44b3bf433a6ec0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for tfIdfInheritVectorizer 0.1
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.