Git Product home page Git Product logo

webppl-csv's Introduction

webppl-csv

This package provides functions for reading and writing CSV files:

// Read data:
var testData = csv.read('data/test-file.csv');

// Write data:
csv.write('data/test-file-copy.csv', testData);

Distribution objects can be written to CSV using csv.writeJoint and csv.writeMarginals

var myJointDistribution = Infer({model: function(){
	var a = flip(0.5)
	var b = flip(0.9)
	return {a, b}
}})

// write distribution, maintaining joint distributional information
csv.writeJoint(myJointDistribution, 'data/test-joint.csv')

// write distribution, one variable per line (marginalized)
csv.writeMarginals(myJointDistribution, 'data/test-marginals.csv')

For more custom usage, use csv.open, csv.close, and csv.writeLine.

If you use the query.table with MCMC, try out csv.writeDistTable

Installation

To globally install webppl-csv, run:

mkdir -p ~/.webppl
npm install --prefix ~/.webppl webppl-csv

This may print warnings (npm WARN ENOENT...) which can be ignored.

To upgrade to the latest version, run:

npm install --prefix ~/.webppl webppl-csv --force

Usage

Once installed, you can make all csv. functions available to program.wppl by running:

webppl program.wppl --require webppl-csv

Testing

Run the included test using:

webppl test/test.wppl --require .

webppl-csv's People

Contributors

hawkrobe avatar mhtess 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.