Supervised Learning

In supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.

Supervised learning problems are categorized into "regression" and "classification" problems. In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying to map input variables to some continuous function. In a classification problem, we are instead trying to predict results in a discrete output. In other words, we are trying to map input variables into discrete categories.

Example 1:

Given data about the size of houses on the real estate market, try to predict their price. Price as a function of size is a continuous output, so this is a regression problem.

We could turn this example into a classification problem by instead making our output about whether the house "sells for more or less than the asking price." Here we are classifying the houses based on price into two discrete categories.

Example 2:

(a) Regression - Given a picture of a person, we have to predict their age on the basis of the given picture

(b) Classification - Given a patient with a tumor, we have to predict whether the tumor is malignant or benign.

Arthur Samuel의 머신러닝 정의

- 최초의 머신러닝 기반 체커게임을 만든 사람.

  • 컴퓨터가 명시적(explicit) 프로그램 없이도 스스로 학습할 수 있는 것.

 

Tom Michell의 머신러닝 정의

- Carnegi Mellon 대학교 교수

  • 학습과제(well-posed learning problem) 중심으로 정의
  • 프로그램이 일정 수준의 작업 성능(P)을 가지고 작업(T)을 수행한다고 했을 때 경험(E)이 증가함에 따라 작업(T)를 수행하는 성능(P)이 향상될 때 이 프로그램이 경험(E)으로부터 학습(learn)을 했다고 표현함.

 

원인

해당 에러코드의 해결책은 ML.NET 이미지 분류 튜토리얼 코드에만 한정된다.

다른 해결책은 이 링크를 참조하면 좋다. (https://creon.tistory.com/540)

 

Microsoft.ML.TensorFlow.Redist 패키지가 설치되지 않아서 발생한 문제.


해결책

 

  1. 도구 > Nuget 패키지 관리자 > 솔루션용 Nuget 패키기 관리... 클릭
  2. 찾아보기 탭에서 Microsoft.ML.TensorFlow.Redist 검색
  3. 최신버전 설치

 

 

원인

Microsoft.ML.TensorFlow 패키지가 설치되지 않아서 발생한 문제.


해결책

 

  1. 도구 > Nuget 패키지 관리자 > 솔루션용 Nuget 패키기 관리... 클릭
  2. 찾아보기 탭에서 Microsoft.ML.TensorFlow 검색
  3. 최신버전 설치

 

Error 문장

원인

Microsoft.ML.ImageAnalytics 패키지가 설치되지 않아서 발생한 문제.


해결책

  1. 도구 > Nuget 패키지 관리자 > 솔루션용 Nuget 패키기 관리... 클릭
  2. 찾아보기 탭에서 Microsoft.ML.ImageAnalytics 검색
  3. 최신버전 설치

참조

https://blog.hompus.nl/2020/06/11/unable-to-find-an-entry-point-named-ortgetapibase-in-dll-onnxruntime-with-microsoft-ml-onnxtransformer-1-5-0/

Accord.NET framework은 171가지의 이미지 필터링을 제공하고 있으며 그 목록은 다음과 같다. 


ClassDescription
Public classAdaptiveSmoothing
Adaptive Smoothing - noise removal with edges preserving.
Public classAdd
Add fillter - add pixel values of two images.
Public classAdditiveNoise
Additive noise filter.
Public classApplyMask
Apply mask to the specified image.
Public classBackwardQuadrilateralTransformation
Performs backward quadrilateral transformation into an area in destination image.
Public classBaseFilter
Base class for filters, which produce new image of the same size as a result of image processing.
Public classBaseFilter2
Base class for filters, which operate with two images of the same size and format and produce new image as a result.
Public classBaseInPlaceFilter
Base class for filters, which may be applied directly to the source image.
Public classBaseInPlaceFilter2
Base class for filters, which operate with two images of the same size and format and may be applied directly to the source image.
Public classBaseInPlacePartialFilter
Base class for filters, which may be applied directly to the source image or its part.
Public classBaseResizeFilter
Base class for image resizing filters.
Public classBaseRotateFilter
Base class for image rotation filters.
Public classBaseTransformationFilter
Base class for filters, which may produce new image of different size as a result of image processing.
Public classBaseUsingCopyPartialFilter
Base class for filters, which require source image backup to make them applicable to source image (or its part) directly.
Public classBayerDithering
Ordered dithering using Bayer matrix.
Public classBayerFilter
Generic Bayer fileter image processing routine.
Public classBayerFilterOptimized
Optimized Bayer fileter image processing routine.
Public classBilateralSmoothing
Bilateral filter implementation - edge preserving smoothing and noise reduction that uses chromatic and spatial factors.
Public classCode exampleBinaryDilation3x3
Binary dilation operator from Mathematical Morphology with 3x3 structuring element.
Public classBinaryErosion3x3
Binary erosion operator from Mathematical Morphology with 3x3 structuring element.
Public classCode exampleBinaryWatershed
Watershed filter.
Public classCode exampleBlend
Linear Gradient Blending filter.
Public classBlobsFiltering
Blobs filtering by size.
Public classBlur
Blur filter.
Public classBottomHat
Bottop-hat operator from Mathematical Morphology.
Public classBradleyLocalThresholding
Adaptive thresholding using the internal image.
Public classBrightnessCorrection
Brightness adjusting in RGB color space.
Public classBurkesDithering
Dithering using Burkes error diffusion.
Public classCannyEdgeDetector
Canny edge detector.
Public classCanvasCrop
Fill areas outiside of specified region.
Public classCanvasFill
Fill areas iniside of the specified region.
Public classCanvasMove
Move canvas to the specified point.
Public classChannelFiltering
Channels filters.
Public classClosing
Closing operator from Mathematical Morphology.
Public classColorFiltering
Color filtering.
Public classColorRemapping
Color remapping.
Public classCombineChannel
Combine channel filter.
Public classCompassConvolution
Compass convolution filter.
Public classConcatenate
Concatenation filter.
Public classConnectedComponentsLabeling
Connected components labeling.
Public classConservativeSmoothing
Conservative smoothing.
Public classContrastCorrection
Contrast adjusting in RGB color space.
Public classContrastStretch
Contrast stretching filter.
Public classConvolution
Convolution filter.
Public classCornersMarker
Filter to mark (highlight) corners of objects.
Public classCrop
Crop an image.
Public classDifference
Difference filter - get the difference between overlay and source images.
Public classDifferenceEdgeDetector
Difference edge detector.
Public classCode exampleDifferenceOfGaussians
Difference of Gaussians filter.
Public classDilation
dilation operator from Mathematical Morphology.
Public classDilation3x3
dilation operator from Mathematical Morphology with 3x3 structuring element.
Public classCode exampleDistanceTransform
Distance transform filter.
Public classDivide
Divide filter - divide pixel values of two images.
Public classEdges
Simple edge detector.
Public classErosion
Erosion operator from Mathematical Morphology.
Public classErosion3x3
Erosion operator from Mathematical Morphology with 3x3 structuring element.
Public classErrorDiffusionDithering
Base class for error diffusion dithering.
Public classErrorDiffusionToAdjacentNeighbors
Base class for error diffusion dithering, where error is diffused to adjacent neighbor pixels.
Public classEuclideanColorFiltering
Euclidean color filtering.
Public classCode exampleExponential
Exponential filter.
Public classExtractBiggestBlob
Extract the biggest blob from image.
Public classExtractChannel
Extract RGB channel from image.
Public classExtractNormalizedRGBChannel
Extract normalized RGB channel from color image.
Public classFastBoxBlur
Fast Box Blur filter.
Public classFastGuidedFilter
Fast Guided Filter (non-commercial).
Public classCode exampleFastVariance
Fast Variance filter.
Public classFeaturesMarker
Filter to mark (highlight) feature points in a image.
Public classFillHoles
Fill holes in objects in binary image.
Public classFilterIterator
Filter iterator.
Public classFiltersSequence
Filters' collection to apply to an image in sequence.
Public classFlatFieldCorrection
Flat field correction filter.
Public classFloydSteinbergDithering
Dithering using Floyd-Steinberg error diffusion.
Public classCode exampleGaborFilter
Gabor filter.
Public classGammaCorrection
Gamma correction filter.
Public classGaussianBlur
Gaussian blur filter.
Public classGaussianSharpen
Gaussian sharpen filter.
Public classGrayscale
Base class for image grayscaling.
Public classGrayscale.CommonAlgorithms
Set of predefined common grayscaling algorithms, which have already initialized grayscaling coefficients.
Public classGrayscaleBT709Obsolete.
Grayscale image using BT709 algorithm.
Public classGrayscaleRMYObsolete.
Grayscale image using R-Y algorithm.
Public classGrayscaleToRGB
Convert grayscale image to RGB.
Public classGrayscaleYObsolete.
Grayscale image using Y algorithm.
Public classCode exampleGrayWorld
Gray World filter for color normalization.
Public classHighBoost
High boost filter.
Public classHistogramEqualization
Histogram equalization filter.
Public classHitAndMiss
Hit-And-Miss operator from Mathematical Morphology.
Public classHomogenityEdgeDetector
Homogenity edge detector.
Public classHorizontalRunLengthSmoothing
Horizontal run length smoothing algorithm.
Public classHSLFiltering
Color filtering in HSL color space.
Public classHSLLinear
Luminance and saturation linear correction.
Public classHueModifier
Hue modifier.
Public classImageWarp
Image warp effect filter.
Public classIntersect
Intersect filter - get MIN of pixels in two images.
Public classInvert
Invert image.
Public classIterativeThreshold
Iterative threshold search and binarization.
Public classJarvisJudiceNinkeDithering
Dithering using Jarvis, Judice and Ninke error diffusion.
Public classJitter
Jitter filter.
Public classCode exampleKirschEdgeDetector
Kirsch's Edge Detector
Public classCode exampleKuwahara
Kuwahara filter.
Public classLevelsLinear
Linear correction of RGB channels.
Public classLevelsLinear16bpp
Linear correction of RGB channels for images, which have 16 bpp planes (16 bit gray images or 48/64 bit colour images).
Public classLineMarker
Filter to mark (highlight) lines in a image.
Public classCode exampleLogarithm
Log filter.
Public classMaskedFilter
Apply filter according to the specified mask.
Public classMean
Mean filter.
Public classMedian
Median filter.
Public classMerge
Merge filter - get MAX of pixels in two images.
Public classMirror
Mirroring filter.
Public classMorph
Morph filter.
Public classMoveTowards
Move towards filter.
Public classMultiply
Multiply filter - multiply pixel values of two images.
Public classCode exampleNiblackThreshold
Niblack Threshold.
Public classOilPainting
Oil painting filter.
Public classOpening
Opening operator from Mathematical Morphology.
Public classOrderedDithering
Binarization with thresholds matrix.
Public classOtsuThreshold
Otsu thresholding.
Public classPairsMarker
Filter to mark (highlight) pairs of points in a image.
Public classPixellate
Pixellate filter.
Public classPointedColorFloodFill
Flood filling with specified color starting from specified point.
Public classPointedMeanFloodFill
Flood filling with mean color starting from specified point.
Public classCode examplePointsMarker
Filter to mark (highlight) points in a image.
Public classQuadrilateralTransformation
Performs quadrilateral transformation of an area in a given source image.
Public classQuadrilateralTransformationBilinearObsolete.
Performs quadrilateral transformation using bilinear algorithm for interpolation.
Public classQuadrilateralTransformationNearestNeighborObsolete.
Performs quadrilateral transformation using nearest neighbor algorithm for interpolation.
Public classRectanglesMarker
Filter to mark (highlight) rectangles in a image.
Public classRectification
Rectification filter for projective transformation.
Public classReplaceChannel
Replace RGB channel of color imgae.
Public classResizeBicubic
Resize image using bicubic interpolation algorithm.
Public classResizeBilinear
Resize image using bilinear interpolation algorithm.
Public classResizeNearestNeighbor
Resize image using nearest neighbor algorithm.
Public classRGChromacity
RG Chromaticity.
Public classCode exampleRobinsonEdgeDetector
Robinson's Edge Detector
Public classRotateBicubic
Rotate image using bicubic interpolation.
Public classRotateBilinear
Rotate image using bilinear interpolation.
Public classRotateChannels
Rotate RGB channels.
Public classRotateNearestNeighbor
Rotate image using nearest neighbor algorithm.
Public classSaltAndPepperNoise
Salt and pepper noise.
Public classSaturationCorrection
Saturation adjusting in HSL color space.
Public classCode exampleSauvolaThreshold
Sauvola Threshold.
Public classSepia
Sepia filter - old brown photo.
Public classSharpen
Sharpen filter
Public classShrink
Shrink an image by removing specified color from its boundaries.
Public classSierraDithering
Dithering using Sierra error diffusion.
Public classSimplePosterization
Simple posterization of an image.
Public classSimpleQuadrilateralTransformation
Performs quadrilateral transformation of an area in the source image.
Public classSimpleSkeletonization
Simple skeletonization filter.
Public classSISThreshold
Threshold using Simple Image Statistics (SIS).
Public classSobelEdgeDetector
Sobel edge detector.
Public classStereoAnaglyph
Stereo anaglyph filter.
Public classStuckiDithering
Dithering using Stucki error diffusion.
Public classSubtract
Subtract filter - subtract pixel values of two images.
Public classTexturedFilter
Textured filter - filter an image using texture.
Public classTexturedMerge
Merge two images using factors from texture.
Public classTexturer
Texturer filter.
Public classThreshold
Threshold binarization.
Public classThresholdedDifference
Calculate difference between two images and threshold it.
Public classThresholdedEuclideanDifference
Calculate Euclidean difference between two images and threshold it.
Public classThresholdWithCarry
Threshold binarization with error carry.
Public classTopHat
Top-hat operator from Mathematical Morphology.
Public classTransformFromPolar
Transform polar image into rectangle.
Public classTransformToPolar
Transform rectangle image into circle (to polar coordinates).
Public classCode exampleVariance
Variance filter.
Public classVerticalRunLengthSmoothing
Vertical run length smoothing algorithm.
Public classWaterWave
Simple water wave effect filter.
Public classCode exampleWaveletTransform
Wavelet transform filter.
Public classCode exampleWhitePatch
White Patch filter for color normalization.
Public classCode exampleWolfJolionThreshold
Wolf Jolion Threshold.
Public classYCbCrExtractChannel
Extract YCbCr channel from image.
Public classYCbCrFiltering
Color filtering in YCbCr color space.
Public classYCbCrLinear
Linear correction of YCbCr channels.
Public classYCbCrReplaceChannel
Replace channel of YCbCr color space.
Public classZhangSuenSkeletonization
Zhang-Suen skeletonization filter.


이 필터들은 .NET Standard 2.0  .NET Core 2.0 에 완벽하게 호환 제공되고 있다.

이 필터들을 사용하기 위해서는 단순히

using Accord.Imaging.Filters;

을 네임스페이스 위에 삽입하여 사용하면 된다.


예제코드(가우시안 블러 사용 예제)

using System;
using System.Drawing;

using Accord.Imaging.Filters;
using Accord.DataSets;

					
public class Program
{
    public static void Main()
    {
        TestImages t = new TestImages();
        Bitmap baboon = t.GetImage("baboon.bmp");
		
        // We can create a new Gaussian Blur:
        GaussianBlur blur = new GaussianBlur();
        
        // Now we can either apply it to the image, creating a
        // new resulting image to hold the output of the filter:
        Bitmap result = blur.Apply(baboon);
        
        // Or we can apply the operation in place,
        // overwriting the original image:
        blur.ApplyInPlace(baboon);
    }
}



Accord.NET은 C#으로만 작성된 .NET framework로써 선형 대수학, 수치 최적화, 통계학, 머신러닝, 인공 신경망, 신호 및 영상처리 등을 처리할 수 있으며  Gnu Lesser Public License 을 따른다.

설치는 다음과 같다.

Visual Studio의 프로젝트를 시작한 후 NuGet Package를 열고 아래 인스톨 명령을 실행한다.

    PM> Install-Package Accord.MachineLearning
    PM> Install-Package Accord.Controls

설치가 완료되면 이제 Accord.NET을 쓸 준비가 된 것이다.


예제코드

using Accord.Controls;
using Accord.MachineLearning.VectorMachines.Learning;
using Accord.Math.Optimization.Losses;
using Accord.Statistics;
using Accord.Statistics.Kernels;
using System;

namespace GettingStarted
{
    class Program
    {
        [MTAThread]
        static void Main(string[] args)
        {
            double[][] inputs =
            {
                /* 1.*/ new double[] { 0, 0 },
                /* 2.*/ new double[] { 1, 0 }, 
                /* 3.*/ new double[] { 0, 1 }, 
                /* 4.*/ new double[] { 1, 1 },
            };

            int[] outputs =
            { 
                /* 1. 0 xor 0 = 0: */ 0,
                /* 2. 1 xor 0 = 1: */ 1,
                /* 3. 0 xor 1 = 1: */ 1,
                /* 4. 1 xor 1 = 0: */ 0,
            };

            // Create the learning algorithm with the chosen kernel
            var smo = new SequentialMinimalOptimization<Gaussian>()
            {
                Complexity = 100 // Create a hard-margin SVM 
            };

            // Use the algorithm to learn the svm
            var svm = smo.Learn(inputs, outputs);

            // Compute the machine's answers for the given inputs
            bool[] prediction = svm.Decide(inputs);

            // Compute the classification error between the expected 
            // values and the values actually predicted by the machine:
            double error = new AccuracyLoss(outputs).Loss(prediction);

            Console.WriteLine("Error: " + error);

            // Show results on screen 
            ScatterplotBox.Show("Training data", inputs, outputs);
            ScatterplotBox.Show("SVM results", inputs, prediction.ToZeroOne());

            Console.ReadKey();
        }
    }
}



+ Recent posts