<jupyter_start><jupyter_text>Banknote AutheticationLet's analyze and preprocess the data. This data was extracted from the [UCI repository](http://archive.ics.uci.edu/ml/datasets/banknote+authentication) which says that:         Data were extracted from images that were taken from genuine and forged banknote-like specimens. For digitization, an industrial camera usually used for print inspection was used. The final images have 400x 400 pixels. Due to the object lens and distance to the investigated object gray-scale pictures with a resolution of about 660 dpi were gained. Wavelet Transform tool were used to extract features from images.So the attribute information are:1. variance of Wavelet Transformed image (continuous)2. skewness of Wavelet Transformed image (continuous)3. curtosis of Wavelet Transformed image (continuous)4. entropy of image (continuous)5. class (integer)   Dependencies<jupyter_code>%matplotlib inline

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import seaborn as sns
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
banknote = pd.read_csv('data_banknote_authentication.txt')
banknote<jupyter_output><empty_output><jupyter_text>Let us adjust the header.<jupyter_code># Get the columns names as array
new_header = banknote.columns.values

#header = new_header.copy()
#header[5]='convenient'
# Create the columns
cols = ['var_wavelet','skewness_wavelet','curtosis_wavelet','entropy','target']
new_header
# Create a DataFrame from the hedader
bna = pd.DataFrame(new_header.astype(float)[None,:],columns=list(new_header))

# Transform the type of classes as integer
bna['0'] = bna['0'].astype('int64')
# Append both the dataframes
bna = bna.append(banknote)
# Rename the columns
cols = {new_header[i]:cols[i] for i in range(new_header.size)}
#cols['0']='target'
bna=bna.rename(columns=cols)


bna.head(10)<jupyter_output><empty_output><jupyter_text>Data information and Description<jupyter_code>bna.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 1372 entries, 0 to 1370
Data columns (total 5 columns):
var_wavelet         1372 non-null float64
skewness_wavelet    1372 non-null float64
curtosis_wavelet    1372 non-null float64
entropy             1372 non-null float64
target              1372 non-null int64
dtypes: float64(4), int64(1)
memory usage: 64.3 KB<jupyter_text>There are no missing data, all the features are of the type float, and the classes are all integers. There are no need to preprocess for while.<jupyter_code>bna.describe()<jupyter_output><empty_output><jupyter_text>There are no need to standarlize, so I will maintain the data the way it is. Now, let's see the class distribution.<jupyter_code>count = bna['target'].value_counts().rename_axis('Unique').to_frame('Counts')
count
plt.bar(np.arange(1),count['Counts'][0],color='b',alpha=0.5, label='Authentic')
plt.bar(np.arange(1)+1,count['Counts'][1],color='r',alpha=0.5, label='Inauthentic')
plt.xlabel('Classes',fontsize=20, labelpad=30)
plt.ylabel('Frequency',fontsize=20, labelpad=30)
plt.xticks(np.arange(2),['0','1'],fontsize=20)
plt.yticks(fontsize=20)
plt.legend()
plt.show()
print("Authentic: {}%".format(round(count['Counts'][0]*100/count['Counts'].sum(),2)))
print("Inauthentic: {}%".format(round(count['Counts'][1]*100/count['Counts'].sum(),2)))
print("Ratio Nasal/Oral: {}%".format(round((count['Counts'][0]/count['Counts'][1])*100,2)))<jupyter_output><empty_output><jupyter_text>The distribution isn't so unequal, so there is nothing to be changed. Let's save the data<jupyter_code>bna.columns
bna.to_csv('banknote.data')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12298442197321673, 'fraction_numerical': 0.0308827548510522, 'mean_word_length': 6.754237288135593, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '302378', 'license': 'MIT', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1185, 'n_words': 323, 'path': 'tests/11 - NSC Data Tests/All folders/Data-tests/comparison/datas/banknote.ipynb', 'repo_name': 'GuilhermeToso/masters-project', 'size': '3659'}