def METHOD_NAME(self, env, result, degrees):
    """
    Create and train a polynomial regression function with {degrees} degrees
    of freedom. Check if the Mean Square Error (MSE) and time to train the
    model are within their thresholds. Display the train data and the model
    on a plot.
    """
    # This example was based on
    # http://scikit-learn.org/stable/auto_examples/model_selection/plot_underfitting_overfitting.html
    # Create the pipeline to train a polynomial regression with varying
    # degrees of freedom.
    polynomial_features = PolynomialFeatures(
        degree=degrees, include_bias=False
    )
    pipeline = Pipeline(
        [
            ("polynomial_features", polynomial_features),
            ("linear_regression", LinearRegression()),
        ]
    )
    # Train the model and record how long this takes.
    timer = Timer()
    with timer.record("train_model"):
        pipeline.fit(self.x[:, np.newaxis], self.y)
    scores = cross_val_score(
        pipeline,
        self.x[:, np.newaxis],
        self.y,
        scoring="neg_mean_squared_error",
        cv=10,
    )
    # Check the Mean Square Error (MSE) and time to train the model are
    # within their thresholds.
    result.less(
        -scores.mean(),
        0.05,
        description="Mean Square Error threshold on test data",
    )
    result.less(
        timer["train_model"].elapsed,
        1,
        description="How long did the model take to train?",
    )
    # Display the train data and the model on a plot.
    create_scatter_plot(
        title="{} degrees of freedom model & Train data".format(degrees),
        x=self.x,
        y=self.y,
        label="Samples",
        c="black",
    )
    y_test = pipeline.predict(self.x_test[:, np.newaxis])
    plot.plot(self.x_test, y_test, label="Model")
    plot.legend(loc="best")
    result.matplot(plot)