Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import numpy as np
  2. import time
  3. import warnings
  4.  
  5. import numpy as np
  6. import matplotlib.pyplot as plt
  7.  
  8. from sklearn import cluster, datasets, mixture
  9. from sklearn.neighbors import kneighbors_graph
  10. from sklearn.preprocessing import StandardScaler
  11. from itertools import cycle, islice
  12. from sklearn.metrics import fbeta_score, make_scorer
  13.  
  14. n_samples = 1500
  15. X, y = datasets.make_circles(n_samples=n_samples, factor=.5,
  16. noise=.05)
  17.  
  18. import numpy as np
  19. from sklearn.linear_model import Ridge
  20. from sklearn.grid_search import GridSearchCV
  21.  
  22. # prepare a range of alpha values to test
  23. alphas = np.array([10, 1, 0.1, 0.01, 0.001, 0.0001, 0])
  24. # create and fit a ridge regression model, testing each alpha
  25. model = Ridge()
  26. ftwo_scorer = make_scorer(fbeta_score, beta=2)
  27. grid = GridSearchCV(estimator=model, param_grid=dict(alpha=alphas), scoring=Ridge.score)
  28. grid.fit(X, y)
  29. print(grid)
  30. print("asdasdasdsada")
  31. # summarize the results of the grid search
  32. print(grid.best_score_)
  33. print(grid.best_estimator_.alpha)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement