コード例 #1
0
        private void exportDataSets(EditText input)
        {
            #region nonnormalized
            //This is where we will tie in the PCA core
            ///Its undecided if we want to create a new class that is just the PCA core output to file output, probably best way to do it
            DataStructure.Data   = DataSet;
            DataStructure.Labels = Labels;
            DataStructure.Process();
            DataWriter dataWriter = new DataWriter();

            //User Prompt
            string path = AppSettings.dirData.Path;
            string filePath;

            //get file path
            //get file path
            string name = "RefernceFile.txt";            //Default value
            if (input.Text != "")
            {
                name = "Reference_areas" + areaUpperLimit.ToString() + "_" + input.Text + ".csv";
            }

            filePath = System.IO.Path.Combine(path, name);

            dataWriter.Filepath = filePath;
            //Dimension size
            dataWriter.Dimensionsize = areaUpperLimit;
            dataWriter.NumberOfPics  = Labels.Count;
            dataWriter.writeDimension();
            //Labels
            dataWriter.Labels = Labels;
            dataWriter.writeLabels();
            //using the final data from PCA forms the vectors.
            dataWriter.FinalData = DataStructure.FinalDataRealigned;
            dataWriter.writeFinalDataRealigned();
            //Grab the vectors
            dataWriter.Vectors = DataStructure.FeatureVectors;
            dataWriter.writeVectors();

            //Clear the data structure afterwords
            DataStructure.clear();
            #endregion

            #region normalized

            DataStructure.Data = normalizedSet(DataSet);
            DataStructure.Process();
            dataWriter.FinalData = DataStructure.FinalDataRealigned;
            dataWriter.writeFinalDataRealigned();
            //Grab the vectors
            dataWriter.Vectors = DataStructure.FeatureVectors;
            dataWriter.writeVectors();


            #endregion

            // Export a raw file which can then be added to later
            name     = "DataSet_areas" + areaUpperLimit.ToString() + "_" + input.Text + ".csv";
            filePath = System.IO.Path.Combine(path, name);
            if (System.IO.File.Exists(path))
            {
                System.IO.File.Create(path);
            }

            for (int i = 0; i < Labels.Count; i++)
            {
                System.IO.File.AppendAllText(filePath, Labels[i] + "\n");
            }
            foreach (List <double> item in DataSet)
            {
                for (int i = 0; i < item.Count - 1; i++)
                {
                    System.IO.File.AppendAllText(filePath, item[i].ToString() + ",");
                }
                System.IO.File.AppendAllText(filePath, item[item.Count - 1].ToString() + "\n");
            }

            SetContentView(Resource.Layout.Main);
            Intent intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
        }