亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? form1.cs

?? 基于貝葉斯的數據挖掘算法的實現,使用visual stutio2005編程實現。
?? CS
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using System.Text;

namespace DataMing
{
	/// <summary>
	/// Form1 的摘要說明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid dataGrid1;
		static private int kind = 0;//分類數目
		static private int feature = 0;
		private string path = null;
		static private DataSet ds = new DataSet();
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		private System.Windows.Forms.DataGrid dataGrid2;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.MenuItem menuItem5;
		/// <summary>
		/// 必需的設計器變量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗體設計器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
			//
			
		}

		/// <summary>
		/// 清理所有正在使用的資源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗體設計器生成的代碼
		/// <summary>
		/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
		/// 此方法的內容。
		/// </summary>
		private void InitializeComponent()
		{
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
			this.dataGrid2 = new System.Windows.Forms.DataGrid();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// dataGrid1
			// 
			this.dataGrid1.AlternatingBackColor = System.Drawing.Color.White;
			this.dataGrid1.BackColor = System.Drawing.Color.White;
			this.dataGrid1.BackgroundColor = System.Drawing.Color.Ivory;
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dataGrid1.CaptionBackColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid1.CaptionForeColor = System.Drawing.Color.Lavender;
			this.dataGrid1.CaptionText = "標準差與均值";
			this.dataGrid1.DataMember = "";
			this.dataGrid1.FlatMode = true;
			this.dataGrid1.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dataGrid1.ForeColor = System.Drawing.Color.Black;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Wheat;
			this.dataGrid1.HeaderBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.Black;
			this.dataGrid1.LinkColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid1.Location = new System.Drawing.Point(16, 24);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Ivory;
			this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.Black;
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.SelectionBackColor = System.Drawing.Color.Wheat;
			this.dataGrid1.SelectionForeColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid1.Size = new System.Drawing.Size(544, 112);
			this.dataGrid1.TabIndex = 0;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.dataGrid2);
			this.groupBox1.Location = new System.Drawing.Point(48, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(568, 232);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "訓練數據";
			// 
			// dataGrid2
			// 
			this.dataGrid2.AlternatingBackColor = System.Drawing.Color.White;
			this.dataGrid2.BackColor = System.Drawing.Color.White;
			this.dataGrid2.BackgroundColor = System.Drawing.Color.Ivory;
			this.dataGrid2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dataGrid2.CaptionBackColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid2.CaptionForeColor = System.Drawing.Color.Lavender;
			this.dataGrid2.CaptionText = "訓練數據";
			this.dataGrid2.DataMember = "";
			this.dataGrid2.FlatMode = true;
			this.dataGrid2.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dataGrid2.ForeColor = System.Drawing.Color.Black;
			this.dataGrid2.GridLineColor = System.Drawing.Color.Wheat;
			this.dataGrid2.HeaderBackColor = System.Drawing.Color.CadetBlue;
			this.dataGrid2.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid2.HeaderForeColor = System.Drawing.Color.Black;
			this.dataGrid2.LinkColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid2.Location = new System.Drawing.Point(16, 24);
			this.dataGrid2.Name = "dataGrid2";
			this.dataGrid2.ParentRowsBackColor = System.Drawing.Color.Ivory;
			this.dataGrid2.ParentRowsForeColor = System.Drawing.Color.Black;
			this.dataGrid2.SelectionBackColor = System.Drawing.Color.Wheat;
			this.dataGrid2.SelectionForeColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid2.Size = new System.Drawing.Size(496, 184);
			this.dataGrid2.TabIndex = 0;
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem5});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3,
																					  this.menuItem4});
			this.menuItem1.Text = "文件&F";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "添加訓練數據";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "顯示標準差與均值";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 2;
			this.menuItem4.Text = "";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.dataGrid1);
			this.groupBox2.Location = new System.Drawing.Point(48, 256);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(576, 152);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "特征值的標準差與均值";
			this.groupBox2.Visible = false;
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 1;
			this.menuItem5.Text = "form2";
			this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(704, 465);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "分類";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 應用程序的主入口點。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		/// <summary>
		/// 根據樣本數據進行訓練
		/// </summary>
		/// <param name="path">訓練數據文件的路徑</param>
		/// <param name="db" > 訓練數據的元數據</param>
		/// <returns></returns>
		static private DataSet GetDataSet(string path,DataTable db)
		{			
			string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ;Extended Properties=Excel 8.0;Data Source = " + path;
			OleDbConnection myConn = new OleDbConnection(strCon );

			feature = db.Rows.Count  - 1;//獲取特征數目

			//			string strCom = " SELECT v5,count(v5) as total,stdev(v1) as dev1,avg(v1) as avg1,stdev(v2) as dev2,avg(v2) as avg2,stdev(v3) as dev3," +
			//				"avg(v3) as avg3,stdev(v3) as dev4,avg(v4) as avg4 FROM [sheet1$] group by v5 having count(*)>2";
			/*-----------------------------
			 * 預處理,將列名轉化為固定的列名
			 * 
			 ------------------------------*/
			StringBuilder sb = new StringBuilder("select ");

			int count = db.Rows.Count ;
			string s = db.Rows[count-1][0].ToString();

			sb.Append(s + " as v" + count.ToString() + ",count(" + s +") as total");

			count--;

			for(int i = count;i>0;i--)
			{
				string ms = ",stdev(" + db.Rows[i-1][0].ToString() + ") as dev" + i + ",avg(" +  db.Rows[i-1][0].ToString() + ") as avg" + i;
				sb.Append(ms); 
			}
			sb.Append(" from [sheet1$] group by " + s + " having count(*) > 1");
			//Console.WriteLine("sb={0}",sb);

			try
			{ 
				myConn.Open ( ) ;
				OleDbDataAdapter da = new OleDbDataAdapter(sb.ToString(),myConn);
				da.Fill(ds);
				kind = ds.Tables[0].Rows.Count;//分類數目

				myConn.Close();
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message);
			}
			return ds;
		}

		/// <summary>
		/// 獲取訓練數據的元素據
		/// </summary>
		/// <param name="path"></param>
		/// <returns></returns>
		static DataTable GetSchema(string path)
		{
			string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ;Extended Properties=Excel 8.0;Data Source = " + path;
			OleDbConnection myConn = new OleDbConnection(strCon );
			string str = "select top 1 * from [sheet1$]";

			OleDbCommand myCommand = new OleDbCommand(str,myConn);
			OleDbDataReader myReader;
			DataTable schemaTable = new DataTable();

			try
			{ 
				myConn.Open ( ) ;
				myReader = myCommand.ExecuteReader();

				schemaTable = myReader.GetSchemaTable();
				
				myConn.Close();
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message);
			}
			return schemaTable;
		}

		/// <summary>
		/// 根據文件路徑,獲取待分類的數據集
		/// </summary>
		/// <param name="path">文件路徑</param>
		/// <returns>數據集合</returns>
		static private DataTable GetDataTable(string path)
		{
			string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ;Extended Properties=Excel 8.0;Data Source = " + path;
			OleDbConnection myConn = new OleDbConnection(strCon );
            
			string myCon = "select * from [sheet1$]";

			DataSet source = new DataSet();
			try
			{ 
				myConn.Open ( ) ;
				OleDbDataAdapter da = new OleDbDataAdapter(myCon,myConn);
				da.Fill(source);

				myConn.Close();
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message);
			}
			return source.Tables[0];
		}

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			
			OpenFileDialog openFileDialog1 = new OpenFileDialog();

			openFileDialog1.InitialDirectory = "c:\\" ;
			openFileDialog1.Filter = "txt files (*.xls)|*.xls" ;
			openFileDialog1.FilterIndex = 1 ;
			openFileDialog1.RestoreDirectory = true ;

			if(openFileDialog1.ShowDialog() == DialogResult.OK)
			{
				path = openFileDialog1.FileName;
				dataGrid2.DataSource = GetDataTable(path);
				dataGrid1.DataSource = GetDataSet(path,GetSchema(path));
			}

		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			groupBox2.Visible = !groupBox2.Visible;
			menuItem3.Text = groupBox2.Visible ?"隱藏標準差與均值":"顯示標準差與均值";
		}

		/// <summary>
		/// 將數據分類
		/// </summary>
		/// <param name="db">有待分類的數據</param>
	    private void Classify(DataTable db)
		{
			if(db.Columns.Count!=feature)
			{
				MessageBox.Show(this,"輸入特征值的數目不對!","錯誤提示");
			}
		
			//添加結果列
				DataColumn col = new DataColumn();
				col.ColumnName = "result";
				col.DataType = Type.GetType("System.String");
				db.Columns.Add(col);

				double[] input = new double[feature];
				foreach(DataRow dr in db.Rows)
				{
					for(int i=0;i<feature;i++)
					{
						try
						{
							input[i] = double.Parse(dr[i].ToString());
						}
						catch(Exception ex)
						{
							Console.WriteLine(ex.Message);
						}
					}
					dr["result"] = ReturnType(input);
				}

		}
     
		/// <summary>
		/// 計算概率,分布為高斯分布
		/// </summary>
		/// <param name="x">樣本值</param>
		/// <param name="avg">樣本均值</param>
		/// <param name="dev">樣本方差</param>
		/// <returns>概率</returns>
		 private double GetPossibility(double x,double avg,double dev)
		{
			double n = -(x-avg)*(x-avg)/(2*dev*dev);
			double m = 1/(dev*Math.Sqrt(2*Math.PI));
			return Math.Exp(n)*m;
		}
		/// <summary>
		/// 根據輸入的特征值,返回其所屬的類
		/// </summary>
		/// <param name="input">特征值數組</param>
		/// <returns>類名</returns>
		 private string ReturnType(double[] input)
		{
			if(input.Length != feature)
			{
				return "ERROR!";
			}

			int total=0;//計算樣本的總數
			foreach (DataRow dr in ds.Tables[0].Rows)
			{
				try
				{
					total += int.Parse(dr["total"].ToString());
				}
				catch(Exception ex)
				{
					MessageBox.Show(this,ex.Message,"ERROR");
				}
			}

			int index = -1;//所屬類的索引
			int c = -1;
			double p = 0;//屬于某類的概率

			foreach (DataRow dr in ds.Tables[0].Rows)
			{
				c++;
				double sp = double.Parse(dr["total"].ToString())/total;

				//計算P(X|Ci)
				double temp = 1;
				for(int i=1;i<=feature;i++)
				{
					double avg = double.Parse(dr["avg" + i].ToString());
					double dev = double.Parse(dr["dev" + i].ToString());
					temp *= GetPossibility(input[i-1],avg,dev);	
				}

				temp *= sp;//P(X|Ci)P(Ci)

				if(p<temp)
				{
					p = temp;
					index = c;
				}
			}
			
			return ds.Tables[0].Rows[index]["v" + (feature+1)].ToString();     
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			Form2 f2 = new Form2();
			f2.Show();
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人av资源站| 日韩欧美一级二级| 精品国产凹凸成av人网站| 亚洲国产精品ⅴa在线观看| 五月天欧美精品| 99久久久久久| 2023国产精品| 日本亚洲最大的色成网站www| 成人sese在线| 久久久久国产成人精品亚洲午夜| 亚洲成人一区二区在线观看| 不卡的av电影| 久久久精品人体av艺术| 日本伊人午夜精品| 欧美调教femdomvk| 中文字幕精品一区| 日本欧美加勒比视频| 粉嫩在线一区二区三区视频| 欧美日韩日本视频| 国产亚洲综合色| 日韩1区2区3区| 在线视频一区二区三区| 日韩女优av电影| 亚洲国产aⅴ成人精品无吗| 高清国产一区二区三区| 欧美日韩精品久久久| 国产精品进线69影院| 久久99精品国产麻豆不卡| 91同城在线观看| 久久久高清一区二区三区| 午夜精品国产更新| 99re这里只有精品首页| 久久影院电视剧免费观看| 亚洲成人www| 91网站最新地址| 国产欧美一区二区三区在线老狼| 日本亚洲电影天堂| 欧美午夜精品久久久久久孕妇| 久久精品网站免费观看| 久久草av在线| 欧美偷拍一区二区| 亚洲欧美一区二区久久| 麻豆精品在线视频| 欧美精品在欧美一区二区少妇| 国产精品色哟哟| 成人午夜免费视频| 日韩一区二区在线免费观看| 亚洲va国产天堂va久久en| av不卡免费电影| 国产精品美女久久久久久2018 | 国产欧美日韩激情| 韩国在线一区二区| 久久久亚洲综合| 国产一区二区h| 国产欧美综合在线观看第十页| 国产精品羞羞答答xxdd| 久久看人人爽人人| 国产一区二区三区综合| 国产亚洲一区二区在线观看| 国产一区二区三区香蕉| 国产色爱av资源综合区| 国产99久久久国产精品潘金| 国产日韩欧美亚洲| 95精品视频在线| 亚洲精品一二三| 91九色最新地址| 亚洲免费在线播放| 5月丁香婷婷综合| 狠狠狠色丁香婷婷综合激情| 99久久精品一区二区| 一区二区三区欧美亚洲| 成人精品在线视频观看| 亚洲色图一区二区| 欧美日韩国产免费| 久久99久久精品| 国产精品视频第一区| 在线中文字幕一区二区| 天天影视涩香欲综合网| 久久在线免费观看| 91麻豆国产福利精品| 免费一级片91| 欧美精彩视频一区二区三区| 91麻豆国产香蕉久久精品| 日本欧洲一区二区| 国产视频一区二区在线| 欧美专区日韩专区| 国内偷窥港台综合视频在线播放| 中文字幕在线观看不卡| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 日韩精品成人一区二区三区| 欧美激情在线观看视频免费| 在线观看亚洲a| 国产一区二区三区免费播放| 中文字幕一区二区三区不卡在线| 91精品国产综合久久福利| 国产.欧美.日韩| 首页国产欧美久久| 中文字幕在线观看不卡| 欧美大尺度电影在线| 色婷婷亚洲一区二区三区| 激情综合网激情| 亚洲日本电影在线| 欧美群妇大交群中文字幕| 成人激情校园春色| 秋霞午夜av一区二区三区| 亚洲人成精品久久久久久| 精品粉嫩超白一线天av| 欧美三级蜜桃2在线观看| 国产麻豆精品久久一二三| 午夜亚洲国产au精品一区二区| 国产欧美一区二区精品性色| 欧美一区二区大片| 91蜜桃婷婷狠狠久久综合9色| 亚洲综合丁香婷婷六月香| 国产精品电影一区二区| 欧美日韩中文另类| 99久久免费视频.com| 国产精品综合在线视频| 日韩国产欧美三级| 亚洲一级二级在线| **网站欧美大片在线观看| 欧美精彩视频一区二区三区| 精品国产乱码久久久久久1区2区| 欧美三级电影一区| 在线国产亚洲欧美| 91老司机福利 在线| 成人av综合在线| 国产成人精品一区二区三区四区 | av一区二区三区在线| 激情久久五月天| 精品亚洲aⅴ乱码一区二区三区| 午夜视频一区二区三区| 亚洲大片精品永久免费| 一区二区三区日本| 午夜国产不卡在线观看视频| 亚洲午夜免费视频| 午夜精品福利一区二区三区蜜桃| 亚洲永久精品大片| 亚洲成人福利片| 日韩精品每日更新| 日韩影院免费视频| 夜夜嗨av一区二区三区四季av| 一区二区三区四区视频精品免费 | 精品视频一区二区不卡| 欧美亚洲高清一区二区三区不卡| 欧洲一区二区三区在线| 欧美亚洲动漫精品| 日韩精品一区二区三区视频在线观看| 日韩欧美国产三级| 国产亚洲综合在线| 日韩美女久久久| 亚洲精品久久久蜜桃| 青娱乐精品在线视频| 韩国av一区二区三区在线观看| 成人av资源下载| 在线观看免费亚洲| 日韩无一区二区| 国产日韩精品一区二区浪潮av| 国产精品国产a| 亚洲国产日韩一区二区| 日本成人在线一区| 国产精品99久久久| 欧美在线影院一区二区| 欧美精品久久99久久在免费线| 91精品婷婷国产综合久久竹菊| 国产欧美一区二区精品性色| 亚洲精品日韩综合观看成人91| 三级在线观看一区二区| 国产精品一区三区| 91国偷自产一区二区三区观看| 日韩欧美一区二区久久婷婷| 国产日韩影视精品| 午夜av区久久| 成人福利视频在线| 91精品国产aⅴ一区二区| 亚洲444eee在线观看| 日韩一区二区三免费高清| 欧美高清在线视频| 亚洲成av人片www| 国产91对白在线观看九色| 欧美日韩一级视频| 中文字幕高清一区| 天天射综合影视| 盗摄精品av一区二区三区| 另类的小说在线视频另类成人小视频在线 | 一区二区三区在线免费播放| 美女高潮久久久| 欧美视频日韩视频在线观看| 久久综合狠狠综合久久激情| 亚洲黄色在线视频| 国产在线看一区| 欧美日韩视频在线第一区| 国产欧美精品国产国产专区| 日韩国产欧美在线观看| 91在线精品一区二区三区| 制服丝袜在线91| 亚洲精品自拍动漫在线| 国产aⅴ综合色| 日韩欧美一区二区视频| 亚洲乱码日产精品bd|