From bf77ea937b80ff474f575df1a96b863d16f0c376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Maldonado=20S=C3=A1nchez?= Date: Thu, 2 Feb 2023 17:28:12 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adidas=20algunas=20etiquetas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testML/Program.cs | 43 +++++++++++++++++++++---------------- testML/S4i_SimularCruces.cs | 16 ++++++++------ testML/packages.config | 2 +- testML/testML.csproj | 2 +- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/testML/Program.cs b/testML/Program.cs index 220d83a..623b409 100644 --- a/testML/Program.cs +++ b/testML/Program.cs @@ -1,4 +1,7 @@ -using Microsoft.ML; +#define SIMULATION +#undef TEST_MODELS + +using Microsoft.ML; using Microsoft.ML.AutoML; using Microsoft.ML.Data; using Microsoft.ML.Trainers; @@ -31,7 +34,7 @@ namespace testML { XSSFWorkbook wb; //using (FileStream file = new FileStream(@"C:\Users\miguel.maldonado\Downloads\entrenar_IAMenos.xlsx", FileMode.Open, FileAccess.Read)) - using (FileStream file = new FileStream(@"C:\Users\miki_\Downloads\entrenar_IA_2.xlsx", FileMode.Open, FileAccess.Read)) + using (FileStream file = new FileStream(@"C:\Users\miguel.maldonado\Downloads\entrenar_IA.xlsx", FileMode.Open, FileAccess.Read)) { wb = new XSSFWorkbook(file); } @@ -136,9 +139,11 @@ namespace testML } } +#if SIMULATION + S4i_Simulador.S4i_SimularCruces.Run(tmpData); - - /*foreach (var key in firstRow.Keys) +#else + foreach (var key in firstRow.Keys) { if (key.StartsWith("DESCENDIENTE_S4i") || key.StartsWith("DESCENDIENTE_SNP")) @@ -170,7 +175,8 @@ namespace testML } } - }*/ + } +#endif Console.WriteLine(); Console.WriteLine("Press enter to Exit"); @@ -205,7 +211,7 @@ namespace testML var objectFilename = columnToPredict + "." + hash + ".dll"; - #endregion +#endregion MLContext mlContext = new MLContext(); @@ -237,16 +243,16 @@ namespace testML var loadMethodObj = loadMethod.MakeGenericMethod(classType); var data = (IDataView)loadMethodObj.Invoke(mlContext.Data, new object[] { dataConverted, null }); - #region Cortamos los datos de entrenamiento en (Datos para entenar y Datos para hacer el test de precisión) +#region Cortamos los datos de entrenamiento en (Datos para entenar y Datos para hacer el test de precisión) DataOperationsCatalog.TrainTestData dataSplit = mlContext.Data.TrainTestSplit(data, testFraction: 0.5); IDataView trainData = dataSplit.TrainSet; IDataView testData = dataSplit.TestSet; - #endregion +#endregion - #region Preparamos los datos de entrada y salida +#region Preparamos los datos de entrada y salida var columnNameAndTypes = new Dictionary(); @@ -317,14 +323,15 @@ namespace testML #endregion - /* - //Entrenamos el modelo - //ITransformer model = pipe.Fit(trainData); - #region Hacemos un test para medir el % de error +#if TEST_MODELS + //Entrenamos el modelo + //ITransformer model = pipe.Fit(trainData); - // Use trained model to make inferences on test data - IDataView testDataPredictions = result.Model.Transform(testData); +#region Hacemos un test para medir el % de error + + // Use trained model to make inferences on test data + IDataView testDataPredictions = result.Model.Transform(testData); // Extract model metrics and get RSquared RegressionMetrics trainedModelMetrics = mlContext.Regression.Evaluate(testDataPredictions, labelColumnName: columnInference.LabelColumnName); @@ -332,10 +339,10 @@ namespace testML Console.WriteLine("ModelMetrics: {0}", rSquared); - #endregion +#endregion - #region Ponemos a prueba haciendo algunas predicciones +#region Ponemos a prueba haciendo algunas predicciones var predictionFunction = mlContext.Model.CreatePredictionEngine(result.Model); @@ -350,7 +357,7 @@ namespace testML Console.WriteLine("Found: {0:#,##0.00}\tExpected: {1:#,##0.00}\t\tDiff: {2:#,##0.00}", p.IntegerNumber, expected, expected - p.IntegerNumber); } - #endregion +#endregion */ } diff --git a/testML/S4i_SimularCruces.cs b/testML/S4i_SimularCruces.cs index 40b3f3a..321e5fb 100644 --- a/testML/S4i_SimularCruces.cs +++ b/testML/S4i_SimularCruces.cs @@ -300,6 +300,8 @@ FROM CruceItem C"); #endregion + Console.WriteLine("Ready"); + Console.ReadLine(); var limit = individuos.Length * individuos.Length; var current = 0; @@ -401,16 +403,19 @@ FROM CruceItem C"); var files = Directory.GetFiles("Modelos", "*.zip").OrderBy(x => x).ToArray(); for (var c = 0; c < files.Length; c++) - { - count++; - //if (count > 5) break; - + { var filename = files[c]; - var name = Path.GetFileNameWithoutExtension(filename); var matchName = columnByModelName.Match(name); + if(!matchName.Success ) + { + continue; + } + + count++; + if (count > 10) break; Console.Write(string.Format("{0}/{1} Loading: {2}... ", c + 1, files.Length, matchName.Groups[1].Value)); @@ -450,7 +455,6 @@ FROM CruceItem C"); Console.WriteLine(); } - return result; } diff --git a/testML/packages.config b/testML/packages.config index 131b3c3..ae3dbee 100644 --- a/testML/packages.config +++ b/testML/packages.config @@ -33,7 +33,7 @@ - + diff --git a/testML/testML.csproj b/testML/testML.csproj index adf89fa..343bcc3 100644 --- a/testML/testML.csproj +++ b/testML/testML.csproj @@ -57,7 +57,7 @@ - ..\..\..\..\..\..\Desarrollo\SQLiteUtilities\SQLiteUtilities\bin\Debug\FFSoft.SQLiteUtilities.dll + ..\..\SQLiteUtilities\SQLiteUtilities\bin\Debug\FFSoft.SQLiteUtilities.dll ..\packages\Google.Protobuf.3.21.9\lib\net45\Google.Protobuf.dll