input: Write a function to create a machine learning algorithm in Python to categorize a dataset of records. The function should take in a list of dictionaries where each dictionary contains a label and a list of features, and return a predicted label for a given set of features.
  
  assert categorize([{"label": "apple", "features": [1, 1, 0]}, {"label": "banana", "features": [0, 1, 1]}, {"label": "lemon", "features": [0, 0, 1]}, {"label": "orange", "features": [1, 0, 0]}, {"label": "pear", "features": [0, 1, 0]}], [1, 0, 1])=="banana"
output: 
  def categorize(dataset, features):
      from sklearn.neighbors import KNeighborsClassifier
      X = [entry["features"] for entry in dataset]
      y = [entry["label"] for entry in dataset]
      knn = KNeighborsClassifier(n_neighbors=1)
      knn.fit(X, y)
      return knn.predict([features])[0]
  