/// <summary> /// Supplies data for training and testing. /// </summary> /// <param name="record"></param> public void SetRecord(EEGRecord record) { _er = record; _ml.ActionList = _er.actions; #region convert double[][] input = new double[record.FeatureVectorsOutputInput.Count][]; double[][] output = new double[record.FeatureVectorsOutputInput.Count][]; for (int i = 0; i < record.FeatureVectorsOutputInput.Count; i++) { input[i] = new double[_er.FeatureVectorsOutputInput[i].Length - 1]; Array.Copy(_er.FeatureVectorsOutputInput[i], 1, input[i], 0, input[i].Length); output[i] = new double[1]; output[i][0] = _er.FeatureVectorsOutputInput[i][0]; } #endregion #region seperate data for training and testing (evaluating final computed model) int ratio = 5; NNTrainDataIterator iter = new NNTrainDataIterator(ratio, input, output); iter.NextData(out trainDataInput, out trainDataOutput, out testDataInput, out testDataOutput); #endregion }
public ManageRecordedData(EEGRecord record) { InitializeComponent(); AsyncWorkerLoadEEGRecords = new BackgroundWorker(); AsyncWorkerLoadEEGRecords.DoWork += new DoWorkEventHandler(AsyncWorkerLoadEEGRecords_DoWork); AsyncWorkerLoadEEGRecords.RunWorkerCompleted += new RunWorkerCompletedEventHandler(AsyncWorkerLoadEEGRecords_RunWorkerCompleted); AsyncWorkerSaveEEGRecord = new BackgroundWorker(); AsyncWorkerSaveEEGRecord.DoWork += new DoWorkEventHandler(AsyncWorkerSaveEEGRecord_DoWork); AsyncWorkerSaveEEGRecord.RunWorkerCompleted += new RunWorkerCompletedEventHandler(AsyncWorkerSaveEEGRecord_RunWorkerCompleted); providedRecord = record; //listBox1.DisplayMember = "Name"; toolStripStatusLabel1.Text = "Loading EEG records... please wait"; buttonLoad.Enabled = false; rs = new EEGRecordStorage(); AsyncWorkerLoadEEGRecords.RunWorkerAsync(); if (AsyncWorkerLoadEEGRecords.IsBusy) { buttonSave.Enabled = false; } listBox1.Items.Add("Loading..."); }
public Experiment(string name, EEGRecord er, AMLearning ml, bool enabled) { Name = name; _er = er; _ml = ml; _enabled = enabled; _ml.Progress += new ChangedValuesEventHandler(_ml_Progress); }
/// <summary> /// Checks dimensions /// </summary> /// <param name="record"></param> /// <returns></returns> public static bool IsRecordValid(EEGRecord record) { int m = record.FeatureVectorsOutputInput[0].Length; foreach (var k in record.FeatureVectorsOutputInput) { if (k.Length != m) { return(false); } } return(true); }
public void SaveRecord(EEGRecord record) { if (!File.Exists(DbSettings.fullpath + ".eq")) { db.CreateDatabase(DbSettings.fullpath); } db.OpenDatabase(DbSettings.fullpath); db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues; db.Store(record); db.Close(); }
public EEGRecord(EEGRecord rec) { FeatureVectorsOutputInput = new List <double[]>(); actions = new Dictionary <string, int>(rec.actions); for (int i = 0; i < rec.FeatureVectorsOutputInput.Count; i++) { double[] newItem = new double[rec.FeatureVectorsOutputInput[i].Length]; rec.FeatureVectorsOutputInput[i].CopyTo(newItem, 0); FeatureVectorsOutputInput.Add(newItem); } Name = rec.Name; }
void AsyncWorkerSaveEEGRecord_DoWork(object sender, DoWorkEventArgs e) { if (providedRecord.FeatureVectorsOutputInput.Count == 0) { MessageBox.Show("Save operation aborted. Record seems empty!"); return; } toolStripStatusLabel1.Text = "Saving... please wait"; EEGRecord saveRecord = new EEGRecord(providedRecord);//create a copy saveRecord.Name = textBoxName.Text; rs.SaveRecord(saveRecord); records.Add(saveRecord); }
public EEGRecord LoadModel(string name) { EEGRecord result = null; if (File.Exists(DbSettings.fullpath + ".eq")) { db.OpenDatabase(DbSettings.fullpath); db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues; result = (from EEGRecord sample in db where sample.Name == name select sample).FirstOrDefault(); db.Close(); } return(result); }
void rd_ReocordSelected(EEGRecord record) { foreach (double[] vector in record.FeatureVectorsOutputInput) { double[] input = new double[vector.Length - 1]; Array.Copy(vector, 1, input, 0, vector.Length - 1); int result = model.Classify(input); if (result == vector[0]) { listBoxResult.Items.Insert(0, "OK"); } else { listBoxResult.Items.Insert(0, "wrong"); } } }
public abstract void Train(EEGRecord record);
private void buttonClearRecord_Click(object sender, EventArgs e) { currentRecord = new EEGRecord(); listBoxLogger.Items.Insert(0, "Recorded data cleared. Now you can record or load data."); }
void rd_ReocordSelected(EEGRecord selectedRecord) { currentRecord = new EEGRecord(selectedRecord);//create a copy listBoxLogger.Items.Insert(0, "Pre-recorded data '" + selectedRecord.Name + "' has been loaded containing: " + currentRecord.FeatureVectorsOutputInput.Count + " feature vectors. You can now record additional data or start 'Computing'."); }