csharp using Accord.IO; using Accord.Imaging; var image = new ImageDecoder().Decode(@"path/to/image.jpg"); var grayscaleImage = new Grayscale(0, 255).Apply(image); var scaledImage = grayscaleImage.Resize(100, 100); csharp using Accord.MachineLearning.Text; string[] documents = { "This is the first document.", "This document is the second document.", "And this is the third one.", "Is this the first document?" }; var vectorizer = new TFIDF(); var matrix = vectorizer.Transform(documents); double[][] features = matrix.ToMatrix(); foreach (var feature in features) { Console.WriteLine(string.Join(", ", feature)); } csharp using Accord.MachineLearning; using Accord.MachineLearning.VectorMachines; using Accord.MachineLearning.VectorMachines.Learning; double[][] inputs = { new double[] { 0, 0 }, new double[] { 1, 0 }, new double[] { 0, 1 }, new double[] { 1, 1 }, }; int[] outputs = { -1, -1, -1, 1 }; var teacher = new SupportVectorMachine<Gaussian>(inputs: 2); double error = teacher.Run(inputs, outputs); Console.WriteLine("Training error: " + error); int prediction = teacher.Decide(new double[] { 1, 0 }); Console.WriteLine("Prediction: " + prediction); csharp using Accord.MachineLearning; using System.IO; var model = new KMeans(3); { new double[] { 1, 2, 3 }, new double[] { 4, 5, 6 }, new double[] { 7, 8, 9 } }; model.Learn(inputs); model.Save(Path.Combine("path/to/file.xml")); var loadedModel = KMeans.Load(Path.Combine("path/to/file.xml")); int[] predictions = loadedModel.Decide(inputs); Console.WriteLine(string.Join(", ", predictions)); csharp using Accord; using Accord.Statistics.Analysis; using Accord.Statistics.Visualizations; using Accord.IO; double[] data = new CsvReader("path/to/file.csv").ToDoubleMatrix().GetColumn(0); Histogram histogram = new Histogram(data, binCount: 10); HistogramChart plot = new HistogramChart(histogram); plot.Show(); csharp using Accord; using Accord.Statistics.Analysis; using Accord.Statistics.Visualizations; using Accord.IO; double[] x = new CsvReader("path/to/x.csv").ToDoubleMatrix().GetColumn(0); double[] y = new CsvReader("path/to/y.csv").ToDoubleMatrix().GetColumn(0); Scatterplot scatterplot = new Scatterplot("Data", "X", "Y"); scatterplot.Compute(x, y); ScatterplotBox plot = new ScatterplotBox(scatterplot); plot.Show();


上一篇:
下一篇:
切换中文