Jovian
⭐️
Sign In
In [1]:
import sklearn.datasets as ds
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sns

Fetch list of dataSet names

In [2]:
dataSetName = [name for name in dir(ds) if name.startswith("fetch") or name.startswith("load")]
print("Total_DataSets::",len(dataSetName))
print(dataSetName)
Total_DataSets:: 24 ['fetch_20newsgroups', 'fetch_20newsgroups_vectorized', 'fetch_california_housing', 'fetch_covtype', 'fetch_kddcup99', 'fetch_lfw_pairs', 'fetch_lfw_people', 'fetch_mldata', 'fetch_olivetti_faces', 'fetch_openml', 'fetch_rcv1', 'fetch_species_distributions', 'load_boston', 'load_breast_cancer', 'load_diabetes', 'load_digits', 'load_files', 'load_iris', 'load_linnerud', 'load_sample_image', 'load_sample_images', 'load_svmlight_file', 'load_svmlight_files', 'load_wine']

Load datasets

In [3]:
for name in dataSetName:
    #print(name)
    tmp = "ds."+name+"()"
    data = eval(tmp)["data"]
    print("#"*10 + "Loading..."+ name + "#"*10)
    print(name)
    print(data)
    print("#"*50)

IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--NotebookApp.iopub_data_rate_limit`. Current values: NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec) NotebookApp.rate_limit_window=3.0 (secs)
##########Loading...fetch_20newsgroups_vectorized########## fetch_20newsgroups_vectorized (0, 5022) 0.017109647770728872 (0, 5886) 0.017109647770728872 (0, 6214) 0.017109647770728872 (0, 6216) 0.017109647770728872 (0, 6281) 0.017109647770728872 (0, 6286) 0.017109647770728872 (0, 6324) 0.017109647770728872 (0, 6331) 0.017109647770728872 (0, 6403) 0.017109647770728872 (0, 11391) 0.017109647770728872 (0, 13930) 0.017109647770728872 (0, 15094) 0.017109647770728872 (0, 15251) 0.017109647770728872 (0, 15530) 0.017109647770728872 (0, 16731) 0.017109647770728872 (0, 20228) 0.017109647770728872 (0, 26214) 0.017109647770728872 (0, 26806) 0.017109647770728872 (0, 27436) 0.017109647770728872 (0, 27618) 0.017109647770728872 (0, 27645) 0.017109647770728872 (0, 27901) 0.017109647770728872 (0, 28012) 0.05132894331218662 (0, 28146) 0.41063154649749295 (0, 28421) 0.034219295541457743 : : (11313, 115133) 0.035555906726738896 (11313, 115475) 0.4266708807208668 (11313, 115816) 0.035555906726738896 (11313, 118561) 0.035555906726738896 (11313, 118842) 0.1066677201802167 (11313, 118983) 0.07111181345347779 (11313, 119701) 0.035555906726738896 (11313, 119741) 0.035555906726738896 (11313, 121278) 0.1066677201802167 (11313, 121667) 0.07111181345347779 (11313, 121837) 0.035555906726738896 (11313, 121999) 0.035555906726738896 (11313, 123198) 0.035555906726738896 (11313, 123211) 0.035555906726738896 (11313, 123759) 0.035555906726738896 (11313, 123796) 0.035555906726738896 (11313, 124103) 0.035555906726738896 (11313, 124198) 0.035555906726738896 (11313, 124616) 0.07111181345347779 (11313, 125271) 0.035555906726738896 (11313, 128026) 0.035555906726738896 (11313, 128084) 0.035555906726738896 (11313, 128402) 0.1066677201802167 (11313, 128420) 0.035555906726738896 (11313, 128436) 0.035555906726738896 ################################################## ##########Loading...fetch_california_housing########## fetch_california_housing [[ 8.3252 41. 6.98412698 ... 2.55555556 37.88 -122.23 ] [ 8.3014 21. 6.23813708 ... 2.10984183 37.86 -122.22 ] [ 7.2574 52. 8.28813559 ... 2.80225989 37.85 -122.24 ] ... [ 1.7 17. 5.20554273 ... 2.3256351 39.43 -121.22 ] [ 1.8672 18. 5.32951289 ... 2.12320917 39.43 -121.32 ] [ 2.3886 16. 5.25471698 ... 2.61698113 39.37 -121.24 ]] ################################################## ##########Loading...fetch_covtype########## fetch_covtype [[2.596e+03 5.100e+01 3.000e+00 ... 0.000e+00 0.000e+00 0.000e+00] [2.590e+03 5.600e+01 2.000e+00 ... 0.000e+00 0.000e+00 0.000e+00] [2.804e+03 1.390e+02 9.000e+00 ... 0.000e+00 0.000e+00 0.000e+00] ... [2.386e+03 1.590e+02 1.700e+01 ... 0.000e+00 0.000e+00 0.000e+00] [2.384e+03 1.700e+02 1.500e+01 ... 0.000e+00 0.000e+00 0.000e+00] [2.383e+03 1.650e+02 1.300e+01 ... 0.000e+00 0.000e+00 0.000e+00]] ################################################## ##########Loading...fetch_kddcup99########## fetch_kddcup99 [[0 b'tcp' b'http' ... 0.0 0.0 0.0] [0 b'tcp' b'http' ... 0.0 0.0 0.0] [0 b'tcp' b'http' ... 0.0 0.0 0.0] ... [0 b'tcp' b'http' ... 0.01 0.0 0.0] [0 b'tcp' b'http' ... 0.01 0.0 0.0] [0 b'tcp' b'http' ... 0.01 0.0 0.0]] ################################################## ##########Loading...fetch_lfw_pairs########## fetch_lfw_pairs [[ 73.666664 70.666664 81.666664 ... 225.66667 229.66667 233.33333 ] [ 86.333336 113.333336 133.33333 ... 106. 114.333336 122.333336] [ 37.333332 35.333332 34. ... 51.333332 52.333332 52. ] ... [ 73. 94.333336 121.333336 ... 64. 71. 82.333336] [119. 110.333336 112.666664 ... 145.33333 130. 102.333336] [ 23.333334 20. 23.333334 ... 146.33333 151. 159. ]] ################################################## ##########Loading...fetch_lfw_people########## fetch_lfw_people [[ 34. 29.333334 22.333334 ... 14.666667 16. 14. ] [158. 160.66667 169.66667 ... 138.66667 135.33333 130.33333 ] [ 77. 81.333336 88. ... 192. 145.33333 66.333336] ... [ 38. 41.666668 55.333332 ... 66. 63.666668 54.333332] [ 16.666666 24.333334 60.333332 ... 219. 143.33333 69.333336] [ 58.333332 48. 20. ... 116. 106.333336 143.33333 ]] ##################################################
C:\Anaconda3\lib\site-packages\sklearn\utils\deprecation.py:85: DeprecationWarning: Function fetch_mldata is deprecated; fetch_mldata was deprecated in version 0.20 and will be removed in version 0.22. Please use fetch_openml. warnings.warn(msg, category=DeprecationWarning)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-1da783ca8dba> in <module> 2 #print(name) 3 tmp = "ds."+name+"()" ----> 4 data = eval(tmp)["data"] 5 print("#"*10 + "Loading..."+ name + "#"*10) 6 print(name) <string> in <module> C:\Anaconda3\lib\site-packages\sklearn\utils\deprecation.py in wrapped(*args, **kwargs) 84 def wrapped(*args, **kwargs): 85 warnings.warn(msg, category=DeprecationWarning) ---> 86 return fun(*args, **kwargs) 87 88 wrapped.__doc__ = self._update_doc(wrapped.__doc__) TypeError: fetch_mldata() missing 1 required positional argument: 'dataname'

For Samples generator

In [4]:
dataSetName2 = [name for name in dir(ds) if name.startswith("make_")]
print("Total_DataSets::",len(dataSetName2))
print(dataSetName2)
Total_DataSets:: 20 ['make_biclusters', 'make_blobs', 'make_checkerboard', 'make_circles', 'make_classification', 'make_friedman1', 'make_friedman2', 'make_friedman3', 'make_gaussian_quantiles', 'make_hastie_10_2', 'make_low_rank_matrix', 'make_moons', 'make_multilabel_classification', 'make_regression', 'make_s_curve', 'make_sparse_coded_signal', 'make_sparse_spd_matrix', 'make_sparse_uncorrelated', 'make_spd_matrix', 'make_swiss_roll']
In [5]:
ds.make_friedman1()
Out[5]:
(array([[1.08160151e-01, 8.42784949e-01, 6.74842368e-01, 3.38150463e-01,
         4.15749512e-01, 6.86898776e-02, 1.47420472e-01, 3.04841720e-01,
         4.74499731e-01, 9.30719924e-01],
        [1.11069006e-01, 1.89366921e-01, 3.76624508e-01, 4.26149655e-01,
         5.85321646e-01, 5.41326141e-01, 2.27961573e-01, 2.26389137e-01,
         8.64755853e-01, 2.71212327e-01],
        [9.31988550e-01, 6.17801723e-01, 4.83890211e-01, 7.07344238e-01,
         1.96125262e-01, 6.32928167e-02, 7.21567943e-01, 3.36757171e-01,
         1.76278858e-01, 1.92208981e-02],
        [8.85024510e-01, 1.67773113e-01, 3.24664822e-01, 8.37697921e-01,
         5.39568078e-01, 5.05448986e-01, 7.03896274e-01, 2.98994784e-01,
         9.87164008e-01, 2.32427222e-01],
        [9.31905025e-01, 9.56256226e-01, 3.10057762e-01, 2.63046146e-01,
         7.40983268e-01, 7.32563580e-01, 8.59361705e-01, 4.50492019e-01,
         4.03214017e-02, 3.45050815e-01],
        [4.79963702e-01, 2.60716640e-01, 7.38470789e-02, 5.53461822e-01,
         3.48885257e-01, 4.95707820e-01, 2.74789639e-01, 1.25999592e-01,
         5.53524510e-02, 4.76575123e-01],
        [6.83239938e-01, 6.10761023e-01, 7.60149142e-01, 9.20866965e-01,
         9.21025047e-01, 5.57236683e-01, 3.92887872e-01, 7.17536152e-02,
         2.60383357e-01, 1.38069961e-01],
        [3.53050048e-01, 2.00709478e-01, 5.68640191e-01, 7.03436107e-01,
         5.09729660e-01, 6.03889518e-01, 8.31757119e-01, 5.02136521e-01,
         6.36700623e-01, 6.86787132e-01],
        [4.70302188e-01, 8.67858984e-02, 1.66473591e-01, 9.09239063e-01,
         2.62218245e-01, 2.48447622e-01, 2.39070102e-02, 3.43133166e-01,
         5.22614238e-01, 2.23639233e-01],
        [1.86443795e-01, 8.82538833e-01, 6.10558439e-01, 5.30339636e-01,
         3.35585123e-01, 2.61656083e-01, 6.30919014e-01, 4.35764420e-03,
         3.43903744e-01, 8.45450787e-01],
        [8.15484013e-01, 5.60829240e-01, 1.62446284e-01, 5.02266274e-01,
         8.51074195e-01, 1.08813724e-01, 3.45538566e-01, 5.85036888e-01,
         8.46177961e-02, 2.48276499e-01],
        [6.49367148e-02, 4.28335649e-01, 5.11340026e-01, 2.21678444e-02,
         5.12444233e-01, 1.29320539e-02, 3.47275241e-01, 1.93379379e-01,
         7.76132678e-01, 8.10055012e-01],
        [8.55840840e-01, 6.89541361e-01, 2.16057289e-01, 8.90587381e-01,
         9.82869437e-01, 9.40607119e-01, 2.20114458e-01, 8.30291507e-01,
         4.73444501e-01, 1.57657390e-01],
        [6.76512521e-01, 2.64352822e-01, 1.08389242e-01, 8.64763205e-01,
         4.56082073e-01, 5.68325750e-01, 1.08396760e-01, 2.95589399e-01,
         3.37021685e-01, 9.83089311e-01],
        [3.00197265e-01, 9.16973358e-01, 3.44481765e-02, 2.00403068e-01,
         4.18642340e-01, 5.45704526e-02, 4.61900918e-01, 3.56959376e-01,
         8.92539587e-01, 3.90989417e-01],
        [6.67252265e-01, 1.94798006e-02, 8.35077578e-01, 3.07612250e-01,
         1.00007528e-01, 7.18364572e-02, 7.01214955e-01, 2.81887820e-01,
         1.53041833e-01, 9.81083454e-01],
        [8.64886187e-01, 4.89530522e-01, 2.70022228e-01, 4.11301580e-01,
         7.58302889e-01, 5.15238881e-02, 5.02887125e-01, 8.26196076e-01,
         3.86930594e-01, 8.97447434e-01],
        [2.23758297e-01, 1.77626284e-01, 4.18032291e-01, 7.48525427e-01,
         1.10925465e-01, 1.64443054e-01, 1.47384357e-01, 2.38668582e-01,
         7.47353227e-01, 2.31873930e-01],
        [3.92056991e-01, 2.83283421e-01, 7.95341080e-01, 2.62301869e-01,
         2.22507579e-01, 7.07081270e-01, 4.12103096e-01, 3.53323785e-01,
         5.36120102e-01, 1.10290940e-01],
        [7.78423529e-02, 9.97925445e-01, 6.96528196e-01, 2.90960242e-01,
         7.69497119e-01, 4.36642493e-01, 9.03923083e-01, 4.20322443e-01,
         4.81780733e-01, 9.95389197e-01],
        [5.47027646e-01, 3.33481355e-01, 8.43925152e-01, 4.99160533e-01,
         4.93034544e-01, 3.94110824e-01, 2.32073688e-01, 9.80451864e-01,
         1.79402751e-01, 6.08085633e-02],
        [5.02170362e-01, 7.29045996e-02, 3.30716805e-02, 1.94535845e-01,
         1.58252447e-01, 6.80626262e-01, 5.51049458e-02, 3.14415072e-01,
         5.02516836e-01, 2.14924188e-01],
        [9.11990982e-01, 3.47895728e-01, 4.03003452e-01, 2.39255250e-01,
         9.82706804e-01, 4.82735234e-01, 1.11350576e-01, 1.18461906e-01,
         1.02203432e-02, 4.46828130e-01],
        [3.47585964e-01, 3.64373917e-01, 8.06842720e-01, 9.24538413e-01,
         2.30589252e-01, 8.34800287e-01, 5.35934978e-01, 5.78338484e-01,
         8.35807693e-01, 3.77772335e-01],
        [6.81963755e-01, 4.12002824e-01, 2.30277608e-01, 1.83427559e-01,
         1.23816249e-01, 5.14151203e-01, 2.46081480e-01, 3.58498392e-01,
         8.50557229e-01, 7.18965373e-01],
        [4.19544189e-01, 2.13467550e-02, 2.90095523e-01, 6.95881168e-01,
         8.85238516e-01, 6.86073820e-01, 9.42891467e-01, 5.06140059e-01,
         3.75938040e-01, 2.06719174e-01],
        [8.91491011e-02, 6.80021195e-01, 7.75338654e-01, 7.99247503e-01,
         6.20700657e-01, 1.12128214e-01, 8.47942566e-01, 2.49258261e-01,
         6.89963632e-01, 1.77824994e-01],
        [7.00518562e-01, 5.11731895e-01, 4.93636892e-01, 2.59907809e-01,
         6.51701331e-01, 3.04572057e-01, 6.58227907e-01, 4.80458711e-01,
         8.69316745e-01, 2.75680360e-01],
        [1.08145667e-01, 8.87769049e-01, 7.91413077e-01, 5.98675931e-01,
         2.46641062e-01, 7.07221801e-01, 2.49841700e-02, 1.94840482e-01,
         4.67519841e-01, 9.45918604e-01],
        [3.37842967e-01, 2.25492877e-01, 7.42978558e-02, 5.70260944e-01,
         2.88436636e-01, 8.63519121e-01, 5.80445253e-01, 3.30911759e-01,
         4.94131426e-01, 1.38549744e-01],
        [2.51398933e-01, 5.63997177e-02, 7.82743017e-01, 2.19106466e-01,
         9.31598413e-01, 8.07559198e-01, 5.83656124e-01, 6.62464808e-01,
         9.81709960e-01, 6.12542650e-01],
        [7.54752788e-01, 4.74398178e-02, 9.66226676e-01, 1.58923608e-01,
         6.01172589e-02, 1.83072256e-01, 4.96138675e-01, 7.01994439e-01,
         3.34368329e-01, 5.67736646e-01],
        [3.97541134e-01, 1.82124508e-01, 3.33626568e-01, 6.91896203e-01,
         1.99651056e-01, 5.20493144e-01, 6.68563513e-01, 1.60537516e-01,
         5.75065299e-01, 4.33088065e-01],
        [5.36406505e-02, 6.75250705e-01, 1.05021937e-01, 6.03373088e-02,
         6.37169891e-02, 2.13170370e-02, 2.55250924e-01, 8.22133619e-01,
         7.71931547e-01, 7.68155326e-01],
        [8.27140875e-01, 6.96540531e-01, 9.35229768e-01, 1.22182527e-01,
         5.58332893e-01, 2.29593455e-01, 2.50428243e-01, 5.52398281e-01,
         3.60820245e-01, 4.38811845e-01],
        [3.92221151e-01, 1.08578127e-01, 8.96587573e-01, 2.89458549e-01,
         5.61807499e-02, 4.44507293e-01, 7.07786516e-01, 4.83897404e-01,
         3.90368155e-02, 3.38866756e-01],
        [6.62476285e-01, 4.42034231e-01, 4.54239510e-01, 4.68752413e-01,
         7.84538103e-01, 8.65952352e-01, 5.48838364e-01, 8.62114133e-01,
         1.37886514e-01, 3.88487300e-02],
        [9.24815916e-01, 2.21313553e-01, 8.01860140e-01, 5.94959661e-01,
         4.24759041e-01, 4.98644085e-02, 1.53339563e-01, 6.42749081e-01,
         7.41951711e-02, 2.54298348e-01],
        [5.63063862e-01, 9.45564897e-01, 4.63299038e-01, 6.10454559e-01,
         3.98846104e-01, 7.36454042e-01, 5.57991504e-01, 2.40129500e-01,
         4.81158990e-01, 2.95916890e-01],
        [7.56181923e-01, 1.01903201e-01, 5.56419671e-01, 5.79218170e-01,
         3.52932676e-01, 1.19142614e-01, 5.49350144e-01, 1.59011046e-03,
         5.41373757e-01, 7.60669519e-01],
        [6.22576135e-01, 1.04712634e-01, 2.62301069e-01, 8.96416934e-01,
         8.56389093e-01, 7.01438594e-01, 2.64649689e-01, 6.18779280e-01,
         3.46681179e-01, 1.79202544e-02],
        [9.66229997e-01, 3.04226848e-01, 2.24108064e-01, 8.48303113e-01,
         3.39009823e-01, 9.05471527e-02, 8.87515678e-01, 9.68129121e-01,
         2.98344371e-01, 9.83722006e-01],
        [3.09821032e-01, 7.78723915e-01, 6.03422996e-01, 1.76032986e-02,
         9.16870423e-01, 8.85657021e-01, 3.62887611e-01, 8.14211037e-01,
         5.83956195e-02, 7.16853701e-01],
        [5.47594975e-01, 1.68773708e-01, 2.77431711e-01, 1.89754745e-01,
         6.04397872e-01, 1.10986039e-01, 9.47481508e-01, 6.47711507e-01,
         2.21579122e-01, 1.99695265e-01],
        [6.58897347e-01, 5.65032278e-01, 2.37717765e-01, 5.63600209e-02,
         5.52327189e-01, 2.33012324e-01, 1.66268109e-03, 1.19248266e-01,
         4.12785894e-01, 5.80834851e-01],
        [7.19924061e-01, 9.20640746e-01, 7.88345825e-01, 1.43358977e-01,
         6.08161063e-01, 1.97873505e-01, 8.62258580e-01, 6.61245531e-01,
         6.02838434e-02, 9.73738262e-01],
        [7.78625451e-01, 6.01262850e-01, 2.64202244e-01, 2.30575998e-01,
         5.77046537e-01, 9.49647005e-01, 3.17712872e-01, 4.83177791e-01,
         4.39853907e-01, 6.76488855e-01],
        [9.95613056e-01, 9.95999152e-01, 3.10720845e-01, 2.90925372e-01,
         7.63359091e-01, 7.20770837e-02, 1.65180202e-01, 3.05707862e-01,
         9.69835577e-01, 7.59156817e-01],
        [4.69329412e-01, 6.01867190e-01, 6.11595385e-03, 2.87442806e-02,
         9.40401015e-01, 9.67864699e-01, 2.28871956e-01, 6.75289153e-01,
         1.21845785e-01, 5.71162159e-01],
        [6.10241757e-01, 3.51669611e-01, 5.53337053e-01, 8.71073817e-01,
         7.36710642e-01, 8.09512799e-01, 6.89902942e-01, 2.20585554e-01,
         6.49810481e-01, 7.01316064e-02],
        [6.33981790e-02, 1.39646751e-01, 4.20845484e-01, 9.86215205e-01,
         8.50320394e-01, 3.67890431e-01, 1.08237786e-01, 8.89987494e-01,
         3.06756799e-01, 9.18617921e-01],
        [6.98118319e-01, 8.25899392e-01, 8.94225191e-01, 3.22739772e-01,
         2.05530547e-01, 2.82028706e-01, 3.02400296e-01, 9.92972184e-01,
         8.63251083e-01, 3.93938576e-01],
        [6.59705325e-01, 3.06107303e-01, 1.52300585e-01, 8.15343016e-01,
         6.00977799e-01, 5.72889396e-01, 7.22646386e-01, 7.08261868e-01,
         4.54514296e-01, 8.37996128e-01],
        [4.33234210e-01, 7.15346230e-01, 5.21476192e-01, 4.52415631e-02,
         3.29810510e-01, 9.51461991e-01, 2.37377981e-01, 4.63632554e-02,
         3.25113288e-01, 6.54795928e-01],
        [1.31041868e-01, 7.07963227e-01, 5.03879237e-01, 4.74522993e-02,
         7.46167122e-01, 1.90371205e-01, 5.75424215e-01, 1.40848745e-01,
         8.00069516e-01, 3.86494589e-01],
        [9.86405500e-01, 5.23407802e-01, 1.64606628e-01, 2.79885467e-01,
         7.10202106e-01, 1.88324128e-02, 8.56485161e-02, 4.53443648e-01,
         7.03606684e-01, 2.67618916e-01],
        [9.41600706e-01, 2.83238971e-01, 8.58273883e-01, 1.05988545e-01,
         3.89139742e-01, 5.78045007e-01, 5.83009297e-02, 6.49437481e-01,
         1.53044440e-01, 8.48068064e-01],
        [3.69228432e-01, 1.64299986e-01, 3.25078621e-01, 2.95465341e-01,
         2.56316239e-01, 9.18783210e-01, 4.66714247e-01, 5.56984166e-01,
         4.65183283e-01, 5.04172344e-01],
        [2.20225931e-01, 6.96426267e-01, 3.83020351e-01, 6.35871838e-01,
         6.57721697e-01, 6.36243312e-01, 1.56139577e-01, 1.73476701e-01,
         9.65054228e-01, 3.55611840e-01],
        [3.31153837e-01, 8.25896997e-01, 6.89560670e-01, 5.12273470e-01,
         8.43187856e-01, 2.30008213e-01, 6.82979337e-02, 8.51156376e-01,
         4.65616186e-01, 6.93862742e-01],
        [6.50264354e-02, 1.53577283e-01, 4.40146971e-01, 4.19209655e-01,
         7.49959809e-04, 5.21774811e-01, 3.62943494e-01, 1.20014757e-02,
         9.89213751e-01, 5.45934435e-01],
        [6.06361459e-01, 2.30873334e-01, 3.54040880e-02, 3.46586236e-01,
         9.76835148e-01, 5.17576914e-01, 4.15254893e-01, 3.97640460e-01,
         5.16607739e-01, 5.44908043e-02],
        [2.40244714e-01, 7.37508136e-01, 4.64086232e-01, 1.66645647e-01,
         5.80767058e-02, 5.33801545e-01, 8.42543143e-01, 6.06430930e-01,
         5.41029518e-01, 9.63236303e-02],
        [7.54387924e-01, 7.27773716e-01, 8.51360791e-01, 2.09714157e-01,
         4.97358970e-01, 6.07372102e-01, 9.78993656e-01, 8.33819130e-01,
         4.53098994e-01, 2.87820270e-01],
        [9.62937035e-01, 1.92886178e-01, 1.38246099e-01, 3.39613437e-02,
         8.57640449e-01, 5.68582769e-01, 1.41058554e-01, 9.38923912e-01,
         3.72295222e-01, 2.39981811e-01],
        [2.24102744e-01, 2.57630586e-01, 9.59893265e-01, 6.17945705e-01,
         5.84209019e-01, 2.86119223e-01, 3.62687617e-01, 5.94825711e-01,
         5.58559291e-01, 5.59658912e-01],
        [5.32253430e-01, 4.53859012e-01, 9.67315311e-01, 2.30519156e-01,
         4.83372793e-01, 2.99283468e-01, 8.06688793e-01, 7.46875318e-01,
         9.68215442e-01, 8.05004066e-01],
        [1.76236480e-01, 6.93754600e-01, 4.71210057e-01, 6.78032864e-02,
         2.67040942e-01, 7.81296582e-01, 5.61675246e-01, 6.32145555e-01,
         4.43913125e-01, 6.70287174e-01],
        [1.86439712e-01, 7.10508159e-01, 5.38223756e-01, 8.99857632e-01,
         9.88007666e-01, 7.49607084e-01, 3.08588495e-01, 2.85504921e-01,
         7.46145723e-02, 2.93640266e-01],
        [1.27289242e-01, 1.40592907e-01, 5.79607686e-01, 8.19642446e-01,
         3.06355734e-02, 1.61831627e-01, 5.84090887e-02, 6.03233986e-01,
         5.22017790e-01, 7.49143120e-01],
        [7.87970699e-01, 8.35218774e-01, 3.81396130e-01, 5.14891335e-01,
         8.47333808e-01, 2.59441648e-01, 4.57608727e-01, 9.60829898e-01,
         3.08670606e-01, 4.94856277e-01],
        [5.63474044e-01, 9.82650929e-01, 9.11292852e-01, 9.49684306e-01,
         3.58635405e-01, 5.28012460e-01, 1.48407617e-01, 8.32628301e-01,
         5.23431068e-01, 7.83178160e-01],
        [7.25460952e-01, 3.53464627e-01, 8.35097108e-01, 1.40184908e-02,
         5.63561140e-01, 6.30122373e-01, 6.91656647e-01, 1.93621026e-01,
         9.72356544e-02, 3.89218209e-01],
        [5.58573188e-03, 8.83569882e-01, 8.89704393e-01, 8.25400504e-01,
         6.42237567e-01, 5.02843952e-01, 9.13291425e-01, 9.11332271e-01,
         1.40761843e-01, 6.97328618e-01],
        [6.59602229e-01, 1.36631306e-01, 7.72462358e-01, 6.39991293e-01,
         9.50661495e-01, 4.49993197e-01, 7.56951931e-02, 5.22613141e-01,
         4.09270746e-01, 6.20529500e-01],
        [9.65147444e-01, 7.37477384e-01, 8.24507132e-01, 8.82753930e-01,
         7.82933593e-01, 6.68483068e-01, 7.85434676e-01, 3.59349675e-01,
         3.30283627e-01, 4.16116854e-01],
        [1.08288364e-01, 8.38502829e-01, 7.59889682e-01, 9.43619573e-01,
         4.67485630e-03, 7.70993309e-01, 9.53546432e-02, 9.98112474e-01,
         1.16275247e-01, 4.65946706e-01],
        [7.59591556e-01, 9.45973985e-01, 7.81646584e-01, 5.21340902e-01,
         6.75581756e-01, 4.25183100e-01, 9.95336374e-01, 9.59405311e-01,
         9.64186269e-01, 7.74592239e-01],
        [3.23481933e-01, 8.77513352e-02, 3.83338392e-01, 4.93062144e-01,
         6.64503705e-01, 7.73435281e-01, 5.97260697e-01, 9.90161461e-01,
         5.98636994e-01, 9.34960093e-01],
        [6.15753995e-01, 2.75125282e-01, 4.71587311e-01, 8.86862666e-01,
         9.54093117e-01, 5.64358321e-01, 6.84756445e-01, 5.67802033e-02,
         8.39542872e-01, 5.27469989e-01],
        [8.36626102e-01, 2.29880556e-02, 3.86325816e-02, 4.29179771e-01,
         4.69618519e-01, 2.95652252e-01, 3.23681052e-01, 5.79297726e-01,
         2.57092901e-01, 5.59751314e-01],
        [7.74615816e-01, 8.71318536e-01, 3.94576284e-01, 8.30031353e-01,
         9.23665979e-01, 3.03933155e-01, 1.15813233e-01, 9.39070013e-01,
         7.11811421e-01, 3.94986596e-01],
        [9.91819272e-01, 9.42600987e-01, 7.09497268e-01, 5.79361257e-01,
         5.21459904e-01, 5.36216017e-01, 7.56737635e-01, 1.82162562e-01,
         6.98450681e-01, 9.83921586e-01],
        [2.28125759e-01, 6.40560967e-02, 1.57275395e-01, 7.69438120e-01,
         4.19084867e-01, 8.60730095e-01, 8.48463026e-01, 7.95094255e-01,
         7.81041459e-01, 7.09683741e-02],
        [4.15913161e-01, 9.58236671e-01, 5.34086313e-01, 3.48066790e-01,
         2.56999457e-01, 8.98891040e-01, 9.38882063e-01, 2.85893727e-01,
         7.25024388e-01, 2.60457893e-01],
        [9.87401121e-01, 4.61521028e-01, 4.60172272e-01, 8.25487917e-01,
         1.53409297e-01, 5.12611167e-01, 2.17140490e-02, 5.81255491e-01,
         4.82430418e-01, 8.13996667e-01],
        [9.52726098e-01, 4.80746657e-01, 3.96842107e-01, 4.44183097e-01,
         1.30875589e-01, 4.83659110e-01, 3.48477654e-01, 8.85278201e-01,
         5.50061605e-01, 4.20086375e-01],
        [9.13428862e-01, 7.27077623e-01, 3.30982693e-01, 9.35002409e-01,
         3.28545601e-01, 8.00894780e-01, 1.83496711e-01, 4.46231210e-01,
         3.59252853e-01, 3.44621808e-01],
        [9.47113211e-02, 8.40254844e-01, 7.64893439e-01, 6.12173094e-01,
         3.84318485e-01, 6.12183203e-01, 2.75683351e-01, 8.78316043e-01,
         6.46464170e-01, 9.34913845e-01],
        [5.88427565e-01, 9.35569475e-01, 1.79430343e-01, 4.31992861e-01,
         4.44063202e-01, 6.39656110e-01, 5.02406630e-02, 4.60291271e-01,
         3.65270199e-01, 8.51035502e-02],
        [2.43562305e-01, 3.66778783e-01, 8.15176679e-02, 3.94288139e-01,
         8.66546041e-01, 5.13712648e-01, 8.70469991e-01, 8.39218489e-01,
         4.98110555e-01, 8.31940707e-01],
        [7.28345395e-01, 6.16971283e-01, 1.74689571e-01, 9.03539932e-01,
         3.03226140e-01, 8.05737402e-01, 3.28989574e-01, 2.43865398e-01,
         1.53801110e-01, 2.65366363e-01],
        [4.51084733e-01, 2.01693248e-01, 6.46641191e-01, 1.29997404e-01,
         8.19270325e-02, 5.98484279e-01, 3.95618038e-01, 7.81043982e-01,
         1.01178513e-01, 9.20869238e-01],
        [9.37978806e-01, 1.28161964e-01, 4.01091397e-01, 4.36959113e-01,
         4.72665715e-01, 1.97454771e-01, 6.11737331e-01, 6.75870935e-01,
         1.89076548e-01, 2.78422251e-01],
        [5.61456745e-01, 5.80850754e-01, 6.96350886e-01, 2.50568676e-01,
         7.44228428e-01, 8.30515269e-01, 8.74040267e-01, 2.88183789e-01,
         6.05312956e-02, 9.42557085e-02],
        [9.26237363e-01, 9.24681860e-02, 4.46075112e-01, 1.10963489e-01,
         8.45058623e-01, 4.74660231e-01, 5.52172777e-01, 4.84266967e-01,
         9.33771987e-01, 7.33836323e-01],
        [2.96871330e-01, 9.13402061e-01, 4.75241140e-01, 3.60415946e-01,
         1.80095027e-01, 4.99792989e-02, 7.67719318e-02, 9.70975593e-02,
         2.48953234e-01, 3.58301736e-01],
        [8.84587023e-01, 3.78727738e-01, 9.97342526e-01, 2.91704942e-01,
         5.62291383e-01, 3.19539936e-01, 6.42799316e-01, 9.38402511e-02,
         8.12367181e-01, 5.27414807e-01],
        [1.65801227e-01, 1.05199997e-01, 5.93224928e-01, 1.72463767e-01,
         7.46740448e-01, 1.84247992e-01, 3.11812451e-01, 3.64243014e-01,
         9.88133977e-01, 8.65917820e-02],
        [9.77152709e-01, 9.81373717e-01, 1.67659890e-01, 3.93689704e-01,
         4.31033869e-01, 4.44181100e-01, 1.67855297e-01, 4.94495260e-01,
         7.96346766e-01, 2.59571270e-01]]),
 array([ 8.89640904,  8.15281907, 17.77717816, 16.18706703, 10.4106001 ,
        14.74190922, 24.83170553, 11.88504537, 13.90702807, 12.16792021,
        21.46724157,  3.6591848 , 25.03441968, 19.32263184, 16.04163711,
         6.22992869, 18.67407948,  9.41965081,  8.898872  ,  9.94581932,
        15.24486501,  8.24468136, 15.89139947, 16.15608913, 11.63290114,
        12.54752304, 14.50524938, 14.88619887, 11.88906333, 13.13975907,
         8.89322275,  7.35965577, 10.7258325 ,  5.17757006, 17.51728621,
         7.65503421, 16.60796093, 15.89179919, 18.07391359, 10.01776109,
        16.40989685, 19.67746352, 11.84869947,  8.77309621, 13.90705733,
        14.85774429, 16.25301316,  7.70550968, 17.6223181 , 18.69388809,
        14.51716309, 17.0753461 , 19.50328257, 10.3799523 ,  7.07911569,
        18.5865434 , 13.00489487,  6.74249109, 14.55502404, 17.63068841,
         4.58118035, 16.9246105 ,  7.26595799, 16.93465951, 12.75470513,
        15.13443035, 15.97102487,  5.77712291, 18.01032168,  9.03827217,
        18.45816845, 24.53129808, 12.41613269, 14.65762663, 15.43153602,
        22.715566  , 13.62446299, 17.9118261 ,  9.41592867, 18.72967533,
        11.50092454, 21.66836028, 11.3099564 , 12.59792348, 14.28522605,
        18.95698963, 15.22219842, 20.26385649, 11.92086071, 18.46988287,
        14.54795807, 22.54182644,  4.95916737, 10.61605034, 15.54267768,
         8.05143141, 12.04211497, 19.36208785,  6.17984913,  9.58705555]))
In [6]:
ds.make_classification(n_classes=2)
Out[6]:
(array([[-1.40221684,  1.320418  , -0.87693956, ...,  0.57711346,
         -0.8475522 , -0.07260866],
        [-1.96791104, -1.72421113,  0.05002557, ..., -0.63495801,
          1.50153881,  0.46358158],
        [ 1.37775349,  0.10290392, -0.91264597, ...,  0.35670633,
          0.07526866, -0.85852331],
        ...,
        [-1.13885707, -1.12271072, -0.74257468, ...,  0.50269883,
         -0.20383015,  0.44644562],
        [ 1.07751507,  0.7327711 , -0.40610574, ..., -0.17804297,
          1.33874286,  0.57643116],
        [-0.94155835, -1.00285756, -0.2573205 , ...,  0.85292284,
         -0.19576552, -0.40520451]]),
 array([0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0,
        1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1,
        1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0,
        0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
        0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0]))
In [7]:
plt.scatter(ds.make_blobs()[0][:,0],ds.make_blobs()[0][:,1])
plt.show()
Notebook Image
In [17]:
import scikitplot as sp
In [31]:
km.fit(ds.make_blobs()[0])
Out[31]:
KMeans(algorithm='auto', copy_x=True, init='k-means++', max_iter=300,
       n_clusters=8, n_init=10, n_jobs=None, precompute_distances='auto',
       random_state=None, tol=0.0001, verbose=0)
In [57]:
%matplotlib inline
from sklearn.cluster import KMeans
iner = []
for n in range(1,20):
    km = KMeans(n_clusters=n)
    km.fit(ds.make_blobs()[0])
    iner.append(km.inertia_)

plt.plot(range(1,20),iner,"-or")
for i in range(1,19):
    plt.text(i,iner[i],round(iner[i],1))
plt.xticks(range(1,20))
plt.show()
Notebook Image
In [35]:
%matplotlib inline
from sklearn.cluster import KMeans
km = KMeans()
sp.cluster.plot_elbow_curve(km,ds.make_blobs()[0])
Out[35]:
<matplotlib.axes._subplots.AxesSubplot at 0x1e10091c7c8>
Notebook Image
In [10]:
%matplotlib notebook
ax = plt.subplot(111,projection = "3d")
ax.scatter(ds.make_circles()[0][:,0],ds.make_circles()[0][:,1])
plt.show()
In [9]:
%matplotlib notebook
ax = plt.subplot(111,projection = "3d")
ax.scatter(ds.make_swiss_roll()[0][:,0],ds.make_swiss_roll()[0][:,1],ds.make_swiss_roll()[0][:,2],alpha=.4,s=100*ds.make_swiss_roll()[0][:,2])
plt.show()
C:\Anaconda3\lib\site-packages\matplotlib\collections.py:857: RuntimeWarning: invalid value encountered in sqrt scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor