# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda env:root] *
#     language: python
#     name: conda-root-py
# ---

# # Spambase Dataset Analysis
#
# This notebook will analyze and preprocess the spambase dataset. For dataset information go to [UCI repository](https://archive.ics.uci.edu/ml/datasets/spambase). Now, let's import dependencies and the dataset.

# +
# %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
# -

spambase = pd.read_csv('spambase.data')

spambase.dtypes

# +
# Get the columns names as array
new_header = spambase.columns.values

#header = new_header.copy()
#header[5]='convenient'
# Create the columns
cols = ['word_freq_'+str(i) for i in range(48)]
cols = cols + ['char_freq_'+str(i) for i in range(6)]
cols = cols + ['capital_run_length_average', 'capital_run_length_longest', 'capital_run_length_total', 'target']
new_header

# +
# Create a DataFrame from the hedader
sb = pd.DataFrame(new_header[None,:],columns=list(cols))
new_header[2] = '0.64'
new_header[11] = '0.64'
new_header[15] = '0.32'
new_header[40] = '0.32'
sb.loc[0,cols] = new_header.astype(float)
sb = sb.astype(float)
#sb['0.64.1'] = '0.64'
#sb['0.64.2'] = '0.64'
#sb['0.32.1'] = '0.32'
#sb['0.32.2'] = '0.32'

#sb = sb.astype(float)
# Transform the type of classes as integer
sb['capital_run_length_average'] = sb['capital_run_length_average'].astype(int)
sb['capital_run_length_longest'] = sb['capital_run_length_longest'].astype(int)
sb['capital_run_length_total'] = sb['capital_run_length_total'].astype(int)
sb['target'] = sb['target'].astype(int)


# Append both the dataframes
sb

# -

sb.dtypes

sb.append(spambase)

sb



StarcoderdataJupyterScriptsDedupFiltered