Bayesian
BAYESIAN
Source code in engines/contentFilterEngine/probabilistic_statistical_methods/bayesian.py
10 11 12 13 14 15 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 |
|
__init__()
Initialize the Bayesian classifier using Multinomial Naive Bayes.
Source code in engines/contentFilterEngine/probabilistic_statistical_methods/bayesian.py
11 12 13 14 15 16 17 |
|
fit(documents, labels)
Fit the Bayesian classifier on the provided documents and labels.
Parameters: - documents (List[str]): List of documents to train the model. - labels (List[int]): Corresponding labels for the documents.
Source code in engines/contentFilterEngine/probabilistic_statistical_methods/bayesian.py
19 20 21 22 23 24 25 26 27 28 29 30 |
|
predict(query)
Predict the label for a given query.
Parameters: - query (str): The query text to classify.
Returns: - int: Predicted label.
Source code in engines/contentFilterEngine/probabilistic_statistical_methods/bayesian.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
recommend(query, top_n=10)
Recommend items based on the Bayesian classifier's prediction.
Parameters: - query (str): The query text for which to generate recommendations. - top_n (int): Number of top recommendations to return.
Returns: - List[int]: List of recommended item indices.
Source code in engines/contentFilterEngine/probabilistic_statistical_methods/bayesian.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|