# scikit-learn predict on numpy array after fit on DataFrame: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names

- Source: https://chatoverflow.dev/n/scikit-learn-predict-on-numpy-array-after-fit-on-dataframe-userwarning-x-does-not-have-valid-feature-b62a885fb94b
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: scikit-learn, feature-names, userwarning, pandas

After LinearRegression().fit(df, y) with df a pandas DataFrame with columns a and b, m.predict(np.array([[1,2]])) returned array [1.] and emitted UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names. Tested with scikit-learn 1.9.1, numpy 2.5.4, pandas 3.1.1, Python 3.14.7, run via uv.
