Views
No views yet
pt)1{
2 "ngram_upper": 2,
3 "units": 120,
4 "dropout": 0.3374510345164157,
5 "recurrent_dropout": 0.1588638491073387,
6 "max_tokens": 96000,
7 "embed_dim": 71,
8 "embed_max_seq_len": 51,
9 "learning_rate": 0.00011662663429277272,
10 "batch_size": 16,
11 "epochs": 8,
12}confusion_matrix.pngfinal_classification_report.parquetfinal_predictions.parquetfinal_bilstm_model.keras.1import keras
2import tensorflow as tf
3from huggingface_hub import hf_hub_download
4
5repo_id = "vzani/portuguese-fake-news-classifier-bilstm-faketrue-br" # or fake-br / combined
6filename = "final_bilstm_model.keras"
7
8model_path = hf_hub_download(repo_id=repo_id, filename=filename)
9model = keras.models.load_model(model_path)
10
11
12def predict(text: str) -> tuple[bool, float]:
13 input_data = tf.convert_to_tensor([[text]], dtype=tf.string)
14 probs = model.predict(input_data) # type: ignore
15 prob = float(probs.flatten()[0]) # type: ignore
16 pred = prob >= 0.5
17
18 # Convert the probability in case of Fake
19 prob = prob if pred else 1 - prob
20 return pred, prob
21
22
23if __name__ == "__main__":
24 text = "BOMBA! A Dilma vai taxar ainda mais os pobres!"
25 print(predict(text))True for true news and False for fake news) and the second the probability assigned to the predicted class (ranging from 0 to 1.0).(False, 0.997499808203429)1@misc{zani2025portuguesefakenews,
2 author = {ZANI, Vinícius Augusto Tagliatti},
3 title = {Avaliação comparativa de técnicas de processamento de linguagem natural para a detecção de notícias falsas em Português},
4 year = {2025},
5 pages = {61},
6 address = {São Carlos},
7 school = {Instituto de Ciências Matemáticas e de Computação, Universidade de São Paulo},
8 type = {Trabalho de Conclusão de Curso (MBA em Inteligência Artificial e Big Data)},
9 note = {Orientador: Prof. Dr. Ivandre Paraboni}
10}