ML.Emotion
1.0.0
dotnet add package ML.Emotion --version 1.0.0
NuGet\Install-Package ML.Emotion -Version 1.0.0
<PackageReference Include="ML.Emotion" Version="1.0.0" />
paket add ML.Emotion --version 1.0.0
#r "nuget: ML.Emotion, 1.0.0"
// Install ML.Emotion as a Cake Addin
#addin nuget:?package=ML.Emotion&version=1.0.0
// Install ML.Emotion as a Cake Tool
#tool nuget:?package=ML.Emotion&version=1.0.0
ML.Emotion
This framework is a Machine Learning framework. It is used to predict the Customer emotion from their feedbacks.
This framework is extended from the Microsoft Machine Learning ML.NET Model.
Datasets and instructions: https://github.com/thanhtd32/ML.Emotion#readme, Coding demo is "ML.EmotionDemo"
This Research from KMOU (Korea Maritime & Ocean University) - Data Science Lab - Room 407.
Authors: Duy Thanh Tran, Prof. Jun-Ho Huh
Any question, please free to contact me: thanhtd@uel.edu.vn
My full name: TRAN DUY THANH
Blog study coding: https://duythanhcse.wordpress.com/
Group support: https://www.facebook.com/groups/communityuni/
ML.Emotion - How to use?
Install nuget package
Install-Package ML.Emotion -ProjectName YourProject
Train-Test Set sample
Download The UCI Sentiment Labeled Sentences dataset zip file: http://archive.ics.uci.edu/ml/machine-learning-databases/00331/sentiment%20labelled%20sentences.zip You use the file "yelp_labelled.txt" or you can download the file at https://github.com/thanhtd32/ML.Emotion/tree/main/TrainTestSet
Full code:
using ML.Emotion.Data;
using ML.Emotion.Predict;
namespace ML.EmotionDemo
{
public partial class frmMain : Form
{
//Declare EmotionEngine object
EmotionEngine emotionEngine =new EmotionEngine();
string folder = "Models";
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
LoadModelIntoCombo();
}
//1. Import dataset and split traint- test set
private void btnLoadData_Click(object sender, EventArgs e)
{
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path=openFileDialog1.FileName;
double ratio=double.Parse(txtTestRatio.Text);
emotionEngine.ImportDataset(path, false, ratio);
}
}
//2. Build model
private void btnBuildModel_Click(object sender, EventArgs e)
{
bool ret=emotionEngine.BuildAndTrainModel();
if (ret)
lblBuildModelStatus.Text = "Build Model successfully";
else
lblBuildModelStatus.Text = "Build Model failed";
}
//3. Evaluate model
private void btnEvaluateModel_Click(object sender, EventArgs e)
{
Metric metric= emotionEngine.Evaluate();
txtAccuracy.Text=metric.Accuracy.ToString();
txtAUC_PR.Text=metric.AUC_PR.ToString();
txtAUC_ROC.Text=metric.AUC_ROC.ToString();
txtF1Score.Text=metric.F1Score.ToString();
txtLogLoss.Text=metric.LogLoss.ToString();
txtLogLossReduction.Text=metric.LogLossReduction.ToString();
txtNegativePrecision.Text=metric.NegativePrecision.ToString();
txtNegativeRecall.Text=metric.NegativeRecall.ToString();
txtPositivePrecision.Text=metric.PositivePrecision.ToString();
txtPositiveRecall.Text = metric.PositiveRecall.ToString();
}
//4. Save model
private void btnSaveModel_Click(object sender, EventArgs e)
{
if (Directory.Exists(folder) == false)
{
Directory.CreateDirectory(folder);
}
string path = folder + "\\ML.Emotion-" + DateTime.Now.ToString("ddMMyyyy-hhmmss") + ".zip";
bool ret = emotionEngine.SaveModel(path);
if (ret)
lblSaveModelStatus.Text = "Save Model successfully";
else
lblSaveModelStatus.Text = "Save Model failed";
LoadModelIntoCombo();
}
//5. Load model
private void LoadModelIntoCombo()
{
cboModel.Items.Clear();
if (Directory.Exists(folder) == false)
{
return;
}
string[] files = Directory.GetFiles(folder);
foreach (string file in files)
{
FileInfo fi = new FileInfo(file);
cboModel.Items.Add(fi.Name);
}
}
//5. Load model and pick model
private void btnLoadModel_Click(object sender, EventArgs e)
{
if (cboModel.SelectedIndex == -1)
return;
string modelName = folder + "\\" + cboModel.Text;
bool ret = emotionEngine.LoadModel(modelName);
if (ret)
lblLoadModelStatus.Text = "Load Model successfully";
else
lblLoadModelStatus.Text = "Load Model failed";
}
//6. Predict
private void btnPredict_Click(object sender, EventArgs e)
{
FeedbackData feedback=new FeedbackData();
feedback.Data=txtInputData.Text;
EmotionDataPrediction result = emotionEngine.Predict(feedback);
picBlameArrow.Visible = false;
lblBlameProbability.Visible = false;
picComplimentArrow.Visible = false;
lblComplimentProbability.Visible = false;
picNeutralArrow.Visible = false;
lblNeutralProbability.Visible = false;
if(result.EmotionType==EmotionType.Blame)
{
picBlameArrow.Visible = true;
lblBlameProbability.Visible = true;
lblBlameProbability.Text = "Probability:" + result.ProbabilityFormat;
}
else if(result.EmotionType==EmotionType.Neutral)
{
picNeutralArrow.Visible = true;
lblNeutralProbability.Visible = true;
lblNeutralProbability.Text = "Probability:" + result.ProbabilityFormat;
}
else if(result.EmotionType== EmotionType.Compliment)
{
picComplimentArrow.Visible = true;
lblComplimentProbability.Visible = true;
lblComplimentProbability.Text = "Probability:" + result.ProbabilityFormat;
}
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.ML (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 255 | 2/27/2022 |