Last active
June 15, 2020 08:59
-
-
Save MKaptein/61b72ecef79efb099a352bbe608ce862 to your computer and use it in GitHub Desktop.
Simple linear regression to .WASM example.
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 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