Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Imports
import numpy as np
from sklearn.linear_model import LinearRegression
# Data generation y = 10 + 2*x1 -.5*x2 + noise:
n = 100
x1 = np.random.uniform(0,10,(n,))
x2 = np.random.uniform(0,10,(n,))
y = 10 + 2 * x1 -.5*x2 + np.random.normal(0,1,(n,))
X = np.column_stack((x1, x2))
# Model fitting
lm = LinearRegression(), y.reshape(-1, 1))
# Scailable demo:
import sclblpy as sp
# Create an example feature vector
fv = np.array([2,5])
# Create documentation for this model (accepts Markdown)
docs = {}
docs['name'] = "Simple linear regression demo"
docs['documentation'] = """#Linear regression demonstration.
\nFor the [getting started tutorial]("""
# Upload the model to transpile to WASM and make available
sp.upload(lm, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.