Advertisement
Guest User

iad

a guest
Mar 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1.  
  2. # coding: utf-8
  3.  
  4.  
  5. # In[5]:
  6.  
  7.  
  8. print('Python: {}'.format(sys.version))
  9.  
  10.  
  11. # In[6]:
  12.  
  13.  
  14. # Python version
  15. import sys
  16. print('Python: {}'.format(sys.version))
  17. # scipy
  18. import scipy
  19. print('scipy: {}'.format(scipy.__version__))
  20. # numpy
  21. import numpy
  22. print('numpy: {}'.format(numpy.__version__))
  23. # matplotlib
  24. import matplotlib
  25. print('matplotlib: {}'.format(matplotlib.__version__))
  26. # pandas
  27. import pandas
  28. print('pandas: {}'.format(pandas.__version__))
  29. # scikit-learn
  30. import sklearn
  31. print('sklearn: {}'.format(sklearn.__version__))
  32.  
  33.  
  34. # In[8]:
  35.  
  36.  
  37. # Load libraries
  38. import pandas
  39. from pandas.plotting import scatter_matrix
  40. import matplotlib.pyplot as plt
  41. from sklearn import model_selection
  42. from sklearn.metrics import classification_report
  43. from sklearn.metrics import confusion_matrix
  44. from sklearn.metrics import accuracy_score
  45. from sklearn.linear_model import LogisticRegression
  46. from sklearn.tree import DecisionTreeClassifier
  47. from sklearn.neighbors import KNeighborsClassifier
  48. from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
  49. from sklearn.naive_bayes import GaussianNB
  50. from sklearn.svm import SVC
  51.  
  52.  
  53. # In[9]:
  54.  
  55.  
  56. # Load dataset
  57. url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
  58. names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
  59. dataset = pandas.read_csv(url, names=names)
  60.  
  61.  
  62. # In[10]:
  63.  
  64.  
  65. # shape
  66. print(dataset.shape)
  67.  
  68.  
  69. # In[11]:
  70.  
  71.  
  72. # head
  73. print(dataset.head(20))
  74.  
  75.  
  76. # In[12]:
  77.  
  78.  
  79. # descriptions
  80. print(dataset.describe())
  81.  
  82.  
  83. # In[13]:
  84.  
  85.  
  86. # class distribution
  87. print(dataset.groupby('class').size())
  88.  
  89.  
  90. # In[14]:
  91.  
  92.  
  93. # box and whisker plots
  94. dataset.plot(kind='box', subplots=True, layout=(2,2), sharex=False, sharey=False)
  95. plt.show()
  96.  
  97.  
  98. # In[21]:
  99.  
  100.  
  101. # histograms
  102. dataset.hist()
  103. plt.show()
  104.  
  105.  
  106. # In[37]:
  107.  
  108.  
  109. import matplotlib.pyplot as plt
  110. plt.rcParams["figure.figsize"] = (30,30)
  111.  
  112. # scatter plot matrix
  113. scatter_matrix(dataset)
  114. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement