input: Write a python function to preprocess a dataset for machine learning. The function should load data, remove irrelevant columns, scale numerical features, apply One Hot Encoding to categorical features, and split the data into training and test sets.
  assert X_train.shape[0] == 0.8 * data.shape[0]
  assert X_test.shape[0] == 0.2 * data.shape[0]
  assert 'categorical_feature1_encoded' in X.columns
  assert 'numerical_feature1' in X.columns
output: from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import StandardScaler, OneHotEncoder
  import pandas as pd
  
  def preprocess_data(filepath, irrelevant_columns, categorical_features, numerical_features):
      # Load data
      data = pd.read_csv(filepath)
  
      # Remove irrelevant columns
      data = data.drop(columns=irrelevant_columns)
  
      # Scale numerical features
      scaler = StandardScaler()
      data[numerical_features] = scaler.fit_transform(data[numerical_features])
  
      # Apply One Hot Encoding to categorical features
      encoder = OneHotEncoder(sparse=False, drop='first')
      encoded_categories = encoder.fit_transform(data[categorical_features])
      encoded_df = pd.DataFrame(encoded_categories, columns=encoder.get_feature_names_out(categorical_features))
      data = data.drop(columns=categorical_features)
      data = pd.concat([data, encoded_df], axis=1)
  
      # Split the data into training and test sets
      X = data.drop(columns=['target'])
      y = data['target']
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
  
      return X_train, X_test, y_train, y_test