Jayabalambika
commited on
Commit
·
0c93937
1
Parent(s):
df356fe
Update app.py
Browse files
app.py
CHANGED
@@ -24,15 +24,15 @@ def compare_lasso_dense():
|
|
24 |
# print(f"Sparse Lasso done in {(time() - t0):.3f}s")
|
25 |
elapse1 = time() - t0
|
26 |
|
27 |
-
|
28 |
dense_lasso.fit(X, y)
|
29 |
# print(f"Dense Lasso done in {(time() - t0):.3f}s")
|
30 |
-
elapse2 = time() -
|
31 |
|
32 |
# compare the regression coefficients
|
33 |
coeff_diff = linalg.norm(sparse_lasso.coef_ - dense_lasso.coef_)
|
34 |
# print(f"Distance between coefficients : {coeff_diff:.2e}")
|
35 |
-
return f"Sparse Lasso done in {(
|
36 |
|
37 |
def compare_lasso_sparse():
|
38 |
# make a copy of the previous data
|
@@ -57,15 +57,15 @@ def compare_lasso_sparse():
|
|
57 |
print(f"Sparse Lasso done in {(time() - t0):.3f}s")
|
58 |
elapses1 = time() - t0
|
59 |
|
60 |
-
|
61 |
dense_lasso.fit(Xs, y)
|
62 |
-
print(f"Dense Lasso done in {(time() -
|
63 |
-
elapses2 = time() -
|
64 |
|
65 |
# compare the regression coefficients
|
66 |
coeff_diff = linalg.norm(sparse_lasso.coef_ - dense_lasso.coef_)
|
67 |
print(f"Distance between coefficients : {coeff_diff:.2e}")
|
68 |
-
return f"Matrix density : {(Xs_sp.nnz / float(X.size) * 100):.3f}%\t\n"+ f"Sparse Lasso done in {(
|
69 |
|
70 |
|
71 |
X,X_sp,y = load_dataset()
|
|
|
24 |
# print(f"Sparse Lasso done in {(time() - t0):.3f}s")
|
25 |
elapse1 = time() - t0
|
26 |
|
27 |
+
t1 = time()
|
28 |
dense_lasso.fit(X, y)
|
29 |
# print(f"Dense Lasso done in {(time() - t0):.3f}s")
|
30 |
+
elapse2 = time() - t1
|
31 |
|
32 |
# compare the regression coefficients
|
33 |
coeff_diff = linalg.norm(sparse_lasso.coef_ - dense_lasso.coef_)
|
34 |
# print(f"Distance between coefficients : {coeff_diff:.2e}")
|
35 |
+
return f"Sparse Lasso done in {(elapse1):.3f}s\t\n" + f"Dense Lasso done in {(elapse2):.3f}s\t\n" + f"Distance between coefficients : {coeff_diff:.2e}\t\n"
|
36 |
|
37 |
def compare_lasso_sparse():
|
38 |
# make a copy of the previous data
|
|
|
57 |
print(f"Sparse Lasso done in {(time() - t0):.3f}s")
|
58 |
elapses1 = time() - t0
|
59 |
|
60 |
+
t1 = time()
|
61 |
dense_lasso.fit(Xs, y)
|
62 |
+
print(f"Dense Lasso done in {(time() - t1):.3f}s")
|
63 |
+
elapses2 = time() - t1
|
64 |
|
65 |
# compare the regression coefficients
|
66 |
coeff_diff = linalg.norm(sparse_lasso.coef_ - dense_lasso.coef_)
|
67 |
print(f"Distance between coefficients : {coeff_diff:.2e}")
|
68 |
+
return f"Matrix density : {(Xs_sp.nnz / float(X.size) * 100):.3f}%\t\n"+ f"Sparse Lasso done in {(elapse1):.3f}s\t\n" + f"Dense Lasso done in {(elapse2):.3f}s\t\n" + f"Distance between coefficients : {coeff_diff:.2e}\t\n"
|
69 |
|
70 |
|
71 |
X,X_sp,y = load_dataset()
|