<jupyter_start><jupyter_text>Supervised Learning - Gaussian Naive BayesDo you remember the recipe for Machine Learning? Let me remind you once again!* Define Problem : We start by defining the problem we are trying to solve. This can be as simple as prediction of your next semester's result based on your previous results.* Collect Data : Next step is to collect relevant data based on the problem definition. This can be your grades in different semesters.* Prepare Data : The data collected for our problem is preprocessed. This can be removing redundant grades and replacing the missing ones.* Select Model(Algorithm) : After the data is ready, we proceed to select the machine learning model. The selection is based on the problem type e.g. classification, regression etc and the data that is available to us. The model can be linear regression model in our case.* Train Model : The selected model is then trained to learn from the data we have collected.* Evaluate Model : Final step is to evaluate the model that we have trained for accuracy and view the results.This is exactly what we are going to do here. Step 1 - Define ProblemMost of the engineering students have a dream of doing Masters in USA! But what are the chances of someone getting in? What if I told you that we can use Machine Learning to predict if you'll get an admission or not? How cool is that?   Step 2 - Collect & Prepare DataStep 2.1 - Import Libs, Data & Primary Data Analysis<jupyter_code>import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()

df = pd.read_csv("data.csv")
df.head()
df.shape
df.describe()<jupyter_output><empty_output><jupyter_text>Here are the few references that can be made from this -* Average GPA is 3.38* GRE has a max score of 800* There are about 400 records Step 2.2 - Finding & Imputing Missing Values<jupyter_code>df.isnull().sum()
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean')
imputer = imputer.fit(df.iloc[:, 1:3])
df.iloc[:, 1:3] = imputer.transform(df.iloc[:, 1:3])
df.isnull().sum()<jupyter_output><empty_output><jupyter_text>Awesome! Now we don't have any missing values.  Step 2.3 - Data Visualization<jupyter_code>sns.boxplot(x = 'admit', y = 'gre', data = df)
sns.barplot(x = 'admit', y = 'gpa', data = df)
sns.violinplot(x = 'admit', y = 'rank', data = df)<jupyter_output><empty_output><jupyter_text>Step 3 - Modeling<jupyter_code>#convert dataframe into matrix
dataArray = df.values
#splitting input features & o/p vars
X = dataArray[:,1:4]
y = dataArray[:,0:1]
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.5,random_state=42)
X_train.shape
X_test.shape
from sklearn.naive_bayes import GaussianNB
GNBClassifier = GaussianNB()
GNBClassifier = GNBClassifier.fit(X_train, y_train.ravel())
y_pred = GNBClassifier.predict(X_test)
from sklearn.metrics import accuracy_score
result = accuracy_score(y_test, y_pred)*100
result<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08241042345276874, 'fraction_numerical': 0.011400651465798045, 'mean_word_length': 5.280163599182004, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '409011', 'license': 'MIT', 'n_tokens_mistral': 959, 'n_tokens_neox': 921, 'n_words': 384, 'path': 'Gaussian Naive Bayes - Predicting MS Admission/.ipynb_checkpoints/Supervised Learning - GNB-checkpoint.ipynb', 'repo_name': 'warmachine0609/Data-Science-Projects', 'size': '3070'}