This example is a good starting point to use the machine learning concept on a classification problem. In the code snippet below, we apply the supervised learning concept with the naive Bayes classifier. The naive Baye classifier is formulated around the Bayes theorem and conditional probability basics. The dataset that is used in the example is the Breast Cancer Dataset. We load this dataset using sklearn package function load_breast_cancer(). That dataset has records for 569 patients and 30 features regarding the images collected using the Needle Tip in Area of Concern. Some features are radius, texture, perimeter, area, smoothness, compactness. To keep the simplicity level of this example, we pick only the first two features. The target of this data is two classes binary (Malignant,Benign). The dataset is split into training and testing sets to validate the trained classified on 50% ratio. The size of training and testing is 284 patients each. We measure the outcome of the validation process using performance measures such as precision, recall, f-measure.
# https://jupyter.org/try # Demo2 # M. S. Rakha, Ph.D. # Post-Doctoral - Queen's University # Supervised Learning - Naive Bayes Classification %matplotlib inline import numpy as np import pandas as pd from sklearn import datasets from sklearn.preprocessing import scale import sklearn.metrics as sm from sklearn.metrics import confusion_matrix,classification_report from sklearn.model_selection import train_test_split