<jupyter_start><jupyter_text>Chapter2. Training Sample ML Algorithm for Classification  Implement a perceptron learning algorithm is Python<jupyter_code># import 
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Data Processing Download and Read dataset<jupyter_code># dataset from URL
DATASET_URL = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"

# read from URL
df = pd.read_csv(DATASET_URL, header= None, encoding='utf-8')<jupyter_output><empty_output><jupyter_text>Data Exploration<jupyter_code># Upper 5 dataset examples
df.head()
# Dataset Categorical
df[4].unique()
# Dataset Categorical value count
df[4].value_counts()
# Ploting the dataset

# select Iris-setosa label
y = df.iloc[50:150, 4].values
y = np.where(y == 'Versicolor', 0, 1)

# extract sepal length and patal length
X = df.iloc[50:150, [0, 2]].values

# plot data
plt.scatter(X[:50, 0], X[:50, 1], color='red', marker='o', label='Versicolor')
plt.scatter(X[50:, 0], X[50:, 1], color='blue', marker='s', label='Virginica')

plt.xlabel('Sepal Length')
plt.ylabel('Patal Lenght')
plt.legend()
plt.grid()
plt.tight_layout()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1437908496732026, 'fraction_numerical': 0.026143790849673203, 'mean_word_length': 6.65625, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '315208', 'license': 'MIT', 'n_tokens_mistral': 484, 'n_tokens_neox': 448, 'n_words': 107, 'path': 'DLwithPytorch/ch2- Training-sample-ml-algorithm-for-classification.ipynb', 'repo_name': 'theaveas/DeepLearning', 'size': '1224'}