-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (47 loc) · 1.96 KB
/
Program.cs
File metadata and controls
57 lines (47 loc) · 1.96 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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using NeuralNetwork.Algorithms;
using NeuralNetwork.HelperTypes;
using NeuralNetwork.Networks;
using Newtonsoft.Json;
namespace NeuralNetwork
{
internal class Program
{
private static void Main(string[] args)
{
//var neuralNetwork = new XorNeuralNet();
//new GeneticAlgorithm(neuralNetwork);
//Console.WriteLine();
//new BackPropagation(neuralNetwork);
var fromFile = new List<Coord>();
const string filePath =
@"D:\Study\Семестр 8\Системы искусственного интеллекта\NeuralNetwork\NeuralNetwork\lat_lng.csv";
const string outFilePath = "out.json";
using (var file = new StreamReader(filePath, Encoding.Default))
{
while (!file.EndOfStream)
{
string[] line = file.ReadLine().Split(',');
var coord = new Coord(Double.Parse(line[0], CultureInfo.InvariantCulture),
Double.Parse(line[1], CultureInfo.InvariantCulture), -1);
fromFile.Add(coord);
}
}
var sofmNet = new SofmNet();
var sofm = new SelfOrganizingFeatureMaps(sofmNet, fromFile);
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Claster\t{0} have\t{1}\tcoordinates", i + 1,
sofm.CoordClast.Select(c => c).Where(c => c.Claster == i).ToList().Count);
}
List<SerializebleCoord> serializebleData = new List<SerializebleCoord>(sofm.CoordClast.ConvertAll(input => new SerializebleCoord(input)));
var jsonString = JsonConvert.SerializeObject(serializebleData, Formatting.Indented);
File.WriteAllText(outFilePath, jsonString);
}
}
}