ModeImputation

class geoanalytics.imputation.ModeImputation.ModeImputation(dataframe)[source]

Bases: object

About this algorithm

Description:

Mode Imputation replaces missing values in each column of a dataset with the most frequent value (mode) of that column. It is a simple and fast technique for handling missing data, particularly useful when the dataset has categorical features or dominant repeated values.

Parameters:
  • Dataset (pandas DataFrame) must be provided during object initialization.

  • No parameters are needed for run().

Attributes:
  • df (pd.DataFrame) – The input data with ‘x’, ‘y’ coordinates and features.

  • imputedDF (pd.DataFrame) – DataFrame after filling in missing values with mode.

  • startTime, endTime (float) – Variables to track execution time.

  • memoryUSS, memoryRSS (float) – Memory usage of the imputation process in kilobytes.

Execution methods

Calling from a Python program

import pandas as pd

from geoanalytics.imputation import ModeImputation

df = pd.read_csv("input.csv")

mode_imputer = ModeImputation(df)

imputed_df = mode_imputer.run()

mode_imputer.getRuntime()
mode_imputer.getMemoryUSS()
mode_imputer.getMemoryRSS()

mode_imputer.save('ModeImputation.csv')

Credits

This implementation was created by Raashika and revised by M.Charan Teja under the guidance of Professor Rage Uday Kiran.

getMemoryRSS()[source]

Prints the memory usage (RSS) of the process in kilobytes.

getMemoryUSS()[source]

Prints the memory usage (USS) of the process in kilobytes.

getRuntime()[source]

Prints the total runtime of the clustering algorithm.

run()[source]

Executes the mode imputation algorithm by filling missing values with column-wise mode.

Returns:

imputedDF (pd.DataFrame) – DataFrame with missing values filled

save(outputFile='ModeImputation.csv')[source]

Saves the imputed DataFrame to a CSV file.

Parameters:

outputFile – str, filename to save the imputed data (default: ‘ModeImputation.csv’)