Last active
June 20, 2020 09:51
-
-
Save MKaptein/4277de539ac63645c46148b44951e515 to your computer and use it in GitHub Desktop.
sclbl_101_model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
import numpy as np | |
from sklearn.linear_model import LinearRegression | |
# Data generation y = 10 + 2*x1 -.5*x2 + noise: | |
np.random.seed(0) | |
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() | |
lm.fit(X, 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](https://github.com/scailable/sclbl-tutorials/blob/master/README.md).""" | |
# 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 https://admin.sclbl.net/signup.html | |
# and install sclblpy using pip. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment