Accord.Net_正規化的作法
一個程式Example
reference link:
https://github.com/primaryobjects/Accord.NET/blob/master/Sources/Accord.Statistics/Filters/Normalization.cs
程式碼區塊(修改一些些資料欄位):
計算標準差部分的程式碼觀察
reference link:
https://github.com/primaryobjects/Accord.NET/blob/master/Sources/Accord.Statistics/Filters/Normalization.cs
程式碼區塊(修改一些些資料欄位):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Accord.IO;
using Accord.MachineLearning;
using Accord.Math;
using Accord.Collections;
using Accord.Diagnostics;
using Accord.Controls;
using Accord.Statistics;
using System.Data; // DataTable
using Accord.Statistics.Filters; // for Normalization
using Accord;
namespace Accord_Normalize_exercise
{
class Program
{
static void Main(string[] args)
{
//Normalization Class
//Create the sample table
DataTable table = new DataTable("Sample data");
table.Columns.Add("Age", typeof(double));
table.Columns.Add("Label", typeof(string));
//如果我的 年齡 < 20 就是 Child
//如果我的 年齡 > 20 就是 Adult
table.Rows.Add(10, "child");
table.Rows.Add(7, "child");
table.Rows.Add(5, "child");
table.Rows.Add(72, "Adult");
table.Rows.Add(15, "child");
table.Rows.Add(21, "Adult");
table.Rows.Add(23, "Adult");
table.Rows.Add(9, "child");
table.Rows.Add(30, "Adult");
table.Rows.Add(65, "Adult");
table.Rows.Add(40, "Adult");
DataGridBox.Show(table);
Normalization normal = new Normalization(table);
double mean = normal["Age"].Mean;
double sdev = normal["Age"].StandardDeviation;
table.Rows.Add(mean, "平均");
table.Rows.Add(sdev, "標準差");
//table.Columns.Add(mean, "平均");
//做一次 正規化
DataTable tableAfterNormal = normal.Apply(table);
DataGridBox.Show(tableAfterNormal);
}
}
}
計算標準差部分的程式碼觀察
留言
張貼留言