<jupyter_start><jupyter_text>**Artificial Intelligence - MSc**CS6501 - MACHINE LEARNING APPLICATIONS Instructor: <NAME>CS6501_Exercise_2.3  Imports<jupyter_code># import libraries
from sklearn.linear_model import LogisticRegression
from pandas import DataFrame
from mlxtend.plotting import plot_decision_regions
import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output><jupyter_text>Real Dataset<jupyter_code>from sklearn import datasets

# Loading some example data
iris = datasets.load_iris()
X2 = iris.data[:, [0, 2]]
y2 = iris.target
# create a data frame
df = DataFrame(dict(x=X2[:,0], y=X2[:,1], label=y2))

# three classes: 'cyan', 'brown', 2:'yellow'
colors = 

# figure
fig, ax = 
grouped = .groupby('label')

# scatter plot


# show the plot
plt.show()
# show first 15 rows
df.head()
# count the data elements for each class
df['label'].<jupyter_output><empty_output><jupyter_text>Training & Test Data<jupyter_code>from sklearn.model_selection import train_test_split

# training: 70%-30% 
X_train,X_test,y_train,y_test =

X_train[0:10]<jupyter_output><empty_output><jupyter_text>Logistic Regresion * [Logistic regression](https://en.wikipedia.org/wiki/Logistic_regression) is a statistical model that in its basic form uses a logistic function to model a binary dependent variable, although many more complex extensions exist. * In regression analysis, logistic regression (or logit regression) is estimating the parameters of a logistic model (a form of binary regression).<jupyter_code># Logistic Regression model
LR_model = LogisticRegression()

# fit to data a Logistic Regresion model
LR_model.fit()<jupyter_output><empty_output><jupyter_text>Decision boundary from [Wikipedia](https://en.wikipedia.org/wiki/Decision_boundary): * A decision boundary is the region of a problem space in which the output label of a classifier is ambiguous.* If the decision surface is a hyperplane, then the classification problem is linear, and the classes are linearly separable.* In a statistical-classification problem with two classes, a decision boundary or decision surface is a hypersurface that partitions the underlying vector space into two sets, one for each class.* You can find a related information to this topic in this [publication](https://towardsdatascience.com/classification-problems-and-exploring-decision-boundaries-3317e03afcdb)<jupyter_code># Plotting the decision boundary 
# from the LogisticRegression model
plot_decision_regions()<jupyter_output>/usr/local/lib/python3.7/dist-packages/mlxtend/plotting/decision_regions.py:244: MatplotlibDeprecationWarning: Passing unsupported keyword arguments to axis() will raise a TypeError in 3.3.
  ax.axis(xmin=xx.min(), xmax=xx.max(), y_min=yy.min(), y_max=yy.max())<jupyter_text>Predictions<jupyter_code># make predictions (assign class labels)
y_pred = 

# show the inputs and predicted outputs
for i in range(len()):
  
# create a data frame
df_new = DataFrame()
# show 12 rows 
df_new.head(_)
# three classes: 'red', 'blue', 'green'

# figure
fig2, ax2 

# new data
grouped = df_new.groupby()

# scatter plot
for key2, group2 in :


# show the plot
plt.show()
# Plotting the new decision boundary 
# from the LogisticRegression model
plot_decision_regions(X_test, y_pred, clf= , legend= )<jupyter_output>/usr/local/lib/python3.7/dist-packages/mlxtend/plotting/decision_regions.py:244: MatplotlibDeprecationWarning: Passing unsupported keyword arguments to axis() will raise a TypeError in 3.3.
  ax.axis(xmin=xx.min(), xmax=xx.max(), y_min=yy.min(), y_max=yy.max())
{'fraction_non_alphanumeric': 0.09775280898876404, 'fraction_numerical': 0.01544943820224719, 'mean_word_length': 6.13627254509018, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 3, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '81678', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1116, 'n_words': 344, 'path': 'Week-2/CS6501_Exercise_2_3.ipynb', 'repo_name': 'KealanMannix/CS6501_SEM1_2021-2', 'size': '3568'}