Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. from __future__ import division
  2. import numpy as np
  3. import cvxpy as cp
  4. import matplotlib.pyplot as plt
  5.  
  6. np.random.seed(1)
  7. n = 20
  8. m = 1000
  9. TEST = m
  10. DENSITY = 0.2
  11. beta_true = np.random.randn(n, 1)
  12. idxs = np.random.choice(range(n), int((1-DENSITY)*n), replace=False)
  13. for idx in idxs:
  14.     beta_true[idx] = 0
  15. offset = 0
  16. sigma = 45
  17. X = np.random.normal(0, 5, size=(m, n))
  18. Y = np.sign(X.dot(beta_true) +
  19.             offset +
  20.             np.random.normal(0, sigma, size=(m, 1)))
  21. X_test = np.random.normal(0, 5, size=(TEST, n))
  22. Y_test = np.sign(X_test.dot(beta_true) +
  23.                  offset +
  24.                  np.random.normal(0, sigma, size=(TEST, 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement