Coder Social home page Coder Social logo

nrbf_haskell's Introduction

NRBF Neural Network using Haskell

NRBF Network Structure

Install

cabal install --enable-tests
cabal test

Usage

Import the NRBF data Preprocessor and Network:

import NRBF.Preprocess -- Optional, But NRBF.Network only accepts training data in DSet form
import NRBF.Network

Training data must be of type DSet

-- Network data types
type DInput     = [Double]              -- 1D input vector
type DOutput    = Double                -- Limited to 1D output for now
type DHidden    = [DInput]              -- Hidden nodes
type DWeights   = [Double]              -- Output weights
type DNet       = (DHidden, DWeights)   -- Network container (Hidden nodes, output weights)
type DRow       = (DInput, DOutput)     -- Training item (Input, Expected output)
type DSet       = [DRow]                -- List of training items

-- Dataset -> Iterations -> (Dnet, [RMS errors])
-- Use this to fit a function to your training data
fit :: DSet -> Int -> (DNet, [Double])

Example Program

Currently, only formats like test/data/TRAIN10X.DAT and test/data/gridwatch.2013-2014.csv are supported. The NRBF network supports N-dimensional inputs but is limited to 1 output (for now).

Example 1D input (TRAIN10X.DAT, function to approximate input/4):

test_fit_1d iterations = do
    train10x_s <- readFile "test//data//TRAIN10X.DAT"
    
    let
        traind10        = pre_xdata train10x_s
        train_result    = fit traind10 iterations -- Fit the network to the training data
        trained_net     = fst train_result

        in writeFile "output.csv" $ unlines $ map show $ map (\n -> predict [n] trained_net) [-1.0, -0.9 .. 5.0]

Example 3D input (gridwatch.2013-2014.csv):

test_fit3d iterations = do
    filec <- readFile $ "data//gridwatch.2013-2014.csv"
    
    let 
        out_data_hourly = preprocess_gridwatch_hour filec
        ttd             = split_70_30 out_data_hourly

        gridwatch_train = list_to_DSet $ fst ttd

        trained_result  = fit gridwatch_train iterations -- Fit the network to the training data
        trained_net     = fst trained_result
        trained_neth    = fst trained_net -- Hidden nodes
        trained_netw    = snd trained_net -- Weights
        
        -- 3D input test vector
        r               = [0.0, 0.05 .. 1.0]
        out_input       = [[x,y,z] | x <- r, y <- r, z <- r]

        in do
            putStrLn ("Number of hidden nodes: " ++ show (length trained_neth))
            -- Show predicted values of the test input vector
            writeFile "grbf_3d.csv" $ unlines $ map show $ map (\n -> predict n trained_net) out_input
            putStrLn "Done"

Example Outputs

TODO

nrbf_haskell's People

Contributors

bendl avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.