Advertisement
GamerBhai02

DS Exp 12

May 21st, 2025
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | Source Code | 0 0
  1. from numpy import where
  2. from collections import Counter
  3. from sklearn.datasets import make_blobs
  4. from matplotlib import pyplot as plt
  5. X, y = make_blobs(n_samples=1000, centers=2, random_state=1)
  6. print(X.shape, y.shape)
  7. counter = Counter(y)
  8. print(counter)
  9. for i in range(10):
  10.     print(X[i], y[i])
  11. for label, _ in counter.items():
  12.     row_ix = where(y==label)[0]
  13.     plt.scatter(X[row_ix, 0], X[row_ix, 1], label=str(label))
  14. plt.legend()
  15. plt.show()
  16.  
  17. from numpy import where
  18. from collections import Counter
  19. from sklearn.datasets import make_blobs
  20. from matplotlib import pyplot as plt
  21. X, y = make_blobs(n_samples=1000, centers=3, random_state=1)
  22. print(X.shape, y.shape)
  23. counter = Counter(y)
  24. print(counter)
  25. for i in range(10):
  26.     print(X[i], y[i])
  27. for label, _ in counter.items():
  28.     row_ix = where(y==label)[0]
  29.     plt.scatter(X[row_ix, 0], X[row_ix, 1], label=str(label))
  30. plt.legend()
  31. plt.show()
  32.  
  33. import pandas as pd
  34. import numpy as np
  35. from matplotlib import pyplot as plt
  36. from sklearn.linear_model import LinearRegression
  37. hgt = np.random.randint(50,70,10).reshape(-1,1)
  38. wgt = np.random.randint(90,120,10).reshape(-1,1)
  39. regression = LinearRegression()
  40. regression.fit(hgt,wgt)
  41. regression.predict([[60]])
Tags: EXP 12
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement