A fruit stall's table has gaps in its number columns and a colour column with words. Build one leak-free pipeline that learns everything from the training rows only.
Task: write fruit_machine(table, labels, new_rows, seed).
table is a dict with number columns "weight" and "sweet" (which may contain None) and a word column "colour". labels holds the answer for each row.new_rows is a dict with the same three columns, holding one or more new fruits.train_test_split(X, y, test_size=0.25, random_state=seed, stratify=y).ColumnTransformer with ("numbers", ..., ["weight", "sweet"]), where ... is a Pipeline of SimpleImputer(strategy="median") then StandardScaler(). Add ("words", OneHotEncoder(handle_unknown="ignore"), ["colour"]).KNeighborsClassifier(n_neighbors=3) as the last step.{"score": test score rounded to 3 decimal places, "predictions": list of predictions for new_rows}.Make the number columns float so each None becomes np.nan.