-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from TailUFPB/develop
Develop
- Loading branch information
Showing
30 changed files
with
5,617 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pickle | ||
|
||
def make_prediction(my_sentence): | ||
model_file = "./models/hate_speech.pkl" | ||
try: | ||
# Carregando o pipeline do arquivo .pkl | ||
with open(model_file, 'rb') as model_file: | ||
pipeline = pickle.load(model_file) | ||
|
||
# Fazendo previsões para os textos | ||
predictions = pipeline.predict([my_sentence]) | ||
|
||
return predictions[0] | ||
|
||
except Exception as e: | ||
return str(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import pandas as pd | ||
import pickle | ||
|
||
def news_prediction(texts): | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pandas as pd | ||
import pickle | ||
from sklearn.pipeline import make_pipeline | ||
|
||
# bag of words | ||
from sklearn.feature_extraction.text import TfidfVectorizer | ||
|
||
from sklearn.model_selection import train_test_split | ||
from sklearn.naive_bayes import MultinomialNB | ||
|
||
df = pd.read_csv("../training_df/nb_hatespeech.csv", sep=';') | ||
|
||
# Dividindo os dados em um conjunto de treinamento e um conjunto de teste | ||
x = df["comment"] | ||
y = df["isHate"] | ||
|
||
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42) | ||
|
||
# Criando um pipeline com o vetorizador TF-IDF e o classificador Multinomial Naive Bayes | ||
pipeline = make_pipeline(TfidfVectorizer(), MultinomialNB()) | ||
|
||
# Ajustando o modelo ao conjunto de treinamento | ||
pipeline.fit(X_train, y_train) | ||
|
||
# Salvando o pipeline em um arquivo .pkl | ||
with open("hate_speech.pkl", "wb") as model_file: | ||
pickle.dump(pipeline, model_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<<<<<<< Updated upstream:api/requirements.txt | ||
Flask==2.3.2 | ||
Flask-Cors==4.0.0 | ||
pandas==2.0.3 | ||
nltk==3.8.1 | ||
scikit-learn==1.3.0 | ||
numpy==1.25.2 | ||
matplotlib==3.7.1 | ||
seaborn==0.13.0 | ||
tensorflow==2.16.1 | ||
keras==3.0.0 | ||
======= | ||
Flask==2.3.2 | ||
Flask-Cors==4.0.0 | ||
pandas==2.0.3 | ||
nltk==3.8.1 | ||
scikit-learn==1.3.0 | ||
numpy==1.25.2 | ||
matplotlib==3.7.1 | ||
seaborn==0.13.0 | ||
tensorflow==2.16.1 | ||
keras==3.0.0 | ||
torchtext==0.17.2 | ||
>>>>>>> Stashed changes:requirements.txt |
Oops, something went wrong.