from sklearn.model_selection import GroupKFold
from sklearn import datasets
from sklearn.linear_model import LinearRegression
diabetes = datasets.load_diabetes() # Load dataset
X = # Split the data into features and target
y =
groups =[:,0] # grouping by the first feature
# Create a GroupKFold object
gkf = GroupKFold(n_splits=5)
# Iterate through the splits and fit a model
for train_index, test_index in gkf.split(X, y, groups):
    X_train, X_test = X[train_index], X[test_index]
    y_train, y_test = y[train_index], y[test_index]
    model = LinearRegression(), y_train)
    score = model.score(X_test, y_test)