input: Write a python function to train a logistic regression model for sentiment analysis. Use the provided data split and transformation steps. Ensure the function takes in a file path for the dataset and returns the accuracy of the model on the test set.
  assert round(train_logistic_regression('data.csv'), 2) == 0.85
  assert round(train_logistic_regression('another_data.csv'), 2) == 0.78
output: def train_logistic_regression(file_path):
      import pandas as pd
      from sklearn.model_selection import train_test_split
      from sklearn.feature_extraction.text import TfidfVectorizer
      from sklearn.linear_model import LogisticRegression
      from sklearn.metrics import accuracy_score
  
      # Load dataset
      data = pd.read_csv(file_path)
      
      # Ensure the dataset has 'text' and 'sentiment' columns
      assert 'text' in data.columns and 'sentiment' in data.columns
  
      # Split data into training and test sets
      X_train, X_test, y_train, y_test = train_test_split(data['text'], data['sentiment'], test_size=0.2, random_state=42)
  
      # Transform text data to TF-IDF features
      vectorizer = TfidfVectorizer()
      X_train_tfidf = vectorizer.fit_transform(X_train)
      X_test_tfidf = vectorizer.transform(X_test)
  
      # Train logistic regression model
      model = LogisticRegression()
      model.fit(X_train_tfidf, y_train)
  
      # Predict on test set
      y_pred = model.predict(X_test_tfidf)
  
      # Calculate accuracy
      accuracy = accuracy_score(y_test, y_pred)
  
      return accuracy