//path_data : row are selected, 2 columns to be cropped ("time,id") //path_minmax : minmax, no crop is needed, leave "" for local MM //path_folder & filename : path to save //Auto Crop Column Name public static void ChangeAnalysis(string path_data_selected, string path_GlobalMM, string path_folder, string filename) { try { path_PE_localMM = path_folder + @"\[MinMax(local)].csv";//in case Local path_PE_vRank = path_folder + @"\" + filename + " F-Rank.csv"; path_PE_normal_extract = path_folder + @"\" + filename + " Extracted-03 Normalized.csv"; DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true); //have 2 unused col DataTable dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0); //only analyzed column DataTable dt_mm = null; //Datatable of MinMax //--- Prepare MinMax Table Boolean useGlobalMM = true; if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false) { useGlobalMM = false; } else { try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); } catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; } } if (useGlobalMM == false) { //build MM table by local data dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table TheTool.export_dataTable_to_CSV(path_PE_localMM, dt_mm); } try { DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm); //--- Cal Change ------------------------------------- List <String> data_raw_change = ThePosExtract.process_calChange(dt_data, false, false); List <String> data_normal_change = ThePosExtract.process_calChange(dt_normal, true, true); List <String> data_ChangeAnalysis = new List <String>(); data_ChangeAnalysis.Add("RAW"); data_ChangeAnalysis.AddRange(data_raw_change); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add(""); data_ChangeAnalysis.Add("NORMALIZED F-RANKING"); data_ChangeAnalysis.AddRange(data_normal_change); TheTool.exportCSV_orTXT(path_PE_vRank, data_ChangeAnalysis, false); //--- Normalize Table : re-added column before save dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0); dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0); int r = 0; foreach (DataRow row in dt_normal.Rows) { row[0] = dt_temp.Rows[r][0].ToString(); row[1] = dt_temp.Rows[r][1].ToString(); r++; } TheTool.export_dataTable_to_CSV(path_PE_normal_extract, dt_normal); } catch (Exception ex) { TheSys.showError("Normalize: " + ex.ToString()); } } catch (Exception ex) { TheSys.showError("Change Analysis: " + ex.ToString()); } }
// "saveFolder" end with \ public static void calSparse(List <UKI_DataRaw> list_extractPose, string saveFolder, string filename) { try { List <String> list_data_n1 = new List <String> { }; List <String> list_data_n2 = new List <String> { }; List <String> list_data_n3 = new List <String> { }; UKI_DataRaw pose_canonical = null; UKI_DataRaw pose_current = null; list_data_n1.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); list_data_n2.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); list_data_n3.Add(DisplayColumnInfo(list_extractPose[0], list_extractPose[0].AnkleLeft.GetType())); int index_canonical = 0; int index_current = 0; String row_name; foreach (UKI_DataRaw r in list_extractPose) { pose_current = r; index_current = r.id; //---------------------------------------------------- String data = ""; if (pose_canonical != null) { row_name = index_canonical + " to " + index_current + ","; double duration_frame_inverse = 1.0f / (pose_current.id - pose_canonical.id); double[] joint_sum = SummarizeJointsVector(pose_current); data = row_name + DisplayJointsVectorToCentroid(pose_current, joint_sum, duration_frame_inverse, pose_canonical); list_data_n1.Add(data); UKI_DataRaw joint_vector_s_1 = CreateSkeletonRawDataFromString(data); double[] xyz_size_vector_current_pose = JointToJointSize(joint_vector_s_1); double[] xyz_size_vector_canonical_pose = JointToJointSize(pose_canonical); data = row_name + DisplayJointsVectorRescalling(joint_vector_s_1, xyz_size_vector_canonical_pose, xyz_size_vector_current_pose); list_data_n2.Add(data); UKI_DataRaw joint_vector_s_2 = CreateSkeletonRawDataFromString(data); double[] joint_sum_canonical_ht = SummarizeJointsVectorFromHeadAndTorso(pose_canonical); double[] joint_sum_current_ht = SummarizeJointsVectorFromHeadAndTorso(joint_vector_s_2); data = row_name + DisplayJointsVectorHeadAndTorsoToCentroid(joint_vector_s_2, joint_sum_canonical_ht, joint_sum_current_ht, duration_frame_inverse); list_data_n3.Add(data); } //---------------------------------------------------- pose_canonical = r; index_canonical = r.id; } TheTool.exportCSV_orTXT(saveFolder + "N1_" + filename + ".csv", list_data_n1, false); TheTool.exportCSV_orTXT(saveFolder + "N2_" + filename + ".csv", list_data_n2, false); TheTool.exportCSV_orTXT(saveFolder + "N3_" + filename + ".csv", list_data_n3, false); } catch (Exception ex) { TheSys.showError(ex); } }
void countExport() { string path3 = path_root + "/countP1.txt"; countP1++; string a = countP1.ToString(); TheTool.writeFile(path3, a, true); }
//************************************************************************ //******* Free Style Usage *********************************************** public static Instance load1Instance_fromPath(string path) { Instance inst = new Instance(); inst.path = path; inst.name = TheTool.getFileName_byPath(inst.path); inst.getDataRaw(true); return(inst); }
public static void MSR_showSample() { TheSys.showError("Link: http://research.microsoft.tcom/en-us/um/people/zliu/ActionRecoRsrc/default.htm"); TheSys.showError("Below is an example of data"); TheSys.showError(""); foreach (String s in TheTool.read_File_getListString(TheURL.url_tv_sample_msr)) { TheSys.showError(s); } }
//H(X|Y) = H(X,Y) - H(Y) public static double calConditionalEntropy(DataTable dt, List <str_double> list_entropy, string x, string y) { double entropy = 0; entropy += calJointEntropy(dt, new List <string> { x, y }); entropy -= TheTool.str_double_getDouble_byStr(list_entropy, y); return(entropy); }
//public static List<Data_UserData> list_user_top10 = new List<Data_UserData>();//sorted, 0 as dummy public static void SaveAll() { List <string> s = new List <string>(); foreach (Data_UserData u in list_user_all) { s.Add(u.total + "," + u.p1_cheer + "," + u.p1_jeer + "," + u.p2_cheer + "," + u.p2_jeer + "," + u.username); } TheTool.exportCSV_orTXT(path1, s, false); TheTool.log("SAVEEEEEEEEEE"); }
//=================================================================== public void cutData(int pe_cutAt) { if (pe_cutAt > 0) { data_raw = TheTool.list_CutAt(data_raw, pe_cutAt); data_bp = TheTool.list_CutAt(data_bp, pe_cutAt); data_movement = TheTool.list_CutAt(data_movement, pe_cutAt); data_add_01 = TheTool.list_CutAt(data_add_01, pe_cutAt); data_log = TheTool.list_CutAt(data_log, pe_cutAt); } }
private void msr_sample_Click(object sender, RoutedEventArgs e) { TheConverter.MSR_showSample(); TheSys.showError("Link: http://research.microsoft.tcom/en-us/um/people/zliu/ActionRecoRsrc/default.htm"); TheSys.showError("Below is an example of data"); TheSys.showError(""); foreach (String s in TheTool.read_File_getListString(TheURL.url_tv_sample_msr)) { TheSys.showError(s); } }
private void but_oneSide_cal_Click(object sender, RoutedEventArgs e) { oneSide_numParticipant = TheTool.getInt(txt_oneSide_numParticipant); oneSide_avgMsg_perMinParticipant = TheTool.getDouble(txt_oneSide_avg); double d = 60000 / (oneSide_avgMsg_perMinParticipant * oneSide_numParticipant); oneSide_generateEvery = (int)d; txt_oneSide_rate.Text = oneSide_generateEvery.ToString(); oneSide_Timer.Stop(); oneSide_Timer.Dispose(); oneSideMode_startTimer(); }
//Browser File private void buttonBrowse_Click(object sender, RoutedEventArgs e) { Nullable <bool> openDialog = TheTool.openFileDialog_01(false, ".csv", TheURL.url_saveFolder); if (openDialog == true) { string filePath = TheTool.dialog.FileName; readData(filePath); fileName = TheTool.getFileName_byPath(filePath); Title = fileName; } }
void subTable_calJointEuclidian(int fileID, DataTable dt) { try { //================================================= //============= Write Sub Table ================== //build Column First columnAdd_forJoints(dt, col_s_suffix_d); //====================================================== //------ Variable For cal Euclidian Distance double[] lastXYZ = { 0, 0, 0 }; double[] currentXYZ = { 0, 0, 0 }; List <double> list_D; double dist; //====================================================== foreach (string joint in TheTool.joint_list_upperOnly)//Column first method { list_D = new List <double> { }; if (normaliz_method == 4) { TheMinMaxNormaliz.getMinMax(joint, ref temp_Dist_min, ref temp_Dist_max); } //------ Cal AvgC ----------------------------- //double avg_C = TheTool_Stat.calAvg_byCol(dt, joint + "_c", decimalNum); //dataTable.Rows[fileID][joint + col_m_cAvg] = avg_C; //------ Cal Joint D ----------------------------- for (int row = 0; row < dt.Rows.Count; row++) { //------ Cal Euclidian -------------------------------- currentXYZ = TheTool.getDouble_fromJoint(dt, row, joint); if (row == 0) { dt.Rows[row][joint + col_s_suffix_d] = "0"; } else { dist = TheTool_Stat.calEuclidean(currentXYZ, lastXYZ, decimalNum); if (normaliz_method == 4) { dist = TheTool_Stat.calMinMaxNormalize(dist, temp_Dist_min, temp_Dist_max); } dt.Rows[row][joint + col_s_suffix_d] = dist; list_D.Add(dist); } lastXYZ = currentXYZ; } //================================================= //============= Write Main Table ================== calMainTable(list_D, fileID, joint); } } catch { } }
private void button2_Click(object sender, RoutedEventArgs e) { Nullable <bool> openDialog = TheTool.openFileDialog_01(false, ".arff", TheURL.url_saveFolder); // Get the selected file name and display in a TextBox if (openDialog == true) { // Open document string filePath = TheTool.dialog.FileName; txtPath.Text = filePath; } }
private void butExportExcel_Click(object sender, RoutedEventArgs e) { try { string file_name0; file_name0 = "Report_" + DateTime.Now.ToString("MMdd_HHmmss"); string path = file_name0; //------------- TheTool.exportExcel_DReport(path, dt.Copy()); } catch { } }
void loadData(m_If i) { i.type = TheMapData.if_type_2Joint; i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.v2 = TheMapData.getJointName_byDef(comboJ2.Text); i.axis = TheMapData.relation_getAxis_byDef(comboRelative.Text); i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text, i.axis, i.value_d); double v = TheTool.getDouble(txtValue.Text); v *= TheMapData.relation_getDirection_byDef(i.axis, comboRelative.Text); v /= 100; i.value_d = v; }
public static void readSetting() { try { List <string> stringList = TheTool.read_File_getListString(TheURL.url_config); foreach (string s in stringList) { storeSetting(s); } loadSetting = true; } catch { TheSys.showError("Error Read Setting : delete config.txt to solve this problem"); } }
private void butExport_Click(object sender, RoutedEventArgs e) { try { string file_name0; file_name0 = "Report_" + DateTime.Now.ToString("MMdd_HHmmss"); string path = TheURL.url_saveFolder + file_name0 + ".csv"; //------------- //TheTool.Folder_CreateIfMissing(path_saveRoot); TheTool.export_dataTable_to_CSV(path, dt.Copy()); } catch { } }
void loadData(m_If i) { i.type = TheMapData.if_type_SphereAngle; i.value = TheMapData.then_SphereAngle_Polar; if (comboAngle.SelectedIndex == 1) { i.value = TheMapData.then_SphereAngle_Azimuth; } i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.v2 = TheMapData.getJointName_byDef(comboJ2.Text); i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text); i.value_d = TheTool.adjustRange(TheTool.getDouble(txtValue.Text), 0, 360); }
void loadData(m_If i) { int move_direction = comboDirect.SelectedIndex; int reverse = TheMapData.moveMoveDirection_list[move_direction].direction; double v_modified = TheTool.getDouble(txtValue.Text) / 100; v_modified *= reverse; i.type = TheMapData.if_type_Change; i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.axis = TheMapData.moveMoveDirection_list[move_direction].axis; i.value_d = v_modified; i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text, i.axis, i.value_d); }
void process01EntropyAlgo() { this.dt_ready = TheTool.dataTable_partitize(dt_raw_exclude, partition_range); //01 partitize //------------------------------------------------------------------------------ this.EnAlgo_first_list_F = TheTool.dataTable_getColList(dt_raw_exclude); //unselected feature (pointed by id) this.list_entropy = TheEntropy.calEntropy(dt_ready); this.list_MI = TheEntropy.calMIList(dt_ready, list_entropy); //for reuse MI //Feature Selection Start : get first -------------------------------------- String fi1 = TheEntropy.temp_colWithHigestEntropy; this.EnAlgo_first_list_F.Remove(fi1); this.EnAlgo_first_S = TheData.getFeature(fi1, dt_threshold_pose1, dt_threshold_pose2);//Initial Threshold is assigned here (Not optimized) }
void setTestMode() { if (radio2.IsChecked == true) { TheWeka.test_mode = 1; TheWeka.crossV_fold = TheTool.getInt(txtFold); } else { TheWeka.test_mode = 0; setRatio_TrainTest(); } }
public void fightingICE_sendInput() { List <string> stringList = new List <string>() { }; stringList.Add("Special:" + uki.key_Special); stringList.Add("Atk:" + uki.key_Atk); stringList.Add("X:" + uki.key_X); stringList.Add("Y:" + uki.key_Y); stringList.Add("Xdouble:" + uki.key_X_double); TheTool.writeFile(stringList, path_fightingICE, false); }
void save_SubTable() { string folderPath = path_saveRoot + folder_forSave; TheTool.Folder_CreateIfMissing(folderPath); folderPath = folderPath + @"\" + getSubSubFolder(); TheTool.Folder_CreateIfMissing(folderPath); // string filePath = folderPath + @"\" + filename_current + ".csv";//Save in Folder TheTool.export_dataTable_to_CSV(filePath, sub_table); list_fileSave.Add(filePath); }
private void butLoad_Click(object sender, RoutedEventArgs e) { TheURL.dm_path_file = txtPath.Text; TheWeka.step_loadInstance(); if (instanceReady == false) { button1.IsEnabled = true; butLoad.Foreground = Brushes.Black; instanceReady = true; } file_name = TheTool.getFileName_byPath(TheURL.dm_path_file); txt1.Text += "File: " + file_name + Environment.NewLine + Environment.NewLine; }
public void setPath(string path) { try { List <string> stringList = new List <string>() { }; stringList.Add(path); TheTool.writeFile(stringList, TheURL.url_config_FTG, false); path_fightingICE = path; } catch { TheSys.showError("Error Save Setting"); } }
DataTable dataTable = null;//data table that become datagrid //------------------------------------- //Browser File private void buttonBrowse_Click(object sender, RoutedEventArgs e) { Nullable <bool> openDialog = TheTool.openFileDialog_01(false, ".csv", TheURL.url_saveFolder); // Get the selected file name and display in a TextBox if (openDialog == true) { // Open document string filePath = TheTool.dialog.FileName; FileNameTextBox.Text = filePath; readData(filePath); fileName_noExtension = TheTool.getFileName_byPath(filePath); } }
public static void import(string file_path , ref List <DetectorReportData> report_data , ref List <string> report_dataString) { try { List <string> readedData = TheTool.read_File_getListString(file_path); //TheSys.showError(readedData.Count + " : " + file_path); report_data = new List <DetectorReportData> { }; report_dataString = new List <string> { }; int i = 0; DetectorReportData d; foreach (string a in readedData) { if (i > 0) { report_dataString.Add(a); //----------------- d = new DetectorReportData(); string[] b = a.Split(','); d.time = b[0]; d.flag_move = int.Parse(b[1]); d.flag_pitch = int.Parse(b[2]); d.flag_twist = int.Parse(b[3]); d.flag_stand = int.Parse(b[4]); // d.flag_break = int.Parse(b[5]); d.prolong_lv = int.Parse(b[6]); d.pitch_lv = int.Parse(b[7]); d.twist_lv = int.Parse(b[8]); d.total_lv = double.Parse(b[9]); // d.prolong_score = int.Parse(b[10]); d.pitch_score = int.Parse(b[11]); d.twist_score = int.Parse(b[12]); d.total_score = int.Parse(b[13]); d.state = b[14]; // report_data.Add(d); } i++;//Skip Header } } catch (Exception e) { TheSys.showError("import:" + e.Message, true); } }
void process01DCFS() { //prepare this.DCFS_listDelta = getListDelta(); this.DCFS_listDeltaCorrelation = TheTool.list_Copy(DCFS_listDelta); this.DCFS_first_list_F = TheTool.dataTable_getColList(dt_raw_exclude); this.DCFS_listCorrelation = getlistCorrelation(); //pick first feature string fi1 = DCFS_listDelta_getMaxValue(); this.DCFS_first_list_F.Remove(fi1); this.DCFS_first_S = TheData.getFeature(fi1, dt_threshold_pose1, dt_threshold_pose2); DCFS_listDelta_update(fi1); }
private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e) { //if (e.ChatMessage.Message.Contains("badword")) // client.TimeoutUser(e.ChatMessage.Channel, e.ChatMessage.Username, TimeSpan.FromMinutes(30), "Bad word! 30 minute timeout!"); //Console.WriteLine($"NewMsg " + e.ChatMessage.Message); //if(e.ChatMessage.Username != "ligoligo12") //string[] words = e.ChatMessage.Message.Split(','); //if (main.isOneSideMode) //{ // if (main.isAPGInterface == true) // { // //string[] words = e.ChatMessage.Message.Split(','); // //main.getMsg(words[0], words[1]); // //Console.WriteLine("testtttttttt 1: " + words[0] + "testtttttttt 2: " + words[1]); // Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); // } // else // { // main.getMsg(e.ChatMessage.Username, e.ChatMessage.Message); // Console.WriteLine("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); // } // //} //else if (words.Length >= 1) //{ // if (main.isAPGInterface) // { // //string[] words = e.ChatMessage.Message.Split(','); // main.getMsg(words[0], words[1]); // Console.WriteLine("testtttttttt 1: " + words[0] + "testtttttttt 2: " + words[1]); // } // else // { // main.getMsg(e.ChatMessage.Username, e.ChatMessage.Message); // } //} //} TheTool.log("HEREEEEEEE"); main.getMsg(e.ChatMessage.Username, e.ChatMessage.Message); }
private void butBrowse_Click(object sender, RoutedEventArgs e) { Nullable <bool> openDialog = TheTool.openFileDialog_01(false, ".csv", TheURL.url_saveFolder); // Get the selected file name and display in a TextBox if (openDialog == true) { TheTool_DetectorReportData.import(TheTool.dialog.FileName, ref report_data, ref report_dataString); txtFile.Content = "File: " + TheTool.getFileName_byPath(TheTool.dialog.FileName); //------------- adjustGUI(); prepareData(); draw(); } }