input: Write a python function to predict the probability of a book being a bestseller using a logistic regression model trained on the given dataset.
  assert predict_bestseller('title1', 'genre1', 'author1', 'publisher1', 2020, 100, 4.5) >= 0.0
  assert predict_bestseller('title2', 'genre2', 'author2', 'publisher2', 2019, 50, 3.8) >= 0.0
  assert predict_bestseller('title3', 'genre3', 'author3', 'publisher3', 2021, 200, 4.9) >= 0.0
output: import pandas as pd
  from sklearn.linear_model import LogisticRegression
  
  # Sample dataset
  data = {
      'title': ['title1', 'title2', 'title3', 'title4'],
      'genre': ['genre1', 'genre2', 'genre3', 'genre4'],
      'author': ['author1', 'author2', 'author3', 'author4'],
      'publisher': ['publisher1', 'publisher2', 'publisher3', 'publisher4'],
      'year': [2020, 2019, 2021, 2020],
      'sales': [100, 50, 200, 150],
      'rating': [4.5, 3.8, 4.9, 4.0],
      'bestseller': [1, 0, 1, 0]  # Target variable
  }
  
  df = pd.DataFrame(data)
  
  # Feature selection and one-hot encoding categorical variables
  X = pd.get_dummies(df[['genre', 'author', 'publisher', 'year', 'sales', 'rating']])
  y = df['bestseller']
  
  # Train logistic regression model
  model = LogisticRegression()
  model.fit(X, y)
  
  def predict_bestseller(title, genre, author, publisher, year, sales, rating):
      # Create a DataFrame for the new data
      new_data = pd.DataFrame({
          'genre': [genre],
          'author': [author],
          'publisher': [publisher],
          'year': [year],
          'sales': [sales],
          'rating': [rating]
      })
      
      # One-hot encode the new data
      new_data_encoded = pd.get_dummies(new_data)
      
      # Ensure that the new data has the same columns as the training data
      new_data_encoded = new_data_encoded.reindex(columns=X.columns, fill_value=0)
      
      # Predict the probability of being a bestseller
      probability = model.predict_proba(new_data_encoded)[0][1]
      
      return probability