-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
98 lines (82 loc) · 2.67 KB
/
Program.cs
File metadata and controls
98 lines (82 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Linq;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Core.Drawing;
using OxyPlot.Series;
namespace ml {
class Program {
static void Main(string[] args) {
//ml_func_tests.test_matrix_norm();
exercise4.test_nn();
//exercise4.test_debug_nn();
//exercise4.test_flatten_unflatten();
//ml_func_tests.run_all_tests();
// var outputToFile = "./images/ex1.png";
// var width = 1024;
// var height = 768;
// var background = OxyColors.LightGray;
// var resolution = 96d;
// var model = exercise1.plot_data1();
// // export to file using static methods
// PngExporter.Export(model, outputToFile, width, height, background, resolution);
}
private static void test_transpose() {
var matrix = ml_funcs.matrix_create(10, 20, 0);
var trasponse_matrix = ml_funcs.matrix_transpose(matrix);
}
private static IPlotModel build_scatter() {
var model = new PlotModel { Title = "ScatterSeries" };
var scatterSeries = new ScatterSeries { MarkerType = MarkerType.Cross };
var r = new Random(314);
for (int i = 0; i < 100; i++)
{
var x = r.NextDouble();
var y = r.NextDouble();
var size = 5;
var colorValue = r.Next(0, 10);
scatterSeries.Points.Add(new ScatterPoint(x, y, size, 5));
}
model.Series.Add(scatterSeries);
model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Hue(10) });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 80});
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10});
return model;
}
private static IPlotModel BuildPlotModel() {
var rand = new Random(21);
var model = new PlotModel { Title = "Cake Type Popularity" };
var cakePopularity = Enumerable.Range(1, 5).Select(i => rand.NextDouble()).ToArray();
var sum = cakePopularity.Sum();
var barItems = cakePopularity.Select(cp => RandomBarItem(cp, sum)).ToArray();
var barSeries = new BarSeries
{
ItemsSource = barItems,
LabelPlacement = LabelPlacement.Base,
LabelFormatString = "{0:.00}%"
};
model.Series.Add(barSeries);
model.Axes.Add(new CategoryAxis
{
Position = AxisPosition.Left,
Key = "CakeAxis",
ItemsSource = new[]
{
"Apple cake",
"Baumkuchen",
"Bundt Cake",
"Chocolate cake",
"Carrot cake"
}
});
return model;
}
private static BarItem RandomBarItem(double cp, double sum)
=> new BarItem { Value = cp / sum * 100, Color = RandomColor() };
private static OxyColor RandomColor()
{
var r = new Random();
return OxyColor.FromRgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
}
}
}