How does the f_regression function handle features with missing values - are they simply dropped?

Viewed 26

I am building a simple regression model in with scikit-learn. My dataset has thousands of features and roughly 600 rows. As a simple feature selection strategy to set my baseline, I am using the f_regression function with SelectKBest - SelectKBest(score_func=f_regression, k=50). My goal is to select the 50 best features. However, a large proportion of these columns have missing values. Without imputing values/dropping them, how does this feature selection strategy handle these features?

My function for selecting the features is below (note I am building a number of models - which are denoted by the key used in the function)

def process_training_and_test_data_for_LG(df):
    training_datasets = {}
    test_datasets = {}
    for drug in df.keys():
        
        print("at "+drug)
        X = df[drug].drop(["cell_line_name", "ln_IC50","putative_target"], axis=1)
        y = df[drug]["ln_IC50"]
        X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)


        #Select 50 top correlated features
        feature_selector = SelectKBest(score_func=f_regression, k=50)
        feature_selector.fit(X_train, y_train)
    
        X_train = feature_selector.transform(X_train)
        X_test = feature_selector.transform(X_test)
    
        #Add data to relevant dictionaries
        training_datasets[drug] = [X_train, y_train]
        test_datasets[drug] = [X_test, y_test]

    return training_datasets, test_datasets
0 Answers
Related