private static void TestSinglePrediction(MLContext mLContext) { var areaCalcSample = new AreaCalc() { //21,70,58,55,59,167 temperature = 21, floor1 = 70, floor2 = 58, floor3 = 55, floor4 = 59, areaEvaluated = 0 }; ITransformer trainedModel; using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { trainedModel = mLContext.Model.Load(stream); } var predEngine = trainedModel.CreatePredictionEngine <AreaCalc, AreaCalcPrediction>(mLContext); var resultprediction = predEngine.Predict(areaCalcSample); System.Console.WriteLine("+++++++++++++++++++++++++++++++++++"); System.Console.WriteLine($"+++++Predicted Area population amount {resultprediction.AreaCalcAmount:0}+++ Actual fare: ? +++++++++++++++++++++++++++"); System.Console.WriteLine("+++++++++++++++++++++++++++++++++++"); }
public float TestSinglePrediction(float valTemp, float valFloor1, float valFloor2, float valFloor3, float valFloor4) { //1 hay q definir el MLContext ? cuando se pasa de from a form? //hay q decidir como se carga el modelo>? var areaCalcSample = new AreaCalc() { //21,70,58,55,59,167 temperature = valTemp, floor1 = valFloor1, floor2 = valFloor2, floor3 = valFloor3, floor4 = valFloor4, areaEvaluated = 0 }; ITransformer trainedModel; using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { trainedModel = mlContext.Model.Load(stream); } var predEngine = trainedModel.CreatePredictionEngine <AreaCalc, AreaCalcPrediction>(mlContext); var resultprediction = predEngine.Predict(areaCalcSample); //System.Console.WriteLine($"+++++Predicted Area population amount {resultprediction.AreaCalcAmount:0}+++ Actual fare: ? +++++++++++++++++++++++++++"); return(resultprediction.AreaCalcAmount); }
public void CalcTest() { Mock <IRectangle> mockRectangle = new Mock <IRectangle>(); mockRectangle.SetupGet(m => m.SideA).Returns(1); mockRectangle.SetupGet(m => m.SideB).Returns(2); AreaCalc areaCalc = new AreaCalc(); Assert.True(areaCalc.Calc(mockRectangle.Object) == 2, "Area is incorrect."); Assert.Throws <ArgumentNullException>(() => areaCalc.Calc(null)); }
public void app() { Dictionary <string, Figure> figures = new Dictionary <string, Figure>(); AreaCalc areaCalc = new AreaCalc(); string num; string ans; //For adding new figure add new element to dictionary figures figures.Add("1", new Figure() { figure = "circle", num_side = 1, func = areaCalc.circle_area }); figures.Add("2", new Figure() { figure = "triangle", num_side = 3, func = areaCalc.triangle_area }); Console.WriteLine("This program calculate geometric figures area"); while (true) { Console.WriteLine("Choose type of figure"); foreach (var el in figures) { Console.WriteLine(el.Key + " - " + el.Value.figure); } Console.WriteLine("0 - exit"); Console.WriteLine("If you will keep this field empty, than program will try to define it:"); num = Console.ReadLine(); if (num == "0") { Console.WriteLine("Thanks for using! Bye!"); break; } figureChoise(num, figures); Console.WriteLine("-----------------------------------------"); while (true) { Console.WriteLine("Do you want to calculate something else? (y/n): "); ans = Console.ReadLine(); if (ans == "n") { Console.WriteLine("Thanks for using! Bye!"); return; } if (ans == "y") { break; } Console.WriteLine("Sorry, but you need to decide!"); } } }
bool TestEqual(double[] arg, double eq) { double area; try { area = AreaCalc.area(arg); } catch (ArgumentException e) { Console.WriteLine(e.Message); return(false); } Console.WriteLine("Calculated area: {0}", area); return(area == eq); }
public void CalcArea_circle_radius1_Pireturned() { // arrange double radius = 1.0; double expected = 3.142; Figure circle = new Circle(radius); // act AreaCalc areaCalc = new AreaCalc(); double actual = areaCalc.Calculate(circle); //assert Assert.AreEqual(expected, actual); }
public void CalcArea_triangle_a10_b10_c10_43returned() { // arrange double a = 10.0; double b = 10.0; double c = 10.0; double expected = 43.301; Figure triangle = new Triangle(a, b, c); // act AreaCalc areaCalc = new AreaCalc(); double actual = areaCalc.Calculate(triangle); //assert Assert.AreEqual(expected, actual); }
/* * o princípio OCP - Open Closed Principle, o Princípio do Aberto Fechado, o segundo da categoria SOLID. Este padrão indica que uma classe deve ser fechada * para modificação e aberta para expansão, a fim de tornar a mesma mais fácil de ser evoluída. */ public void OCP() { var ret1 = new Retangulo() { Altura = 10, Largura = 10 }; var ret2 = new Retangulo() { Altura = 20, Largura = 20 }; var circ1 = new Circulo() { Raio = 20 }; FormaGeometrica[] formas = { ret1, ret2, circ1 }; var calc = new AreaCalc(); var area = calc.CalcularArea(formas); Console.WriteLine(area); Console.ReadLine(); }