Feature Extraction
FeatureExtraction
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
__init__(max_features=5000)
Initializes the FeatureExtraction with a TF-IDF vectorizer.
Parameters: - max_features (int): The maximum number of features (vocabulary size).
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
fit_transform(documents)
Fits the TF-IDF vectorizer on the documents and transforms them into feature vectors.
Parameters: - documents (list of str): The list of documents to process.
Returns: - sparse matrix: The TF-IDF feature matrix.
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
52 53 54 55 56 57 58 59 60 61 62 63 |
|
get_feature_names()
Retrieves the feature names (vocabulary) from the vectorizer.
Returns: - list: A list of feature names.
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
79 80 81 82 83 84 85 86 |
|
tokenize(text)
Tokenizes and lemmatizes the input text.
Parameters: - text (str): The text to tokenize.
Returns: - list: A list of processed tokens.
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
transform(documents)
Transforms the documents into TF-IDF feature vectors using the already fitted vectorizer.
Parameters: - documents (list of str): The list of documents to transform.
Returns: - sparse matrix: The TF-IDF feature matrix.
Source code in engines/contentFilterEngine/performance_scalability/feature_extraction.py
65 66 67 68 69 70 71 72 73 74 75 76 77 |
|