Views
No views yet
pt)1{
2 "n_layers": 2,
3 "first_layer_size": 128,
4 "second_layer_size": 64,
5 "ngram_upper": 3,
6 "min_df": 5,
7 "max_df": 0.991954939032491,
8 "activation": "relu",
9 "solver": "lbfgs",
10 "alpha": 0.00014375816817663168,
11 "learning_rate_init": 0.005261446157045498,
12}confusion_matrix.pngfinal_classification_report.parquetfinal_predictions.parquetfinal_model.joblib.1import joblib
2from huggingface_hub import hf_hub_download
3
4repo_id = "vzani/portuguese-fake-news-classifier-mlp-tfidf-combined" # or fake-br / faketrue-br
5filename = "final_model.joblib"
6
7model_path = hf_hub_download(repo_id=repo_id, filename=filename)
8clf = joblib.load(model_path)
9
10
11def predict(text: str) -> tuple[bool, float]:
12 prob = clf.predict_proba([text])[0][1]
13 pred = prob >= 0.5
14
15 # Convert the probability in case of Fake
16 prob = prob if pred else 1 - prob
17 return bool(pred), float(prob)
18
19
20if __name__ == "__main__":
21 text = "BOMBA! A Dilma vai taxar ainda mais os pobres!"
22 print(predict(text))
23True 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, 1.0)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}