Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple linear regression to .WASM example.
# imports
import sclblpy as sp
import numpy as np
from sklearn.linear_model import LinearRegression
# generate some data:
n = 100
x = np.random.uniform(0,10,(n,))
# y = 10 + 2x + noise:
y = 10 + 2*x + np.random.normal(0,1,(n,))
# fit a model (note the reshape of the vectors)
mod = LinearRegression(), 1), y.reshape(-1, 1))
# prepare for upload to scailable
fv = np.array([10]).reshape(1,-1) # an example feature vector
docs = {}
docs['name'] = "Simple linear regression demo"
docs['documentation'] = "Linear regression demonstration."
# upload the model; a single-line-of-code
sp.upload(mod, fv, docs=docs)
# Note: the last call will only work if you have a valid scailable account
# get one at
# and install sclblpy using pip or conda.
# A demo is available here:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment