Skip to content

Commit

Permalink
Fixed LR example
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvi Solà Martinell committed Oct 25, 2020
1 parent cea3029 commit 7be9c21
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions examples/linear_regression_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
from pycompss.api.api import compss_wait_on
from pylab import scatter, plot, show

import dislib as ds
Expand All @@ -20,14 +19,14 @@ def main():
y_ds = ds.array(y[:, np.newaxis], (4, 1))
reg = LinearRegression()
reg.fit(x_ds, y_ds)
reg.coef_ = compss_wait_on(reg.coef_)
reg.intercept_ = compss_wait_on(reg.intercept_)
print(reg.coef_, reg.intercept_)
coef = reg.coef_.collect()
intercept = reg.intercept_.collect()
print(coef, intercept)

# plot_result:
scatter(x, y, marker='x')
x_mesh = np.linspace(min(x), max(x), 1000)
plot(x_mesh, [reg.coef_*x + reg.intercept_ for x in x_mesh])
plot(x_mesh, [coef*x + intercept for x in x_mesh])
show()


Expand Down

0 comments on commit 7be9c21

Please sign in to comment.