BackwardFill

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

Bases: object

About this algorithm

Description:

Backward Fill imputes missing values using the next valid observation, with forward fill as a fallback for leading NaNs.

Parameters:
  • dataframe (pd.DataFrame) – Input dataset containing spatial columns (‘x’, ‘y’) followed by features with potential missing values.

Attributes:
  • df (pd.DataFrame) – Cleaned copy of input data with ‘x’, ‘y’ as first two columns.

  • imputedDF (pd.DataFrame) – Resulting DataFrame after imputation, preserving spatial columns.

Execution methods

import pandas as pd

from geoanalytics.imputation import BackwardFill

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

imputer = BackwardFill(df)

output = imputer.impute()

imputer.save("BackwardFilled.csv")

Credits

This implementation was created and revised 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 algorithm.

run()[source]

Applies backward fill followed by forward fill to impute missing values in the feature columns.

Returns:

A DataFrame containing original ‘x’, ‘y’ columns and imputed feature columns.

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

Saves the imputed DataFrame to a CSV file.

Parameters:

outputFile – Filename to save the resulting DataFrame.