MeanImputation

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

Bases: object

About this algorithm

Description:

MeanImputation fills missing values in a dataset by replacing them with the mean of their respective columns.

Parameters:
  • dataframe (pd.DataFrame) – A Pandas DataFrame containing missing values.

  • The first two columns must represent spatial/positional attributes, typically ‘x’ and ‘y’.

Attributes:
  • df (pd.DataFrame) – Original dataframe with renamed first two columns (‘x’, ‘y’) and copied features.

  • imputedDF (pd.DataFrame) – Stores the resulting dataframe after mean imputation.

Execution methods

Calling from a Python program

import pandas as pd

from geoanalytics.imputation import MeanImputation

df = pd.read_csv('data_with_nans.csv')

obj = MeanImputation(df)

imputed_df = obj.impute()

obj.save('MeanImputation.csv')

Credits

The complete program was written by and revised by under the supervision 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 algorithm.

run()[source]

Performs mean imputation on all feature columns (excluding x and y).

Returns:

DataFrame with ‘x’, ‘y’, and imputed features.

Return type:

pd.DataFrame

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

Saves the imputed DataFrame to a CSV file.

Parameters:

outputFile (str) – File path to save the output. Defaults to ‘MeanImputation.csv’.