All Projects → vsoch → regression-wasm

vsoch / regression-wasm

Licence: other
Testing doing basic regression with web assembly

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to regression-wasm

portfolio
My Portfolio
Stars: ✭ 17 (-46.87%)
Mutual labels:  web-assembly
sparsereg
a collection of modern sparse (regularized) linear regression algorithms.
Stars: ✭ 55 (+71.88%)
Mutual labels:  linear-regression
bruceR
📦 BRoadly Useful Convenient and Efficient R functions that BRing Users Concise and Elegant R data analyses.
Stars: ✭ 110 (+243.75%)
Mutual labels:  linear-regression
machine learning course
Artificial intelligence/machine learning course at UCF in Spring 2020 (Fall 2019 and Spring 2019)
Stars: ✭ 47 (+46.88%)
Mutual labels:  linear-regression
mathematics-statistics-for-data-science
Mathematical & Statistical topics to perform statistical analysis and tests; Linear Regression, Probability Theory, Monte Carlo Simulation, Statistical Sampling, Bootstrapping, Dimensionality reduction techniques (PCA, FA, CCA), Imputation techniques, Statistical Tests (Kolmogorov Smirnov), Robust Estimators (FastMCD) and more in Python and R.
Stars: ✭ 56 (+75%)
Mutual labels:  linear-regression
ML-Experiments
整理记录本人担任课程助教设计的四个机器学习实验,主要涉及简单的线性回归、朴素贝叶斯分类器、支持向量机、CNN做文本分类。内附实验指导书、讲解PPT、参考代码,欢迎各位码友讨论交流。
Stars: ✭ 85 (+165.63%)
Mutual labels:  linear-regression
dotnet-opa-wasm
Call Open Policy Agent (OPA) policies in WASM (Web Assembly) from .NET Core
Stars: ✭ 36 (+12.5%)
Mutual labels:  web-assembly
machine-learning-implemetation-python
Basic Machine Learning implementation with python
Stars: ✭ 51 (+59.38%)
Mutual labels:  linear-regression
Machine-Learning-Notebooks
15+ Machine/Deep Learning Projects in Ipython Notebooks
Stars: ✭ 66 (+106.25%)
Mutual labels:  linear-regression
srqm
An introductory statistics course for social scientists, using Stata
Stars: ✭ 43 (+34.38%)
Mutual labels:  linear-regression
pyloess
A simple implementation of the LOESS algorithm using numpy
Stars: ✭ 44 (+37.5%)
Mutual labels:  linear-regression
hdnom
Benchmarking and Visualization Toolkit for Penalized Cox Models
Stars: ✭ 36 (+12.5%)
Mutual labels:  linear-regression
BCES
Python module for performing linear regression for data with measurement errors and intrinsic scatter
Stars: ✭ 56 (+75%)
Mutual labels:  linear-regression
node-seal
Homomorphic Encryption for TypeScript or JavaScript - Microsoft SEAL
Stars: ✭ 139 (+334.38%)
Mutual labels:  web-assembly
GDLibrary
Matlab library for gradient descent algorithms: Version 1.0.1
Stars: ✭ 50 (+56.25%)
Mutual labels:  linear-regression
Machine-Learning
🌎 I created this repository for educational purposes. It will host a number of projects as part of the process .
Stars: ✭ 38 (+18.75%)
Mutual labels:  linear-regression
Machine-Learning-Models
In This repository I made some simple to complex methods in machine learning. Here I try to build template style code.
Stars: ✭ 30 (-6.25%)
Mutual labels:  linear-regression
ml-models
Machine Learning Procedures and Functions for Neo4j
Stars: ✭ 63 (+96.88%)
Mutual labels:  linear-regression
ClassifierToolbox
A MATLAB toolbox for classifier: Version 1.0.7
Stars: ✭ 72 (+125%)
Mutual labels:  linear-regression
seeder
Set up Seed app and start dev server by running one command
Stars: ✭ 44 (+37.5%)
Mutual labels:  web-assembly

Regression Wasm

This repository serves a simple web assembly (wasm) application to perform a regression, using data from a table in the browser, which can be loaded as a delimited file by the user. We use a simple regression library to do the work. See the demo here or continue reading.

Summary

  • Run a multiple or single regression using Web Assembly
  • Two variables (one predictor, one regression) will generate a line plot showing X vs. Y and predictions
  • More than two variables (one predictor, multiple regressors) performs multiple regression to generate a residual histogram
  • Upload your own data file, change the delimiter, the file name to be saved, or the predictor column

Overview

When you load the page, you are presented with a loaded data frame. The data is a bit dark, but it's a nice dataset to show how this works. The first column is the number of murders (per million habitants) for some city, and each of the remaining columns are variables that might be used to predict it (inhabitants, percent with incomes below $5000, and percent unemployed). This is what you see:

img/basics.png

Formula

The formula for our regression model is shown below the plot, in human friendly terms.

Predicted = -36.7649 + Inhabitants*0.0000 + Percent with incomes below $5000*1.1922 + Percent unemployed*4.7198

Residual Plot

Given that we have more than one regressor variable, we need to run a multiple regression, and so the plot in the upper right is a histogram of the residuals.

the residuals are the difference between the actual values (number of murders per million habitants) and the values predicted by our model.

Filtering

If you remove any single value from a row, it invalidates it, and it won't be included in the plot. If you remove a column heading, it's akin to removing the entire column.

Line Plot

But what if we want to plot the relationship between one of the variables X, and our Y? This is where the tool gets interesting! By removing a column header, we essentially remove the column from the dataset. Let's first try removing just one, Inhabitants:

img/remove1.png

We still see a residual plot because it would require more than two dimensions to plot. Let's remove another one, the percent unemployed:

img/line-plot.png

Now we see a line plot, along with the plotting of the predictions! By simply removing each column one at a time (and leaving only one Y, and one X) we are actually running a single regression, and we can do this for each variable:

Inhabitants to predict murders

img/inhabitants-predict-murders.png


Unemployment to predict murders

img/unemployment-predict-murders.png


Low Income Percentage to predict murders

img/incomes-predict-murders.png

As we can see, the number of inhabitants (on its own) is fairly useless. The variables that are strongest here are unemployment and income.

Download Data

This of course is a very superficial overview, you would want to download the full model data to get more detail: The "Download Results" will appear after you generate any kind of plot, and it downloads a text file with the model output. Here is an example:

Dinosaur Regression Wasm
Predicted = -36.7649 + Inhabitants*0.0000 + Percent with incomes below $5000*1.1922 + Percent unemployed*4.7198
Murders per annum per one million inhabitants|	Inhabitants|	Percent with incomes below $5000|	Percent unemployed
11.20|	587000.00|	16.50|	6.20
13.40|	643000.00|	20.50|	6.40
40.70|	635000.00|	26.30|	9.30
5.30|	692000.00|	16.50|	5.30
24.80|	1248000.00|	19.20|	7.30
12.70|	643000.00|	16.50|	5.90
20.90|	1964000.00|	20.20|	6.40
35.70|	1531000.00|	21.30|	7.60
8.70|	713000.00|	17.20|	4.90
9.60|	749000.00|	14.30|	6.40
14.50|	7895000.00|	18.10|	6.00
26.90|	762000.00|	23.10|	7.40
15.70|	2793000.00|	19.10|	5.80
36.20|	741000.00|	24.70|	8.60
18.10|	625000.00|	18.60|	6.50
28.90|	854000.00|	24.90|	8.30
14.90|	716000.00|	17.90|	6.70
25.80|	921000.00|	22.40|	8.60
21.70|	595000.00|	20.20|	8.40
25.70|	3353000.00|	16.90|	6.70

N = 20
Variance observed = 92.76010000000001
Variance Predicted = 75.90724706481737
R2 = 0.8183178658153383

About

Why?

Web assembly can allow us to interact with compiled code directly in the browser, doing away with any need for a server. While I don't do a large amount of data analysis for my role proper, I realize that many researchers do, and so with this in mind, I wanted to create a starting point for developers to interact with data in the browser. The minimum conditions for success meant:

  1. being able to load a delimited file into the browser
  2. having the file render as a table
  3. having the data be processed by a compiled wasm
  4. updating a plot based on output from 3.

Thus, the application performs a simple regression based on loading data in the table, and then plotting the result. To make it fun, I added a cute gopher logo and used an xkcd plotting library for the result.

Customization

The basics are here for a developer to create (some GoLang based) functions to perform data analysis on an input file, and render back to the screen as a plot. If you need any help, or want to request a custom tool, please don't hesitate to open up an issue.

Development

Local

If you are comfortable with GoLang, and have installed emscripten, you can clone the repository into your $GOPATH under the github folder:

$ mkdir -p $GOPATH/src.github.com/vsoch
$ cd $GOPATH/src.github.com/vsoch
$ git clone https://www.github.com/vsoch/regression-wasm

And then build the wasm.

$ cd regression-wasm
$ make

Add your own Go version specific wasm_exec.js file :

$ cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./docs

And cd into the "docs" folder and start a server to see the result.

$ cd docs
$ python -m http.server 9999

Open the browser to http://localhost:9999

Docker

If you don't want to install dependencies, just clone the repository, and build the Docker image:

$ docker build -t vanessa/regression-wasm .

It will install emscripten, add the source code to the repository, and compile to wasm. You can then run the container and expose port 80 to see the compiled interface:

$ docker run -it --rm -p 80:80 vanessa/regression-wasm

Then you can proceed to use the interface.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].