<jupyter_start><jupyter_text>Abstract  Iris Dataset Iris ClassificationThe Iris dataset was used in R.A. Fisher's classic 1936 paper, The Use of Multiple Measurements in Taxonomic Problems, and can also be found on the UCI Machine Learning Repository.It includes three iris species with 50 samples each as well as some properties about each flower. One flower species is linearly separable from the other two, but the other two are not linearly separable from each other. Second Datasetthe WBCD (Wisconsin Breast Cancer Diagnosis) dataset is employed. This dataset is widelyutilized for this kind of application because it has a large number of instances (699), is virtuallynoise-free and has just a few missing values. Third DatasetBanknotes are one of the most important assets of a country. Some miscreants introduce fakenotes which bear a resemblance to original note to create discrepancies of the money in the¦nancial market. It is di¨cult for humans to tell true and fake banknotes apart especiallybecause they have a lot of similar features. Forth DatasetFashion-MNIST is a dataset of Zalando's article images—consisting of a training set of 60,000examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image,associated with a label from 10 classes.<jupyter_code>#Import required libraries 
import keras #library for neural network
import pandas as pd #loading data in table form  
import seaborn as sns #visualisation 
import matplotlib.pyplot as plt #visualisation
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from sklearn.preprocessing import normalize #machine learning algorithm library
#Neural network module
from keras.models import Sequential 
from keras.layers import Dense,Activation,Dropout 
from keras.layers.normalization import BatchNormalization 
from keras.utils import np_utils
from sklearn.metrics import classification_report
from sklearn.metrics import f1_score, roc_auc_score, log_loss
from sklearn.model_selection import cross_val_score, cross_validate
from keras.optimizers import SGD
from sklearn import metrics
from sklearn.metrics import accuracy_score
from sklearn.metrics import precision_score
from sklearn.metrics import recall_score
from sklearn.metrics import cohen_kappa_score
from sklearn.metrics import confusion_matrix
#Reading data 
data=pd.read_csv("/content/Iris.csv")
data.loc[data["Species"]=="Iris-setosa","Species"]=0
data.loc[data["Species"]=="Iris-versicolor","Species"]=1
data.loc[data["Species"]=="Iris-virginica","Species"]=2
print(data.head())
data=data.iloc[np.random.permutation(len(data))]
print(data.head())
X=data.iloc[:,1:5].values
y=data.iloc[:,5].values
X_normalized=normalize(X,axis=0)
total_length=len(data)
train_length=int(0.8*total_length)
test_length=int(0.2*total_length)

X_train=X_normalized[:train_length]
X_test=X_normalized[train_length:]
y_train=y[:train_length]
y_test=y[train_length:]
y_train=np_utils.to_categorical(y_train,num_classes=3)
y_test=np_utils.to_categorical(y_test,num_classes=3)<jupyter_output><empty_output><jupyter_text>Model ConstructionThe most simple neural network is the “perceptron”, which, in its simplest form, consists of a single neuron. Much like biological neurons, which have dendrites and axons, the single artificial neuron is a simple tree structure which has input nodes and a single output node, which is connected to each input node. Here’s a visual comparison of the two:![image.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAD5CAYAAADfqVESAAAgAElEQVR4Aex9BZiVR5b27r8y6+6+sztrMzs7yUQmNpkIUSBAcG3au3EI0kAr7hI8QVvxJE<KEY>BWI<KEY>//<KEY>//<KEY>//p55/x6OFD9Ovrj7Vr1pimCXbkXnT/tJtxxkQRrA/eb4MRIxLwy/XrpozQkGBDBDH9yKwsxEXHGK5Em/feM2YcWdjM6dPQ6eOORmGVi38SUYUFBaYeIRiqq6rg26uXEZ3ijckTJyEvb5rh1vj38cM331hiD2UlJRgyeAh27vwKvj374Py585gwPhdZzszHyiMH5W9vv4PpedNMPD8m7B8NGqxetRqffdodJ0+eMPdKi0vR06en4XCkp6YbQoWLEX6ohg0dht49exkrLzRq8OUOy8nhmOwxGFcv+ytjZAprgT8Zi40bN2N4QrKxyDNt+gx07doNEyZMRfbYXOza3SC62AJN8OoiBV8lQBqGWTgfBw99i85dOqGPny/Onz2NK9fuYHzBKgSnzENYWjnCHRWIzKpEuKsCka5yRGaWINJViGhnEaKdpYh1VSCG8enFCEuZh0hHCeav+RoPHgFr16zAX9/9q9lwEL2M532XhPBgD5Z98QUyMzPdvik4vs9SrjwHW7ZsweRJk91EPXfB6flaHMiRqy7lcZeb3F4NrQMBGRcSIF26dDG+PCZNmmzM6dKyGQkOsZZJDghNBnMMydEQrju5XBS5W7V6tSE2hGPCHpLQJBFD7hgD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QCSoA0hczT4i3xKSqqu6mTJpKT48F0wj1pIplGKwKKgCLwxiCgBMgbM9TaUUVAEVAEGkdACZDGcXnWWBIWllgVdUUe/ynR8awoajpFQBF4kxBQAuRNGm3tqyKgCCgCjSCgBEgjoGiUIqAIKAKKQIshoARIi0GrBSsCioAi8HogoATI6zFO2kpFQBFQBLwFASVAvGUktR+KgCKgCDwnAkqAPCdwmk0RUAQUAUXguRBQAuS5YNNMioAioAh4DwJCgOzatQv8MUic9/RSe6IIKAKKgCLQWhBQAqS1jIS2QxFQBBSB3wgBUZQ+duwY+GOQuN+oSVqtIqAIKAKKgBcjoASIFw+udk0RUAQUAUVAEVAEFAFFQBFobQgoAdLaRkTbowgoAoqAIqAIKAKKgCKgCHgxAkqAePHgatcUAUVAEVAEFAFFQBFQBBSB1oaAEiCtbUS0PYqAIqAIKAKKgCKgCCgCioAXI6AEiBcPrnZNEVAEFAFFQBFQBBQBRUARaG0IKAHS2kZE26MIKAKKgCKgCCgCioAioAh4MQJKgHjx4GrXFAFFQBFQBBQBRUARUAQUgdaGgBIgrW1EtD2KgCKgCCgCioAioAgoAoqAFyOgBIgXD652TRFQBBQBRUARUAQUAUVAEWhtCCgB0tpGRNujCCgCioAioAgoAoqAIqAIeDECSoB48eBq1xQBRUARUAQUAUVAEVAEFIHWhoASIK1tRLQ9ioAioAgoAoqAIqAIKAKKgBcjoASIFw+udk0RUAQUAUVAEVAEFAFFQBFobQgoAdLaRkTbowgoAoqAIqAIKAKKgCKgCHgxAkqAePHgatcUAUVAEVAEFAFFQBFQBBSB1oaAEiCtbUS0PYqAIqAIKAKKgCKgCCgCioAXI6AEiBcPrnZNEVAEFAFFQBFQBBQBRUARaG0IKAHS2kZE26MIKAKKgCKgCCgCioAioAh4MQJKgHjx4GrXFAFFQBFQBBQBRUARUAQUgdaGwP8HXsfhB0IWrp0AAAAASUVORK5CYII=)As you can see from the picture, there are six components to artificial neurons. From left to right, these are:Input nodes. As it so happens, each input node is associated with a numerical value, which can be any real number. Remember that real numbers make up the full spectrum of numbers: they can be positive or negative, whole or decimal numbers.Connections. Similarly, each connection that departs from the input node has a weight associated with it, and this can also be any real number.Next, all the values of the input nodes and weights of the connections are brought together: they are used as inputs for a weighted sum: y=f(∑Di=1wi∗xi), or, stated differently, y=f(w1∗x1+w2∗x2+...wD∗xD).This result will be the input for a transfer or activation function. In the simplest but trivial case, this transfer function would be an identity function, f(x)=x or y=x. In this case, x is the weighted sum of the input nodes and the connections. However, just like a biological neuron only fires when a certain threshold is exceeded, the artificial neuron will also only fire when the sum of the inputs exceeds a threshold, let’s say for example 0. This is something that you can’t find back in an identity function! The most intuitive way that one can think of is by devising a system like the following:f(x)=0 if x<0f(x)=0.5 if x=0f(x)=1 if x>0The sigmoid function, is often used. An example of a sigmoid function. Using this function results in a much smoother result!As a result, you have the output node, which is associated with the function (such as the sigmoid function) of the weighted sum of the input nodes. Note that the sigmoid function is a mathematical function that results in an “S” shaped curve; the perceptron may be an additional parameter, called a bias, which you can consider as the weight associated with an additional input node that is permanently set to 1. The bias value is critical because it allows you to shift the activation function to the left or right, which can make a determine the success of your learning. Multi-Layer PerceptronsNetworks of perceptrons are multi-layer perceptrons, Multi-layer perceptrons are also known as “feed-forward neural networks”. They consist of multiple neurons that are organized in layers. The number of layers is usually limited to two or three, but theoretically, there is no limit!The layers act very much like the biological neurons that you have read about above: the outputs of one layer serve as the inputs for the next layer.Among the layers, you can distinguish an input layer, hidden layers, and an output layer. Multi-layer perceptrons are often fully connected. This means that there’s a connection from each perceptron in a specific layer to each perceptron in the next layer. Even though the connectedness is no requirement, this is typically the case.Note that while the perceptron could only represent linear separations between classes, the multi-layer perceptron overcomes that limitation and can also represent more complex decision boundaries.<jupyter_code>model=Sequential()
model.add(Dense(100,input_dim=4,activation='relu'))
model.add(Dense(50,activation='relu'))
model.add(Dense(3,activation='softmax'))
model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])
model.summary()<jupyter_output><empty_output><jupyter_text>Model TrainingIn compiling, you configure the model with the adam optimizer and the binary_crossentropy loss function. Additionally, you can also monitor the accuracy during the training by passing ['accuracy'] to the metrics argument.The optimizer and the loss are two arguments that are required if you want to compile the model. you’ll need to tune certain parameters, such as learning rate or momentum. The choice for a loss function depends on the task that you have at hand: for example, you need to used binary_crossentropy for the binary classification. Lastly, with multi-class classification, you’ll make use of categorical_crossentropy.After, you can train the model for 50 epochs or iterations over all the samples in X_train and y_train, in batches of 1 sample. You can also specify the verbose argument. By setting it to 1, you indicate that you want to see progress bar logging.In other words, you have to train the model for a specified number of epochs or exposures to the training dataset. An epoch is a single pass through the entire training set, followed by testing of the verification set. The batch size that you specify in the code above defines the number of samples that going to be propagated through the network. Also, by doing this, you optimize the efficiency because you make sure that you don’t load too many input patterns into memory at the same time.<jupyter_code>history = model.fit(X_train,y_train,validation_data=(X_test,y_test),batch_size=20,epochs=50,verbose=1, validation_split=0.2, shuffle=True)<jupyter_output><empty_output><jupyter_text>Model EvaluationNow that you have built your model and used it to make predictions on data that your model hadn’t seen yet, it’s time to evaluate its performance. You can visually compare the predictions with the actual test labels (y_test), or you can use all types of metrics to determine the actual performance. In this case, you’ll use evaluate() to do this. Pass in the test data and test labels and if you want, put the verbose argument to 1.The score is a list that holds the combination of the loss and the accuracy.<jupyter_code>score = model.evaluate(X_test, y_test,verbose=1)
score<jupyter_output><empty_output><jupyter_text>Model Evaluation Chartstrain vs test loss, train and test accuracy, F1-Score is a weighted average of precision and recall.<jupyter_code>print(history.history.keys())
# summarize history for accuracy
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
y_pred = model.predict(X_test)
y_pred = (y_pred > 0.5) 
print('Macro-F1-Score:', f1_score(y_test, y_pred, average='macro'))
pd.DataFrame(history.history).plot(figsize=(15,10))<jupyter_output><empty_output><jupyter_text>Fashion MNIST Classification<jupyter_code>#read mnist fashion dataset
mnist = keras.datasets.fashion_mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()
print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)
#reshape data from 3-D to 2-D array
X_train = X_train.reshape(60000, 784)
X_test = X_test.reshape(10000, 784)
#feature scaling
from sklearn.preprocessing import MinMaxScaler
minmax = MinMaxScaler()
#fit and transform training dataset
X_train = minmax.fit_transform(X_train)
#transform testing dataset
X_test = minmax.transform(X_test)
print('Number of unique classes: ', len(np.unique(y_train)))
print('Classes: ', np.unique(y_train))<jupyter_output><empty_output><jupyter_text>Model Construction<jupyter_code>model_mnist = Sequential()
model_mnist.add(Dense(input_dim = X_train.shape[1], units = 256, kernel_initializer='uniform', activation='relu'))
model_mnist.add(Dense(units = 128, kernel_initializer='uniform', activation='relu'))
model_mnist.add(Dense(units = 10, kernel_initializer='uniform', activation='softmax'))
# Compile model
epochs = 50
learning_rate = 0.001
decay_rate = learning_rate / epochs
momentum = 0.8
sgd = SGD(lr=learning_rate, momentum=momentum, decay=decay_rate, nesterov=False)
#compile the neural network
model_mnist.compile(optimizer=sgd, loss='sparse_categorical_crossentropy', metrics=['accuracy'])
#model summary
model_mnist.summary()<jupyter_output><empty_output><jupyter_text>Model Training<jupyter_code>#fit training dataset into the model
history_mnist = model_mnist.fit(X_train, y_train, validation_data=(X_test,y_test),batch_size=20, epochs=100,verbose=1, validation_split=0.2, shuffle=True)<jupyter_output><empty_output><jupyter_text>Model Evaluation<jupyter_code>score_mnist = model_mnist.evaluate(X_test, y_test,verbose=1)
score_mnist<jupyter_output><empty_output><jupyter_text>Model Evaluation Charts<jupyter_code>print(history_mnist.history.keys())
# summarize history for accuracy
plt.plot(history_mnist.history['accuracy'])
plt.plot(history_mnist.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history_mnist.history['loss'])
plt.plot(history_mnist.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
f1_e25 = f1_score(y_test, model_mnist.predict_classes(X_test), average='micro')
f1_e25
pd.DataFrame(history_mnist.history).plot(figsize=(15,10))<jupyter_output><empty_output><jupyter_text>Bank Note Classification<jupyter_code>banknote_data = pd.read_csv('/content/BankNote_Authentication.csv')
banknote_data.head()
X = banknote_data.drop('class', axis=1) #Input variables
# axis=1 indicates that a column will be dropped
y = banknote_data['class']  # Target variable
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X=pd.DataFrame(scaler.fit_transform(X),columns=X.columns)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<jupyter_output><empty_output><jupyter_text>Model Construction<jupyter_code># Building the model
model_banknote = Sequential()
model_banknote.add(Dense(200, activation='relu', input_shape=(X_train.shape[1],)))
model_banknote.add(Dense(50, activation='relu'))   
model_banknote.add(Dense(1, activation='sigmoid'))
model_banknote.summary()<jupyter_output><empty_output><jupyter_text>Model Training<jupyter_code>from tensorflow.keras.callbacks import EarlyStopping
early_stopping = EarlyStopping()
custom_early_stopping = EarlyStopping(
    monitor='val_accuracy', 
    patience=8, 
    min_delta=0.001, 
    mode='max'
)
# Compile model
epochs = 50
learning_rate = 0.001
decay_rate = learning_rate / epochs
momentum = 0.8
sgd = SGD(lr=learning_rate, momentum=momentum, decay=decay_rate, nesterov=False)
model_banknote.compile(loss='binary_crossentropy', optimizer=sgd, metrics=['accuracy'])
# Fit the model
history_banknote = model_banknote.fit(X_train, y_train, validation_split=0.33, epochs=epochs, batch_size=28, verbose=2)<jupyter_output><empty_output><jupyter_text>Model Evaluation<jupyter_code>score_banknote = model_banknote.evaluate(X_test, y_test,verbose=1)
score_banknote<jupyter_output><empty_output><jupyter_text>Model Evaluation Charts<jupyter_code>print(history_banknote.history.keys())
# summarize history for accuracy
plt.plot(history_banknote.history['accuracy'])
plt.plot(history_banknote.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history_banknote.history['loss'])
plt.plot(history_banknote.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
f1_banknote = f1_score(y_test, model_banknote.predict_classes(X_test), average='micro')
f1_banknote
pd.DataFrame(history_banknote.history).plot(figsize=(15,10))<jupyter_output><empty_output><jupyter_text>Wisconsin Brest Cancer Classification<jupyter_code>data_wbc = pd.read_csv('/content/data.csv')
data_wbc.head()<jupyter_output><empty_output><jupyter_text>Data Pre-Processing<jupyter_code>data_wbc.drop("id",axis=1, inplace=True)
data_wbc
data_wbc.drop("Unnamed: 32",axis=1, inplace=True)
data_wbc
from sklearn.preprocessing import LabelEncoder
le=LabelEncoder()
data_wbc["diagnosis"]=le.fit_transform(data_wbc["diagnosis"])
data_wbc<jupyter_output><empty_output><jupyter_text>Data Train-Test Split<jupyter_code>X=data_wbc.drop("diagnosis",axis=1)
X=X.values
X
y=data_wbc["diagnosis"]
y=y.values
y
X_train,X_test,y_train,y_test=train_test_split(X,y, test_size=0.2)
from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
X_train=sc.fit_transform(X_train)
X_train
X_test=sc.transform(X_test)
X_test<jupyter_output><empty_output><jupyter_text>Model Construction<jupyter_code># Building the model
model_wbc = Sequential()
model_wbc.add(Dense(150, activation='relu', input_dim=30))
model_wbc.add(Dense(50, activation='relu'))   
model_wbc.add(Dense(len(data_wbc["diagnosis"].shape), activation='sigmoid'))
model_wbc.summary()<jupyter_output><empty_output><jupyter_text>Model Training<jupyter_code>from tensorflow.keras.callbacks import EarlyStopping
early_stopping = EarlyStopping()
custom_early_stopping = EarlyStopping(
    monitor='val_accuracy', 
    patience=8, 
    min_delta=0.001, 
    mode='max'
)
# Compile model
epochs = 50
learning_rate = 0.001
decay_rate = learning_rate / epochs
momentum = 0.8
sgd = SGD(lr=learning_rate, momentum=momentum, decay=decay_rate, nesterov=False)
model_wbc.compile(loss='binary_crossentropy', optimizer=sgd, metrics=['accuracy'])
# Fit the model
history_wbc = model_wbc.fit(X_train, y_train, validation_split=0.33, epochs=epochs, batch_size=28, verbose=2)<jupyter_output><empty_output><jupyter_text>Model Evaluation<jupyter_code>score_wbc = model_wbc.evaluate(X_test, y_test,verbose=1)
score_wbc<jupyter_output><empty_output><jupyter_text>Model Evaluaiton Charts<jupyter_code>print(history_wbc.history.keys())
# summarize history for accuracy
plt.plot(history_wbc.history['accuracy'])
plt.plot(history_wbc.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
# summarize history for loss
plt.plot(history_wbc.history['loss'])
plt.plot(history_wbc.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
f1_wbc = f1_score(y_test, model_wbc.predict_classes(X_test), average='micro')
f1_wbc
pd.DataFrame(history_wbc.history).plot(figsize=(15,10))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07038462848771847, 'fraction_numerical': 0.06214015603175144, 'mean_word_length': 11.668968493741907, 'pattern_counts': {'":': 0, '<': 94, '<?xml version=': 0, '>': 95, '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': '22', 'dir': 'jupyter-structured-clean-dedup', 'id': '509205', 'license': 'MIT', 'n_tokens_mistral': 14938, 'n_tokens_neox': 13864, 'n_words': 1695, 'path': 'HappyMonk_Experiment_book.ipynb', 'repo_name': 'vdnew/Artificial-Neural-Network-Experiments', 'size': '128313'}