Reinforcement learning using Markov Decision Processes. For JS, written in C++.

Overview

Pavlov.js

About

Pavlov.js uses Markov Decision Processes to implement reinforcement learning. It is written in C++ and compiled to JavaScript. For more on reinforcement learning, check out Andrew Ng's notes.

Installation

npm install pavlovjs --save

Compilation

Simply run make. JavaScript code will be in the lib directory.

Example Usage

(we assume that the prize state automatically leads to a trap state which is never left)

var module = require('pavlovjs');

var pavlov = new module.Pavlov();

// transitions and rewards
pavlov.transition({ "state": "A", "action": "R", "state_": "B" });
pavlov.transition({ "state": "B", "action": "B", "state_": "D" });
pavlov.reward(0);

pavlov.transition({ "state": "A", "action": "B", "state_": "C" });
pavlov.transition({ "state": "C", "action": "R", "state_": "D" });
pavlov.transition({ "state": "D", "action": "B", "state_": "D" });
pavlov.transition({ "state": "D", "action": "R", "state_": "D" });
pavlov.reward(0);

pavlov.transition({ "state": "B", "action": "B", "state_": "D" });
pavlov.transition({ "state": "D", "action": "L", "state_": "C" });
pavlov.transition({ "state": "C", "action": "F", "state_": "A" });
pavlov.transition({ "state": "A", "action": "R", "state_": "B" });
pavlov.reward(0);

pavlov.transition({ "state": "C", "action": "R", "state_": "D" });
pavlov.transition({ "state": "D", "action": "F", "state_": "B" });
pavlov.transition({ "state": "B", "action": "L", "state_": "A" });
pavlov.transition({ "state": "A", "action": "L", "state_": "Prize" });
pavlov.reward(0);

pavlov.transition({ "state": "A", "action": "L", "state_": "Prize" });
pavlov.transition({ "state": "Prize", "action": "L", "state_": "Trap" });
pavlov.transition({ "state": "Trap", "action": "B", "state_": "Trap" });
pavlov.reward(1);

// learn from observations
pavlov.learn();

//policy
console.log(pavlov.action('A')); //L
console.log(pavlov.action('B')); //L
console.log(pavlov.action('C')); //F
console.log(pavlov.action('D')); //F

License

The MIT License (MIT)

Copyright (c) 2015 Nathan Epstein

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...

Defacement detection with deep learning

 Defacement detection with deep learning

In0ri is a defacement detection system utilizing a image-classification convolutional neural network. Introduction When monitoring a website, In0ri wi

Nov 30, 2022

This Repository consist of Daily learning JS, Assignments, coding challenge, projects, references, tutorial

This Repository consist of Daily learning JS, Assignments, coding challenge, projects, references, tutorial

💛 A Tour of JavaScript This Repository consist of Daily learning, Assignments, coding challenge, projects, references, tutorial. 👩‍💻 👨‍💻 alert(

Sep 7, 2022

JavaScript package for predictive data analysis and machine learning

scikit.js JavaScript package for predictive data analysis and machine learning. Generic math operations are powered by Tensorflowjs core layer. We are

Jan 6, 2023

An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

Javascript Frameworks Development Welcome to the world of Javascript Frameworks. An ongoing curated list of frameworks, books, articles, talks, screen

Jul 31, 2022

A learning guide for JavaScript programmers.

Table of Contents Awesome JavaScript 专题列表 基础 开发准备 推荐的书 源代码阅读 敏捷方法与工具 JavaScript ES6 Node.js 图书 最佳实践 风格指南 常用的Node Web框架 常用NPM工具模块 开发工具和库 Future Awesome

Dec 26, 2022

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more

Apache MXNet (incubating) for Deep Learning Apache MXNet is a deep learning framework designed for both efficiency and flexibility. It allows you to m

Jan 5, 2023

Repository for machine learning research.

Machine-Learning A simple project created with django containing links and a chatbot to demonstrate how Choice Coin can be used for eLearning #how to

Oct 21, 2022

This repo. contain some "Login page" , That I have made during learning and practicing HTML & CSS.

This repo. contain some

Login-Page This repo. contain some "Login page" , That I have made during learning and practicing HTML & CSS. Table of content: v1 v2 Objective and Re

Jan 28, 2022

Demo repo used in crash course for students learning web development.

Web Development Crash Course Hosted by Rubberdøk Preparation Following these steps prepares you to join the interactive React demo of the crash course

Sep 20, 2022
Comments
  • Join Slack Community: Briim - Machine Learning in JavaScript

    Join Slack Community: Briim - Machine Learning in JavaScript

    Hello @NathanEpstein and everyone else! I have seen that you don't have any Slack Group for your library. That's why I want to propose the BRIIM community as Slack Community for your library. I believe it would help people tons to discuss and learn from each other in an interactive chat.

    BRIIM, the Machine Learning in JS movement, tries to gather all developers using ML and ML related libraries in JS in one community. I believe it is great to learn from each other when using one library, but also to explore other libraries in the ML in JS ecosystem. So far, every library is its own little community. However, in order to make ML in JS a larger topic this year, I try to bring together all developers/communities with this movement.

    In the next days, I want to propose the community to other ML and ML related libraries too. It would be great to have you with us in order to strengthen the ML in JS movement in 2018 :) If you are more interested in my doings, please checkout this blog post. I hope the article shows that I mean it serious with BRIIM :) Thanks for considering to participate! If it doesn't work out, you can always leave the Slack Community. But I hope to bootstrap this community to make ML in JS happen in 2018. 🚀

    opened by rwieruch 1
Owner
Nathan Epstein
Nathan Epstein
javascript implementation of logistic regression/c4.5 decision tree

LearningJS: A Javascript Implementation of Logistic Regression and C4.5 Decision Tree Algorithms Author: Yandong Liu. Email: yandongl @ cs.cmu.edu Upd

Yandong Liu 67 Aug 19, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Team: Andrei Markov, Grigorii Fil, Adelina Kildeeva, Albert Khazipov

Syntax Tree Visualizer ?? Visualizer for JavaScript code into an abstract syntax tree and a parallel array representations. Description • Demo • How t

null 4 Sep 13, 2022
Parallel/concurrent async work, optionally using multiple threads or processes

parallel-park Parallel/concurrent async work, optionally using multiple processes Usage parallel-park exports two functions: runJobs and inChildProces

Lily Scott 10 Mar 1, 2022
An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.

v0.1.0 (experimental) An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript. Read the documentati

wes4m 32 Dec 27, 2022
The app's backend is written in Python (Flask) and for search it uses Elasticsearch. I used this app as candidate application for learning out how to build, run and deploy a multi-container environment (docker-compose).

foodtrucks-app-docker-compose The app's backend is written in Python (Flask) and for search it uses Elasticsearch. I used this app as candidate applic

Selçuk Şan 3 Oct 24, 2022
A Kaggle clone made using the Django framework as a learning project.

Mini Kaggle (Also known as data-platform) A Kaggle clone made using the Django framework as a learning project at Divar in the summer of 2021. This pr

Sina Kamali 3 Nov 1, 2022
An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

AWS Serverless Event Driven Twitter Bot An AWS Cloud Native application using CDK (Written in TypeScript) that defines a Serverless Event Driven appli

null 4 Dec 18, 2022