Testing Waters
  • Scrapbook
  • Projects
    • Bamiyan Cultural Center
    • Bauhaus Museum
    • Better Hebbal
    • Bicycle Station
    • Cross Laminated Timber
    • Facade
    • Flowing Fabrication
    • Form from Images
    • Guggenheim Helsinki
    • National War Museum
    • National War Memorial
    • Indflorescence
    • Rectangular Compartments
    • Retail Space Layout
    • Noise Barrier : Swedevia Airport
    • Walden
    • Wilson Garden
  • Patterns
    • Area Graph
    • Array along Curve
    • Fibbonacci and Factorial
    • Gyroid
    • Hexagonal Pattern From Image
    • Hexagonal Grid
    • Koch Star
    • Mandelbrot Set
    • Pattern
    • Pattern
    • Pattern
    • Phyllotaxis
    • Random Strip Widths
    • Skewed Surface
    • Staggered Checkerboard
    • Triangle subdivision
    • Vector Field
    • Voronoi
    • Waves
    • Weave
  • Geometry
    • Boundary Curve
    • Bridging parallel curves
    • British Museum Great Court
    • Catenary
    • Delete Adjacent
    • Geodesic Sphere
    • Group Branching Curves
    • Group Circles
    • Group curves
    • K Mean
    • Nurbs Surface Irregular
    • Overlapping Petals
    • Pair Nearest
    • Parametric Shapes
    • Platonic Solids
    • Polyline to PolyArc
    • Roman Surface
    • Sagrada Familia Schools Roof
    • Sine Curve
    • Sine Ribbon
    • Spherical Transformations
    • Split Rectangle
    • Tangential Circle through Point
    • Travelling Salesman Problem
    • Unaligned Bounding Box
  • Lists
    • Alter by Boolean Sequence
    • Color by distance
    • Consecutive Points
    • Distancing
    • Divide Equally
    • Geometry from Image
    • Image based Point Density
    • Isovists
    • Reduce Color Palette
    • Replace Consecutive
    • Replace Multiple
    • Replace Recurring
    • Shadow Area
    • Shortest Path
    • Solar Analysis
    • Topography Analysis
  • Motion
    • Adjacency
    • Animate Sphere
    • Cellular Automation
    • Cloth
    • Hypotrochoid
    • Manakin
    • Rolling Spiral
    • Tan Curve
    • Trammel of Archemedes
    • Image to Integer
  • Articles
    • A Conceptual Approach to Integrating Computational Methods in Early Stage Design
    • Design Script's ambiguous and versatile Replication Guides <1>
    • Design Script's ambiguous and versatile Replication Guides <2>
Powered by GitBook
On this page
  1. Motion

Image to Integer

Basic Machine Learning in F# and Dynamo

PreviousTrammel of ArchemedesNextA Conceptual Approach to Integrating Computational Methods in Early Stage Design

Last updated 3 years ago

namespace integerImage
open System.IO
module integerML =
    type Example = {
        Label : int
        Pixels : int []
    }
    
    let readExamples path = 
        path
        |> File.ReadAllLines
        |> Array.map (fun line -> line.Split ',')
        |> Array.map (fun line -> line |> Array.map int)
        |> Array.map (fun line -> {Label = line.[0]; Pixels = line.[1..]} )

    let distance (img1 : int[]) (img2 : int[]) =
        Array.map2 (fun pix1 pix2 -> abs(pix1 - pix2)) img1 img2
        |> Array.sum
    
    let classify (img : int[]) = 
        let bestMatch =
                readExamples (__SOURCE_DIRECTORY__ + "/train.csv")
                |> Array.minBy (fun x -> distance x.Pixels img)
        bestMat
// Some codepublic class IntImg
{
    private IntImg() { }
    public static int intFrmImg(int[] tst)
    {
        return integerImage.integerML.classify(tst);
    }
}

Inspiration for the node and source of code
MNIST: 60,000 hand written number images
Training Set Source
Logo
90MB
ML.zip
archive