<jupyter_start><jupyter_text>Initialization<jupyter_code>from google.colab import drive
drive.mount("/content/drive")
!cp -r /content/drive/MyDrive/Academic/NASSCOM/T2/Dataset.csv /content/
import numpy as np
import pandas as pd
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsRegressor
from sklearn.metrics import accuracy_score, log_loss
from sklearn.model_selection import train_test_split
import seaborn as sn
import matplotlib.pyplot as plt
df = pd.read_csv("/content/Dataset.csv")<jupyter_output><empty_output><jupyter_text>Dataset Before<jupyter_code>df.info()
df.describe()
df.head()<jupyter_output><empty_output><jupyter_text>Replacing in/out with 0/1<jupyter_code>le = preprocessing.LabelEncoder()
df2 = le.fit_transform(df['out/in']) 
df2 = pd.DataFrame(data=df2, columns=['out/in'])
df2.head()
df['out/in'] = df2['out/in']
df.head()<jupyter_output><empty_output><jupyter_text>**Drop the columns which are not required for prediction**<jupyter_code># Remove the 'room_id/id' column 
df = df.drop(['room_id/id'],axis=1)
# Irrelevant column removed
df.head()<jupyter_output><empty_output><jupyter_text>**Drop the rows which have duplicate values**<jupyter_code># Checking for Duplicates
df[df.duplicated()]
df.drop_duplicates(inplace=True)
# Duplicate rows removed
df[df.duplicated()]<jupyter_output><empty_output><jupyter_text>**Replace the missing values with median/mean**<jupyter_code># Checking for Missing values
df.isnull().sum()
df[df.temp.isnull()]
df3 = df.fillna(df.temp.mean())
# Missing values replaced
df3.head()
# No Missing Values 
df3.isnull().sum()<jupyter_output><empty_output><jupyter_text>Replace date string<jupyter_code>df['date'] = pd.to_datetime(df['noted_date'], format='%d-%m-%Y %H:%M')
df['year'] = df['date'].apply(lambda x : x.year)
df['month'] = df['date'].apply(lambda x : x.month)
df['day'] = df['date'].apply(lambda x : x.day)
df['weekofyear'] = df['date'].apply(lambda x : x.weekofyear)
df['hour'] = df['date'].apply(lambda x : x.hour)
df['minute'] = df['date'].apply(lambda x : x.minute)
df.head()
def change(x):
    if x in [22,23,0,1,2,3]:
        t = 0
    elif x in range(4, 12):
        t = 1
    elif x in range(12, 17):
        t = 2
    elif x in range(17, 22):
        t = 3
    else:
        t = 'X'
    return t
df['timing'] = df['hour'].apply(change)
df.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16097766540244415, 'fraction_numerical': 0.014749262536873156, 'mean_word_length': 5.763532763532764, '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': '119302', 'license': 'MIT', 'n_tokens_mistral': 909, 'n_tokens_neox': 886, 'n_words': 181, 'path': 'T2/T2.ipynb', 'repo_name': 'abphilip-vit/College8', 'size': '2373'}