<jupyter_start><jupyter_text>Assignment 4 @author : @ruhend DATA PRE-PROCESSING   Need of pre-processing Real world data are usually- Inconsistent: containing discrepancies in codes or names.- Incomplete: lacking attribute values, lacking certain attributes of --interest, or containing only aggregate data.- Noisy: containing errors or outliers.  What is data pre-processing - Preprocessing refers to the transformations applied to the data before feeding it to the machine learning algorithms.- The data gathered from different sources is collected in raw format which is not feasible for the analysis.- Data Preprocessing technique is used to convert the raw data into a clean data set.<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset = pd.read_csv("company_data.csv")
print ('dataset: %s'%(str(dataset.shape)))
dataset
dataset.isnull().sum()
dataset.isnull().sum().sum()<jupyter_output><empty_output><jupyter_text>Droppping the Unwanted data columns<jupyter_code>dataset=dataset.drop(['votes','views','media_type','content','followers'], axis=1)
dataset<jupyter_output><empty_output><jupyter_text>Replacing missing values using Python functions<jupyter_code># forward fill
dataset.ffill(inplace = True)
dataset
dataset.isnull().sum().sum()
# Backward fill
dataset.bfill(inplace = True)
dataset
dataset.isnull().sum().sum()<jupyter_output><empty_output><jupyter_text>Replacing Missing Values with Mean Values of the columns<jupyter_code>dataset.fillna(np.mean(dataset["reactions"]),inplace = True) #Using python function fillna
dataset
dataset.isnull().sum().sum()<jupyter_output><empty_output><jupyter_text>Replacing missing values with a global constant<jupyter_code>dataset.fillna(0.00000,inplace = True)
dataset
dataset.isnull().sum().sum()<jupyter_output><empty_output><jupyter_text>Eliminating the missing value rows<jupyter_code>dataset.dropna(axis=0,inplace=True)  #using dropna function
dataset
dataset.isnull().sum().sum()<jupyter_output><empty_output><jupyter_text>Handling the noisy data<jupyter_code>min_value = dataset['reactions'].min()
max_value = dataset['reactions'].max()
bins = np.linspace(min_value,max_value,25)
labels = bins[1:]
dataset['reactions_Bin'] = pd.cut(dataset['reactions'], bins=bins, labels=labels, include_lowest=True)
dataset<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11329628046173579, 'fraction_numerical': 0.005130397605814451, 'mean_word_length': 8.176470588235293, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '268998', 'license': 'MIT', 'n_tokens_mistral': 727, 'n_tokens_neox': 700, 'n_words': 185, 'path': 'CSE_310L-Data Warehouseing and Mining Lab/Assignment-4/LAB_4_DATA PROCESSING_AP19110010169.ipynb', 'repo_name': 'ruhend/Semester-5-labs', 'size': '2339'}