input: Write a python function to create a dataframe from a list of documents using TF-IDF vectorization and classify them based on predefined categories.
  assert classify_documents(["This document is about Machine Learning", "This document is about Natural Language Processing"], ["Machine Learning", "Natural Language Processing"]) == ["Machine Learning", "Natural Language Processing"]
  assert classify_documents(["Deep learning is a part of machine learning", "NLP stands for Natural Language Processing"], ["Machine Learning", "Natural Language Processing"]) == ["Machine Learning", "Natural Language Processing"]
output: def classify_documents(documents, categories):
      from sklearn.feature_extraction.text import TfidfVectorizer
      from sklearn.preprocessing import LabelEncoder
      from sklearn.neighbors import KNeighborsClassifier
      import pandas as pd
  
      # Create TF-IDF Vectorizer
      vectorizer = TfidfVectorizer()
      X = vectorizer.fit_transform(documents)
  
      # Encode categories
      label_encoder = LabelEncoder()
      y = label_encoder.fit_transform(categories)
  
      # Create a DataFrame with TF-IDF features
      feature_names = vectorizer.get_feature_names_out()
      df = pd.DataFrame(X.toarray(), columns=feature_names)
  
      # Train a KNN classifier
      classifier = KNeighborsClassifier(n_neighbors=1)
      classifier.fit(X, y)
  
      # Predict the categories for the documents
      predicted_labels = classifier.predict(X)
      predicted_categories = label_encoder.inverse_transform(predicted_labels)
  
      return list(predicted_categories)