internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: sktime/sktime

Issue:
[ENH] Allow YfromX to handle missing data
**Is your feature request related to a problem? Please describe.**
YfromX should be able to handle missing data as long as the estimator passed to it is able to. We can change the tag to read the missing data capability of the estimator. 


Discussion:

Resolving patch:
diff --git a/sktime/forecasting/compose/_reduce.py b/sktime/forecasting/compose/_reduce.py
--- a/sktime/forecasting/compose/_reduce.py
+++ b/sktime/forecasting/compose/_reduce.py
@@ -2446,6 +2446,7 @@ class YfromX(BaseForecaster, _ReducerMixin):
     _tags = {
         "requires-fh-in-fit": False,  # is the forecasting horizon required in fit?
         "ignores-exogeneous-X": False,
+        "handles-missing-data": True,
         "X_inner_mtype": ["pd.DataFrame", "pd-multiindex", "pd_multiindex_hier"],
         "y_inner_mtype": ["pd.DataFrame", "pd-multiindex", "pd_multiindex_hier"],
     }


Test patch:
Repository: sktime/sktime

Issue:
[BUG] `NaiveForecaster` has `ignores-exogeneous-X` tag value as `False`
**To Reproduce**
<!--
Add a Minimal, Complete, and Verifiable example (for more details, see e.g. https://stackoverflow.com/help/mcve

If the code is too long, feel free to put it in a public gist and link it in the issue: https://gist.github.com
-->

```pycon
>>> from sktime.forecasting.naive import NaiveForecaster
>>> NaiveForecaster().get_tag("ignores-exogeneous-X")
False
```

**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->
The value is expected to be `True`, as exogenous features are not supposed to be used for "naive" forecasting.


Discussion:
ah, you are right - I concur. Should be an easy fix, are you going to PR?

Resolving patch:
diff --git a/sktime/forecasting/naive.py b/sktime/forecasting/naive.py
--- a/sktime/forecasting/naive.py
+++ b/sktime/forecasting/naive.py
@@ -111,6 +111,7 @@ class NaiveForecaster(_BaseWindowForecaster):
         "y_inner_mtype": "pd.Series",
         "requires-fh-in-fit": False,
         "handles-missing-data": True,
+        "ignores-exogeneous-X": True,
         "scitype:y": "univariate",
         "capability:pred_var": True,
         "capability:pred_int": True,


Test patch:
Repository: sktime/sktime

Issue:
[BUG] ColumnSelect missing tag`"skip-inverse-transform"`
**Describe the bug**
<!--
A clear and concise description of what the bug is.
-->
The ColumnSelect is missing the tag  `"skip-inverse-transform"`. Thus, a TransformedTargetForecaster subsetting the `y` input will fail when calling predict.

**To Reproduce**
<!--
Add a Minimal, Complete, and Verifiable example (for more details, see e.g. https://stackoverflow.com/help/mcve

If the code is too long, feel free to put it in a public gist and link it in the issue: https://gist.github.com
-->



```python
from sktime.forecasting.naive import NaiveForecaster
from sktime.transformations.series.subset import ColumnSelect
from sktime.datasets import load_longley
y = load_longley()[1][["GNP", "UNEMP"]]
fc = ColumnSelect(["GNP"]) * NaiveForecaster()
fc.fit(y)
fc.predict(fh=[1])
```

**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->
I would expect that the forecast is performed only on the selected time series without raising an error.

**Additional context**
<!--
Add any other context about the problem here.
-->
This would be fixed by just adding the tag `skip-inverse-transform` to ColumnSelect.



Discussion:
Ah, that's an oversight.

Although, why would you chain a `ColumnSelect` in a `TransformedTargetForecaster`, would that not result in a forecast of less variables than the original data?

Either way, I suppose it's not an unreasonable use case. Let's add the tag and the failing example as a one-off test?

Resolving patch:
diff --git a/sktime/transformations/series/subset.py b/sktime/transformations/series/subset.py
--- a/sktime/transformations/series/subset.py
+++ b/sktime/transformations/series/subset.py
@@ -160,6 +160,7 @@ class ColumnSelect(BaseTransformer):
         "fit_is_empty": True,
         "univariate-only": False,
         "capability:inverse_transform": False,
+        "skip-inverse-transform": True,
     }
 
     def __init__(self, columns=None, integer_treatment="col", index_treatment="remove"):


Test patch:
diff --git a/sktime/transformations/series/tests/test_subset.py b/sktime/transformations/series/tests/test_subset.py
--- a/sktime/transformations/series/tests/test_subset.py
+++ b/sktime/transformations/series/tests/test_subset.py
@@ -7,6 +7,7 @@
 import pytest
 
 from sktime.datasets import load_airline, load_longley
+from sktime.forecasting.naive import NaiveForecaster
 from sktime.transformations.series.subset import ColumnSelect, IndexSubset
 
 
@@ -49,3 +50,10 @@ def test_columnselect_int():
     X_subset = transformer.fit_transform(X=X)
 
     assert X_subset.columns.equals(X.columns[[0, 2, 4]])
+
+
+def test_columnselect_as_first_step_in_transformedtargetforecaster():
+    y = load_longley()[1][["GNP", "UNEMP"]]
+    fc = ColumnSelect(["GNP"]) * NaiveForecaster()
+    fc.fit(y)
+    fc.predict(fh=[1])
Repository: sktime/sktime

Issue:
[DOC] `STLForecaster` docs not rendered correctly.
#### Describe the issue linked to the documentation
The documentation doesn't appear to have rendered correctly here: https://www.sktime.org/en/v0.15.1/api_reference/auto_generated/sktime.forecasting.trend.STLForecaster.html

<img width="710" alt="image" src="https://user-images.githubusercontent.com/30973056/214697850-8557fbfc-b58c-4d63-8414-cf8286469eb4.png">




Discussion:
Hey! I wanna fix this! @KishManani  , please tell me what do you want to see fixed? ( I am new, I don't have eyes for it yet :)
Thanks, @blazingbhavneek!

I think:
* the content in the grey boxes should simply continue the previous line instead of being in grey boxes.
* the list points 1., 2., 3. should render aligned

Resolving patch:
diff --git a/sktime/forecasting/trend.py b/sktime/forecasting/trend.py
--- a/sktime/forecasting/trend.py
+++ b/sktime/forecasting/trend.py
@@ -309,22 +309,24 @@ class STLForecaster(BaseForecaster):
 
     The STLForecaster applies the following algorithm, also see [1]_.
 
-    in `fit`:
-    1. use `statsmodels` `STL` [2]_ to decompose the given series `y` into
-        the three components: `trend`, `season` and `residuals`.
-    2. fit clones of `forecaster_trend` to `trend`, `forecaster_seasonal` to `season`,
-        and `forecaster_resid` to `residuals`, using `y`, `X`, `fh` from `fit`.
-        The forecasters are fitted as clones, stored in the attributes
-        `forecaster_trend_`, `forecaster_seasonal_`, `forecaster_resid_`.
+    In `fit`:
+
+    1. Use `statsmodels` `STL` [2]_ to decompose the given series `y` into
+       the three components: `trend`, `season` and `residuals`.
+    2. Fit clones of `forecaster_trend` to `trend`, `forecaster_seasonal` to `season`,
+       and `forecaster_resid` to `residuals`, using `y`, `X`, `fh` from `fit`.
+       The forecasters are fitted as clones, stored in the attributes
+       `forecaster_trend_`, `forecaster_seasonal_`, `forecaster_resid_`.
 
     In `predict`, forecasts as follows:
-    1. obtain forecasts `y_pred_trend` from `forecaster_trend_`,
-        `y_pred_seasonal` from `forecaster_seasonal_`, and
-        `y_pred_residual` from `forecaster_resid_`, using `X`, `fh`, from `predict`.
-    2. recompose `y_pred` as `y_pred = y_pred_trend + y_pred_seasonal + y_pred_residual`
-    3. return `y_pred`
 
-    `update` refits entirely, i.e., behaves as `fit` on all data seen so far.
+    1. Obtain forecasts `y_pred_trend` from `forecaster_trend_`,
+       `y_pred_seasonal` from `forecaster_seasonal_`, and
+       `y_pred_residual` from `forecaster_resid_`, using `X`, `fh`, from `predict`.
+    2. Recompose `y_pred` as `y_pred = y_pred_trend + y_pred_seasonal + y_pred_residual`
+    3. Return `y_pred`
+
+        `update` refits entirely, i.e., behaves as `fit` on all data seen so far.
 
     Parameters
     ----------


Test patch:
Repository: sktime/sktime

Issue:
[BUG] BaseRegressor should allow one-column `pd.DataFrame` as `y`
**Describe the bug**
<!--
A clear and concise description of what the bug is.
-->
The BaseRegressor's fit method performs the type coercion only for X and not for y. Thus calling a Regressor with a one-dimensional data frame as y fails.



**To Reproduce**
<!--
Add a Minimal, Complete, and Verifiable example (for more details, see e.g. https://stackoverflow.com/help/mcve

If the code is too long, feel free to put it in a public gist and link it in the issue: https://gist.github.com
-->

```python
from sktime.regression.distance_based import KNeighborsTimeSeriesRegressor
import numpy as np

knn = KNeighborsTimeSeriesRegressor()

# The following statement works
knn.fit(pd.DataFrame(np.random.normal(0, 1, (100, 5)), index=pd.MultiIndex.from_product([range(50), range(2)])),
        pd.Series(np.random.normal(0, 1, 50))
        )

# The following statement fails  
knn.fit(pd.DataFrame(np.random.normal(0, 1, (100, 5)), index=pd.MultiIndex.from_product([range(50), range(2)])),
        pd.DataFrame(np.random.normal(0, 1, 50))
        )
```

**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->
Both statements should work and the one-dimensional y is converted to a series internally.



Discussion:
Hm, it's maybe less a bug than a missing feature - the feature being "regressors (and classifiers?) should accept one-column `pd.DataFrame` as a valid `y`".

Also, based on our recent discussion, we should possibly also admit multivariate `y`, and broadcast in the base case? (one regressor/classifier per column)

Resolving patch:
diff --git a/sktime/regression/base.py b/sktime/regression/base.py
--- a/sktime/regression/base.py
+++ b/sktime/regression/base.py
@@ -429,9 +429,12 @@ def _check_regressor_input(
     # Check y if passed
     if y is not None:
         # Check y valid input
-        if not isinstance(y, (pd.Series, np.ndarray)):
+        if not isinstance(y, (pd.Series, np.ndarray)) and not (
+            isinstance(y, pd.DataFrame) and y.shape[1] == 1
+        ):
             raise ValueError(
-                f"y must be a np.array or a pd.Series, but found type: {type(y)}"
+                f"y must be a np.array, pd.Series or a 1-D pd.DataFrame,"
+                f"but found type: {type(y)}"
             )
         # Check matching number of labels
         n_labels = y.shape[0]


Test patch:
Repository: sktime/sktime

Issue:
[BUG] Bug in the imputer class. Fit and transform ignore the parameter for y 
The `fit` and `transform` functions of the `Imputer` class in sktime ignore the input parameter for `y`. Upon debugging, it was found that `y` is always `None` and cannot be changed.

**To Reproduce**
```python
from sktime.datasets import load_airline
from sktime.transformations.series.impute import Imputer
model_reg = YfromX(lgb.LGBMRegressor())
model_reg.fit(x_train, y_train)
x_train = load_airline()
y_train = load_airline()
transformer = Imputer(method="forecaster", forecaster=model_reg)
transformer.fit(y_train, y=x_train)
y_train_imputed = transformer.transform(y_train, y=x_train)
```

**Expected behavior**
The `fit` and `transform` functions of the `Imputer` class should accept the input parameter for `y` and use it as exogenous regressors for the LGBMRegressor YfromX forecaster model. 

**Additional context**
I am using the editable development version of sktime, and the issue persists in this version.

```
System:
MacOS 12.5.1

Python dependencies:
pandas 12.1
numpy 1.25.2
lightgbm 4.0.0
sklearn 1.3.0

```

</details>

<!--
Please run the following code snippet and paste the output here:

from sktime import show_versions; show_versions()
(ImportError: cannot import name 'show_versions' from 'sktime' (unknown location))
-->

</details>

<!-- Thanks for contributing! -->



Discussion:

Resolving patch:
diff --git a/sktime/transformations/series/impute.py b/sktime/transformations/series/impute.py
--- a/sktime/transformations/series/impute.py
+++ b/sktime/transformations/series/impute.py
@@ -137,6 +137,9 @@ def __init__(
                 }
             )
 
+        if method in "forecaster":
+            self.set_tags(**{"y_inner_mtype": ["pd.DataFrame"]})
+
     def _fit(self, X, y=None):
         """Fit transformer to X and y.
 


Test patch:
diff --git a/sktime/transformations/series/tests/test_imputer.py b/sktime/transformations/series/tests/test_imputer.py
--- a/sktime/transformations/series/tests/test_imputer.py
+++ b/sktime/transformations/series/tests/test_imputer.py
@@ -54,3 +54,24 @@ def test_imputer(method, Z):
     t = Imputer(method=method, forecaster=forecaster, value=value)
     y_hat = t.fit_transform(Z)
     assert not y_hat.isnull().to_numpy().any()
+
+
+def test_imputer_forecaster_y():
+    """Test that forecaster imputer works with y.
+
+    Failure case in bug #5284.
+    """
+    from sklearn.linear_model import LinearRegression
+
+    from sktime.datasets import load_airline
+    from sktime.forecasting.compose import YfromX
+
+    X = load_airline()
+    y = load_airline()
+
+    model_reg = YfromX(LinearRegression())
+    model_reg.fit(X, y)
+    transformer = Imputer(method="forecaster", forecaster=model_reg)
+
+    transformer.fit(X=X, y=y)
+    transformer.transform(X=X, y=y)
Repository: sktime/sktime

Issue:
[DOC] `plot_series` docstring should document the `ax` argument and the figure that is plotted
The `plot_series` docstring does not but should document:

* the `ax` argument
* the figure that is plotted

A good example for this does not exist in `sktime` as far as I can find, but one can look at `plot_crossplot_std` in `skpro` for some inspiration (or docstring copy-paste).


Discussion:

Resolving patch:
diff --git a/sktime/utils/plotting.py b/sktime/utils/plotting.py
--- a/sktime/utils/plotting.py
+++ b/sktime/utils/plotting.py
@@ -30,6 +30,20 @@ def plot_series(
 ):
     """Plot one or more time series.
 
+    This function allows you to plot one or more
+    time series on a single figure via `series`.
+    Used for making comparisons between different series.
+
+    The resulting figure includes the time series data plotted on a graph with
+    x-axis as time by default and can be changed via `x_label` and
+    y-axis as value of time series can be renamed via `y_label` and
+    labels explaining the meaning of each series via `labels`,
+    markers for data points via `markers`.
+    You can also specify custom colors via `colors` for each series and
+    add a title to the figure via `title`.
+    If prediction intervals are available add them using `pred_interval`,
+    they can be overlaid on the plot to visualize uncertainty.
+
     Parameters
     ----------
     series : pd.Series or iterable of pd.Series
@@ -46,11 +60,18 @@ def plot_series(
     pred_interval: pd.DataFrame, default = None
         Output of `forecaster.predict_interval()`. Contains columns for lower
         and upper boundaries of confidence interval.
+    ax : matplotlib axes, optional
+        Axes to plot on, if None, a new figure is created and returned
 
     Returns
     -------
     fig : plt.Figure
+        It manages the final visual appearance and layout.
+        Create a new figure, or activate an existing figure.
     ax : plt.Axis
+        Axes containing the plot
+        If ax was None, a new figure is created and returned
+        If ax was not None, the same ax is returned with plot added
 
     Examples
     --------
@@ -58,6 +79,7 @@ def plot_series(
     >>> from sktime.datasets import load_airline
     >>> y = load_airline()
     >>> fig, ax = plot_series(y)  # doctest: +SKIP
+
     """
     _check_soft_dependencies("matplotlib", "seaborn")
     import matplotlib.pyplot as plt


Test patch:
Repository: sktime/sktime

Issue:
[BUG] MCDCNNClassifier.fit runs only 1 training epoch
Despite n_epochs being set to 200, only one training epoch will be executed here:

```python
from sktime.classification.deep_learning.mcdcnn import MCDCNNClassifier
from keras.losses import binary_crossentropy

model = MCDCNNClassifier(n_epochs=200, batch_size=64, loss=binary_crossentropy, random_state=42, metrics=['binary_accuracy'])
model.fit(x_train, y_train)
```

The problem is that model.n_epochs is not passed to self.model_.fit in MCDCNNClassifier._fit (mcdcnn.py):

```python
    def _fit(self, X, y):
        ...

        self.history = self.model_.fit(
            X,
            y_onehot,
            epochs=self.n_epochs, **#<<<-----------------THIS LINS IS MISSING #**
            batch_size=self.batch_size,
            verbose=self.verbose,
            callbacks=self.callbacks_,
        )

        return self
```


Discussion:
Thanks for the report!

The fix seem simple, and you've identified the problem - so, would appreciate a fix PR!
@fkiraly ,
I've submitted the pull request
@pseudomo, I think you never made a PR to sktime proper, but only to your personal fork?

Could you kindly make a PR to sktime?

Resolving patch:
diff --git a/sktime/classification/deep_learning/mcdcnn.py b/sktime/classification/deep_learning/mcdcnn.py
--- a/sktime/classification/deep_learning/mcdcnn.py
+++ b/sktime/classification/deep_learning/mcdcnn.py
@@ -215,6 +215,7 @@ def _fit(self, X, y):
         self.history = self.model_.fit(
             X,
             y_onehot,
+            epochs=self.n_epochs,
             batch_size=self.batch_size,
             verbose=self.verbose,
             callbacks=self.callbacks_,


Test patch:
Repository: sktime/sktime

Issue:
[BUG] `plot_windows` is creating two figures
**Describe the bug**
The method `plot_windows` is generating two plots. One empty and one with the splits

**To Reproduce**
See also https://github.com/sktime/sktime-tutorial-pydata-global-2023/blob/main/notebooks/02_forecasting.ipynb

```python
from sktime.split import ExpandingWindowSplitter
from sktime.utils import plot_windows
import numpy as np
import pandas as pd
y = pd.DataFrame(np.linspace(1,10, 100))
cv = ExpandingWindowSplitter(fh=range(1, 6 + 1), initial_window=12, step_length=1)
_ = plot_windows(cv, y)
```

**Expected behavior**
Only one plot is created showing the windows

**Additional context**

The problem is that in line 452 and 466 a new figure is created. Probably, the lines from 466 should be moved to the line 452. 




Discussion:

Resolving patch:
diff --git a/sktime/utils/plotting.py b/sktime/utils/plotting.py
--- a/sktime/utils/plotting.py
+++ b/sktime/utils/plotting.py
@@ -449,7 +449,7 @@ def plot_windows(cv, y, title="", ax=None):
 
     # create figure if no ax provided for plotting
     if _ax_kwarg_is_none:
-        fig, ax = plt.subplots(1, figsize=plt.figaspect(0.25))
+        fig, ax = plt.subplots(figsize=plt.figaspect(0.3))
 
     train_windows, test_windows = _get_windows(cv, y)
 
@@ -463,8 +463,6 @@ def get_y(length, split):
 
     train_color, test_color = sns.color_palette("colorblind")[:2]
 
-    fig, ax = plt.subplots(figsize=plt.figaspect(0.3))
-
     for i in range(n_splits):
         train = train_windows[i]
         test = test_windows[i]


Test patch:
Repository: sktime/sktime

Issue:
[DOC] Bullet point not rendered properly on feature_selection.py
#### Describe the issue linked to the documentation

<!--
Tell us about the confusion introduced in the documentation.
-->Under Time series transformations (https://www.sktime.net/en/latest/api_reference/transformations.html) in 
FeatureSelection , bullet point is not rendered properly for “feature-importances” under the  FeatureSelection class.

#### Suggest a potential alternative/fix

<!--
Tell us how we could improve the documentation in this regard.
-->



Discussion:

Resolving patch:
diff --git a/sktime/transformations/series/feature_selection.py b/sktime/transformations/series/feature_selection.py
--- a/sktime/transformations/series/feature_selection.py
+++ b/sktime/transformations/series/feature_selection.py
@@ -25,6 +25,7 @@ class FeatureSelection(BaseTransformer):
     ----------
     method : str, required
         The method of how to select the features. Implemented methods are:
+
         * "feature-importances": Use feature_importances_ of the regressor (meta-model)
           to select n_columns with highest importance values.
           Requires parameter n_columns.
@@ -32,6 +33,7 @@ class FeatureSelection(BaseTransformer):
         * "columns": Select features by given names.
         * "none": Remove all columns, transform returns None.
         * "all": Select all given features.
+
     regressor : sklearn-like regressor, optional, default=None.
         Used as meta-model for the method "feature-importances". The given
         regressor must have an attribute "feature_importances_". If None,


Test patch:
Repository: sktime/sktime

Issue:
[DOC] Document the `int_label` option in `BaseSeriesAnnotator`
#### Describe the issue linked to the documentation

<!--
Tell us about the confusion introduced in the documentation.
-->

The `BaseSeriesAnnotator` class has the attribute `labels` which, according to the documentation, can be either `indicator` or `score`. However, the `HMM` class which inherits from `BaseSeriesAnnotator` uses `int_label` for the `labels` attribute, this option is not documented in `BaseSeriesAnnotator`.

The label `int_label` means that for observations `obs = [10, 11, 8, -1. -4. -2]`, the annotator should produce an output like `y = [0, 0, 0, 1, 1, 1]`.

#### Suggest a potential alternative/fix

<!--
Tell us how we could improve the documentation in this regard.
-->

Add proprer documentation to the `BaseSeriesAnnotator` for the `int_label` option for the `labels` parameter.

#### Other comments

There are other algorithms in the annotations module which produce integer labels, such as `GreedyGaussianSegmentation` (GSS), which do not inherit from `BaseSeriesAnnotator`. Perhaps we can change `GreedyGaussianSegmentation` to inherit from `BaseSeriesAnnotator` and use the `int_label` option.



Discussion:

Resolving patch:
diff --git a/sktime/annotation/base/_base.py b/sktime/annotation/base/_base.py
--- a/sktime/annotation/base/_base.py
+++ b/sktime/annotation/base/_base.py
@@ -36,11 +36,13 @@ class BaseSeriesAnnotator(BaseEstimator):
         Annotation output format:
         * If "sparse", a sub-series of labels for only the outliers in X is returned,
         * If "dense", a series of labels for all values in X is returned.
-    labels : str {"indicator", "score"}, optional (default="indicator")
+    labels : str {"indicator", "score", "int_label"}, optional (default="indicator")
         Annotation output labels:
         * If "indicator", returned values are boolean, indicating whether a value is an
         outlier,
         * If "score", returned values are floats, giving the outlier score.
+        * If "int_label", returned values are integers indicating which segment the
+        value belongs to.
 
     Notes
     -----


Test patch:
Repository: sktime/sktime

Issue:
[MNT] Update dask requirement from `<2024.2.2` to `<2024.4.2`, add new required `dataframe` extra to `pyproject.toml`.
Fixes #6280 by updating `dask` to the newest version which fixes incompatibility with python 3.11.9


Discussion:
Turns out we had the same idea, see https://github.com/sktime/sktime/pull/6255

Your fix does not work because your syntax is not PEP 508 compliant, you need to add extras as a PEP 508 marker.

Since you had the idea first, I've changd this PR so it works and credit goes to you, and will close the modified dependabot one.

Resolving patch:
diff --git a/sktime/utils/mlflow_sktime.py b/sktime/utils/mlflow_sktime.py
--- a/sktime/utils/mlflow_sktime.py
+++ b/sktime/utils/mlflow_sktime.py
@@ -47,7 +47,6 @@
 import os
 
 import pandas as pd
-import yaml
 
 import sktime
 from sktime import utils
@@ -56,6 +55,7 @@
 from sktime.utils.validation._dependencies import _check_mlflow_dependencies
 
 if _check_mlflow_dependencies(severity="warning"):
+    import yaml
     from mlflow import pyfunc
 
 FLAVOR_NAME = "mlflow_sktime"


Test patch: