Skip to content

Commit

Permalink
classifier statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasgabriel18 committed Nov 17, 2023
1 parent 85b2dc3 commit 0cf454d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions api/DataProcesser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ def handle_classify(self, df, classifier):

return classifier_switcher.get(classifier, lambda: "Invalid Classifier")(df)

def generate_statistics(self, df):
unique_labels = df['output_column'].unique()

statistics = {
'total_rows': len(df),
'unique_labels': list(unique_labels),
'label_counts': df['output_column'].value_counts().to_dict()
}

return statistics

def preprocess_text(self, texto):
if self.input_column is not None: # Verifique se a coluna foi definida
# tiro tudo que não for texto e espaço
Expand Down
2 changes: 1 addition & 1 deletion api/NbEmotionsModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def make_prediction(my_sentence):

new_sentence = tfidf_vectorizer.transform([my_sentence])
prediction = model.predict(new_sentence)
return prediction
return prediction[0]
3 changes: 2 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def upload_file():

df = pd.DataFrame(selected_data, columns=['input_column'])
result = data_processer.handle_classify(df, selected_classifier)
stats = data_processer.generate_statistics(result)

return jsonify({'result': result.to_json()})
return jsonify({'result': result.to_json(), 'stats': stats})

@app.route('/get-classifiers', methods=["GET"])
def get_classifiers():
Expand Down

0 comments on commit 0cf454d

Please sign in to comment.