ForwardFill

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

Bases: object

About this algorithm

Description:

Forward Fill imputes missing values using the previous valid entry, with backward fill as a fallback for trailing NaNs.

Parameters:
  • dataframe (pd.DataFrame): Input dataset where the first two columns are assumed to be spatial (‘x’, ‘y’) and all remaining columns are treated as features to be imputed.

Attributes:
  • df (pd.DataFrame): Copy of the input data, with the first two columns renamed to ‘x’, ‘y’.

  • imputedDF (pd.DataFrame): Output DataFrame after missing value imputation.

Execution methods

import pandas as pd

from geoanalytics.imputation import ForwardFill

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

ff = ForwardFill(df)

imputed_df = ff.impute()

ff.save("ForwardFilled.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 forward fill imputation followed by backward fill as fallback.

Returns:

A pandas DataFrame with the original spatial coordinates and imputed feature values.

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

Saves the imputed DataFrame to a CSV file.

Parameters:

outputFile – The filename for saving the DataFrame. Defaults to ‘ForwardFilled.csv’.