Skip to content

Instantly share code, notes, and snippets.

View howard-haowen's full-sized avatar
:octocat:
AI Engineer at IBM 💻 | Crafting solutions for client success! 🚀

Haowen Jiang howard-haowen

:octocat:
AI Engineer at IBM 💻 | Crafting solutions for client success! 🚀
View GitHub Profile
@howard-haowen
howard-haowen / scikitlearn2pandas.py
Last active May 14, 2021 03:49 — forked from fclesio/get_classification_report.py
Scikit Learn metrics to Pandas DataFrame
from sklearn.metrics import classification_report, confusion_matrix
import pandas as pd
def get_df_classification_report(y_test, y_pred, target_names):
'''Source: https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format'''
report = classification_report(y_test, y_pred, output_dict=True, target_names=target_names)
df = pd.DataFrame(report).transpose()
return df.round(decimals=3)
# example
@howard-haowen
howard-haowen / Matplotlib-Set-Font-for-zh-TW.ipynb
Created December 7, 2020 15:57 — forked from scottt/Matplotlib-Set-Font-for-zh-TW.ipynb
Matplotlib set suitable font for zh_TW text
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@howard-haowen
howard-haowen / text_classification.py
Last active November 18, 2020 05:16 — forked from nicksyna01/text_classification.py
Text Classification using sklearn
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, confusion_matrix
from sklearn.metrics import classification_report
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
#Are the tags which we are using currently for tagging the sentences