Skip to content

Instantly share code, notes, and snippets.

Embed
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()
mod.fit(x.reshape(-1, 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 https://admin.sclbl.net/signup.html
# and install sclblpy using pip or conda.
# A demo is available here: https://admin.sclbl.net/run.html?cfid=7d4f8549-a637-11ea-88a1-9600004e79cc&exin=%5B%5B10%5D%5D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment