<jupyter_start><jupyter_text>SpotCheck Classification Algorithms---<jupyter_code>from google.colab import drive
drive.mount('/content/drive')<jupyter_output>Mounted at /content/drive<jupyter_text>Linear ML Algorithms  Logistic RegressionLinear Mdels assumes that the featres of our dataset has Gaussian distribution and can be model binary classification problems.<jupyter_code># Linear Regession Classification
from pandas import read_csv
from sklearn.model_selection import KFold 
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
# Load Data
filename = "/content/drive/MyDrive/Colab Notebooks/ML Mastery python/Dataset/pima-indians-diabetes.csv"
names = ['preg', 'plas','pres','skin','test','mass','pedi','age','class']
dataframe = read_csv(filename, names=names)
array = dataframe.values
# separate array into input & output 
X = array[:,0:8]
Y = array[:,8]
kfold = KFold(n_splits=10)
model = LogisticRegression(solver='liblinear')
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.7695146958304853<jupyter_text>Linear Discriminate Analysis**LDA is a statistical technique for binary & malticlass clasification, this model also assumes that our features has a gassuian distribution.<jupyter_code># LDA Classification
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
#
#
model = LinearDiscriminantAnalysis()
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.773462064251538<jupyter_text>Nonlinear ML Algorithm  k-Nearnest NeighborsKNN uses distance metric to find the k most similar instances in the training data for new data & takes mean outcome of the neighbors.<jupyter_code># KNN Classification
from sklearn.neighbors import KNeighborsClassifier
#
#
model = KNeighborsClassifier()
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.7265550239234451<jupyter_text>Naive BayesThis model calculates the probalility of each class and the conditional probabiility of each class for the given input value. When working on real valued data gaussian distribution is assumed and GaussianNB function is used for classification.<jupyter_code># Gaussian Naive Bayes Classification
from sklearn.naive_bayes import GaussianNB
#
#
model = GaussianNB()
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.7551777170198223<jupyter_text>Decision TreesDecision tree, it constructs binary tree from the training data. The spliting point for dividing the tree are chosen greedily by evaluating each freatures and each values of it in the training data fot minimizing the cost function.<jupyter_code># CART Classification
from sklearn.tree import DecisionTreeClassifier
#
#
model = DecisionTreeClassifier(max_depth=3)
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.7446514012303486<jupyter_text>Support Vector MachineSVM seeks a line that best separates two classes, the data which are close to the line are the best separates the classes. SVM has different ketnals for separating the the classes, **Radial Basis Function** is used by default.<jupyter_code># SVM Classification
from sklearn.svm import SVC
#
#
model = SVC(gamma='auto')
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())<jupyter_output>0.6510252904989747
{'fraction_non_alphanumeric': 0.08055473591029802, 'fraction_numerical': 0.031572735320153436, 'mean_word_length': 7.329238329238329, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '226189', 'license': 'MIT', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1022, 'n_words': 319, 'path': 'Lessons/09_Spot_Check_Classification_Algorithms.ipynb', 'repo_name': 'Bluelord/ML_Mastery_Python', 'size': '3389'}