Precision-Recall Curve quick method:

    Parameters
    ----------
    model : the Scikit-Learn estimator
        A classification model to score the precision-recall curve on.

    X : ndarray or DataFrame of shape n x m
        A feature array of n instances with m features the model is trained on.
        This array will be split into train and test splits if X_test is not specified.

    y : ndarray or Series of length n
        An array or series of target or class values. This vector will be split
        into train and test splits if y_test is not specified.

    X_test : ndarray or DataFrame of shape n x m
        An optional feature array of n instances with m features that the model
        is tested on if specified, using X as the training data. Otherwise
        X will be split into train and test splits.

    y_test : ndarray or Series of length n
        An array or series of target or class values that serve as actual labels for
        X_test. If not specified, y will be split into test and train along with X.

    ax : matplotlib Axes, default: None
        The axes to plot the figure on. If None is passed in the current axes
        will be used (or generated if required).

    train_size : float or int, default=0.8
        If float, should be between 0.0 and 1.0 and represent the proportion
        of the dataset to include in the train split. If int, represents the
        absolute number of train samples. Used if X_test and y_test not specified.

    random_state : int, RandomState, or None, optional
        If int, random_state is the seed used by the random number generator;
        If RandomState instance, random_state is the random number generator;
        If None, the random number generator is the RandomState instance used
        by np.random.

    shuffle : bool, default=True
        Whether or not to shuffle the data before splitting.

    classes : list
        A list of class names for the legend. If classes is None and a y value
        is passed to fit then the classes are selected from the target vector.
        Note that the curves must be computed based on what is in the target
        vector passed to the ``score()`` method. Class names are used for
        labeling only and must be in the correct order to prevent confusion.

    fill_area : bool, default=True
        Fill the area under the curve (or curves) with the curve color.

    ap_score : bool, default=True
        Annotate the graph with the average precision score, a summary of the
        plot that is computed as the weighted mean of precisions at each
        threshold, with the increase in recall from the previous threshold used
        as the weight.

    micro : bool, default=True
        If multi-class classification, draw the precision-recall curve for the
        micro-average of all classes. In the multi-class case, either micro or
        per-class must be set to True. Ignored in the binary case.

    iso_f1_curves : bool, default=False
        Draw ISO F1-Curves on the plot to show how close the precision-recall
        curves are to different F1 scores.

    per_class : bool, default=False
        If multi-class classification, draw the precision-recall curve for
        each class using a OneVsRestClassifier to compute the recall on a
        per-class basis. In the multi-class case, either micro or per-class
        must be set to True. Ignored in the binary case.

    fill_opacity : float, default=0.2
        Specify the alpha or opacity of the fill area (0 being transparent,
        and 1.0 being completly opaque).

    line_opacity : float, default=0.8
        Specify the alpha or opacity of the lines (0 being transparent, and
        1.0 being completly opaque).

    kwargs : dict
        Keyword arguments passed to the visualization base class.

    Returns
    -------
    viz : PrecisionRecallCurve
        Returns the visualizer that generates the curve visualization.

    Notes
    -----
    Data is split using ``sklearn.model_selection.train_test_split`` before
    computing the Precision-Recall curve. Splitting options such as train_size,
    random_state, and shuffle are specified. Note that splits are not stratified,
    if required, it is recommended to use the base class.

def precision_recall_curve(model, X, y, X_test=None, y_test=None, ax=None, train_size=0.8,
                           random_state=None, shuffle=True, **kwargs):
    """Precision-Recall Curve quick method:

    Parameters
    ----------
    model : the Scikit-Learn estimator
        A classification model to score the precision-recall curve on.

    X : ndarray or DataFrame of shape n x m
        A feature array of n instances with m features the model is trained on.
        This array will be split into train and test splits if X_test is not specified.

    y : ndarray or Series of length n
        An array or series of target or class values. This vector will be split
        into train and test splits if y_test is not specified.

    X_test : ndarray or DataFrame of shape n x m
        An optional feature array of n instances with m features that the model
        is tested on if specified, using X as the training data. Otherwise
        X will be split into train and test splits.

    y_test : ndarray or Series of length n
        An array or series of target or class values that serve as actual labels for
        X_test. If not specified, y will be split into test and train along with X.

    ax : matplotlib Axes, default: None
        The axes to plot the figure on. If None is passed in the current axes
        will be used (or generated if required).

    train_size : float or int, default=0.8
        If float, should be between 0.0 and 1.0 and represent the proportion
        of the dataset to include in the train split. If int, represents the
        absolute number of train samples. Used if X_test and y_test not specified.

    random_state : int, RandomState, or None, optional
        If int, random_state is the seed used by the random number generator;
        If RandomState instance, random_state is the random number generator;
        If None, the random number generator is the RandomState instance used
        by np.random.

    shuffle : bool, default=True
        Whether or not to shuffle the data before splitting.

    classes : list
        A list of class names for the legend. If classes is None and a y value
        is passed to fit then the classes are selected from the target vector.
        Note that the curves must be computed based on what is in the target
        vector passed to the ``score()`` method. Class names are used for
        labeling only and must be in the correct order to prevent confusion.

    fill_area : bool, default=True
        Fill the area under the curve (or curves) with the curve color.

    ap_score : bool, default=True
        Annotate the graph with the average precision score, a summary of the
        plot that is computed as the weighted mean of precisions at each
        threshold, with the increase in recall from the previous threshold used
        as the weight.

    micro : bool, default=True
        If multi-class classification, draw the precision-recall curve for the
        micro-average of all classes. In the multi-class case, either micro or
        per-class must be set to True. Ignored in the binary case.

    iso_f1_curves : bool, default=False
        Draw ISO F1-Curves on the plot to show how close the precision-recall
        curves are to different F1 scores.

    per_class : bool, default=False
        If multi-class classification, draw the precision-recall curve for
        each class using a OneVsRestClassifier to compute the recall on a
        per-class basis. In the multi-class case, either micro or per-class
        must be set to True. Ignored in the binary case.

    fill_opacity : float, default=0.2
        Specify the alpha or opacity of the fill area (0 being transparent,
        and 1.0 being completly opaque).

    line_opacity : float, default=0.8
        Specify the alpha or opacity of the lines (0 being transparent, and
        1.0 being completly opaque).

    kwargs : dict
        Keyword arguments passed to the visualization base class.

    Returns
    -------
    viz : PrecisionRecallCurve
        Returns the visualizer that generates the curve visualization.

    Notes
    -----
    Data is split using ``sklearn.model_selection.train_test_split`` before
    computing the Precision-Recall curve. Splitting options such as train_size,
    random_state, and shuffle are specified. Note that splits are not stratified,
    if required, it is recommended to use the base class.
    """




    if (X_test is None) and (y_test is None):
        # Create train and test splits to validate the model
        X_train, X_test, y_train, y_test = tts(
            X, y, train_size=train_size, random_state=random_state, shuffle=shuffle
        )
    elif any([((X_test is not None) and (y_test is None)),((X_test is None) and (y_test is not None))]):
        # exception handling in case of missing X_test or y_test
        raise YellowbrickValueError("both X_test and y_test are required if one is specified")
        
    else:
        X_train,y_train=X,y

    # Instantiate the visualizer
    viz = PRCurve(model, ax=ax, **kwargs)
    
    # Fit and transform the visualizer
    viz.fit(X_train, y_train)
    viz.score(X_test, y_test)
    viz.finalize()

    # Return the visualizer
    return viz