def plot_predictions(X, y, model, scale=False, test_size=0.2, plot_type=0, xvalues=None, xlabel='Index', title='Actual vs Predicted values', figsize=(6, 6)):
    "\n    Plot the predictions made by the given model on the given dataset, versus its actual values.\n\n    The dataset is split into training-test sets: the former is used to train the `model`, on the latter the predictions are\n    made.\n\n    Parameters\n    ----------\n    X: np.array\n        Two-dimensional np.array, containing the explanatory features of the dataset.\n    y: np.array\n        Mono dimensional np.array, containing the response feature of the dataset.\n    model: sklearn.base.BaseEstimator\n        Model used to make the predictions.\n    scale: bool\n        Indicates whether to scale or not the features in `X`.\n        (The scaling is performed using the sklearn MinMaxScaler).\n    test_size: float\n        Decimal number between 0 and 1, which indicates the proportion of the test set.\n    plot_type: int\n        Indicates the type of the plot.\n            - 0 -> In the same plot two different curves are drawn: the first has on the x axis `xvalues` and on the y axis\n                   the actual values (i.e. `y`); the second has on the x axis `xvalues` and on the y axis the computed\n                   predicted values.\n            - 1 -> On the x axis the actual values are put, on the y axis the predicted ones.\n    xvalues: list (in general, iterable)\n        Values that have to be put in the x axis of the plot.\n        (It's used only if `plot_type` is 0).\n    xlabel: str\n        Label of the x axis of the plot.\n        (It's used only if `plot_type` is 0).\n    title: str\n        Title of the plot.\n    figsize: tuple\n        Two dimensions of the plot.\n\n    Returns\n    ----------\n    matplotlib.axes.Axes\n        The matplotlib Axes where the plot has been made.\n\n    Notes\n    ----------\n    The splitting of the datasets into the training-test sets is simply made by dividing the dataset into two contiguous\n    sequences.\n    I.e. it is the same technique used usually when the dataset is a time series dataset. (This is done in order to simplify\n    the visualization).\n    For this reason, typically this function is applied on time series datasets.\n    "
    train_len = int((X.shape[0] * (1 - test_size)))
    X_train_80 = X[:train_len]
    y_train_80 = y[:train_len]
    X_test = X[train_len:]
    y_test = y[train_len:]
    if scale:
        scaler = MinMaxScaler()
        scaler.fit(X_train_80)
        X_train_80 = scaler.transform(X_train_80)
        X_test = scaler.transform(X_test)
    model.fit(X_train_80, y_train_80)
    predictions = model.predict(X_test)
    (fig, ax) = plt.subplots(figsize=figsize)
    if (plot_type == 0):
        if (xvalues is None):
            xvalues = range(len(X))
        ax.plot(xvalues, y, 'o:', label='actual values')
        ax.plot(xvalues[train_len:], predictions, 'o:', label='predicted values')
        ax.legend()
    elif (plot_type == 1):
        ax.plot(y[train_len:], predictions, 'o')
        ax.plot([0, 1], [0, 1], 'r-', transform=ax.transAxes)
        xlabel = 'Actual values'
        ax.set_ylabel('Predicted values')
    ax.set_xlabel(xlabel)
    ax.set_title(title)
    ax.grid()
    return ax
Plot the predictions made by the given model on the given dataset, versus its actual values.

The dataset is split into training-test sets: the former is used to train the `model`, on the latter the predictions are
made.

Parameters
----------
X: np.array
    Two-dimensional np.array, containing the explanatory features of the dataset.
y: np.array
    Mono dimensional np.array, containing the response feature of the dataset.
model: sklearn.base.BaseEstimator
    Model used to make the predictions.
scale: bool
    Indicates whether to scale or not the features in `X`.
    (The scaling is performed using the sklearn MinMaxScaler).
test_size: float
    Decimal number between 0 and 1, which indicates the proportion of the test set.
plot_type: int
    Indicates the type of the plot.
        - 0 -> In the same plot two different curves are drawn: the first has on the x axis `xvalues` and on the y axis
               the actual values (i.e. `y`); the second has on the x axis `xvalues` and on the y axis the computed
               predicted values.
        - 1 -> On the x axis the actual values are put, on the y axis the predicted ones.
xvalues: list (in general, iterable)
    Values that have to be put in the x axis of the plot.
    (It's used only if `plot_type` is 0).
xlabel: str
    Label of the x axis of the plot.
    (It's used only if `plot_type` is 0).
title: str
    Title of the plot.
figsize: tuple
    Two dimensions of the plot.

Returns
----------
matplotlib.axes.Axes
    The matplotlib Axes where the plot has been made.

Notes
----------
The splitting of the datasets into the training-test sets is simply made by dividing the dataset into two contiguous
sequences.
I.e. it is the same technique used usually when the dataset is a time series dataset. (This is done in order to simplify
the visualization).
For this reason, typically this function is applied on time series datasets.
def plot_predictions(X, y, model, scale=False, test_size=0.2, plot_type=0, xvalues=None, xlabel='Index', title='Actual vs Predicted values', figsize=(6, 6)):
    "\n    Plot the predictions made by the given model on the given dataset, versus its actual values.\n\n    The dataset is split into training-test sets: the former is used to train the `model`, on the latter the predictions are\n    made.\n\n    Parameters\n    ----------\n    X: np.array\n        Two-dimensional np.array, containing the explanatory features of the dataset.\n    y: np.array\n        Mono dimensional np.array, containing the response feature of the dataset.\n    model: sklearn.base.BaseEstimator\n        Model used to make the predictions.\n    scale: bool\n        Indicates whether to scale or not the features in `X`.\n        (The scaling is performed using the sklearn MinMaxScaler).\n    test_size: float\n        Decimal number between 0 and 1, which indicates the proportion of the test set.\n    plot_type: int\n        Indicates the type of the plot.\n            - 0 -> In the same plot two different curves are drawn: the first has on the x axis `xvalues` and on the y axis\n                   the actual values (i.e. `y`); the second has on the x axis `xvalues` and on the y axis the computed\n                   predicted values.\n            - 1 -> On the x axis the actual values are put, on the y axis the predicted ones.\n    xvalues: list (in general, iterable)\n        Values that have to be put in the x axis of the plot.\n        (It's used only if `plot_type` is 0).\n    xlabel: str\n        Label of the x axis of the plot.\n        (It's used only if `plot_type` is 0).\n    title: str\n        Title of the plot.\n    figsize: tuple\n        Two dimensions of the plot.\n\n    Returns\n    ----------\n    matplotlib.axes.Axes\n        The matplotlib Axes where the plot has been made.\n\n    Notes\n    ----------\n    The splitting of the datasets into the training-test sets is simply made by dividing the dataset into two contiguous\n    sequences.\n    I.e. it is the same technique used usually when the dataset is a time series dataset. (This is done in order to simplify\n    the visualization).\n    For this reason, typically this function is applied on time series datasets.\n    "
    train_len = int((X.shape[0] * (1 - test_size)))
    X_train_80 = X[:train_len]
    y_train_80 = y[:train_len]
    X_test = X[train_len:]
    y_test = y[train_len:]
    if scale:
        scaler = MinMaxScaler()
        scaler.fit(X_train_80)
        X_train_80 = scaler.transform(X_train_80)
        X_test = scaler.transform(X_test)
    model.fit(X_train_80, y_train_80)
    predictions = model.predict(X_test)
    (fig, ax) = plt.subplots(figsize=figsize)
    if (plot_type == 0):
        if (xvalues is None):
            xvalues = range(len(X))
        ax.plot(xvalues, y, 'o:', label='actual values')
        ax.plot(xvalues[train_len:], predictions, 'o:', label='predicted values')
        ax.legend()
    elif (plot_type == 1):
        ax.plot(y[train_len:], predictions, 'o')
        ax.plot([0, 1], [0, 1], 'r-', transform=ax.transAxes)
        xlabel = 'Actual values'
        ax.set_ylabel('Predicted values')
    ax.set_xlabel(xlabel)
    ax.set_title(title)
    ax.grid()
    return ax