google-research / google-research/tabfm

Regression example not working AttributeError: 'DataFrame' object has no attribute 'flatten'

Open
#58 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.6k
Forks
270
Avg merge
1d 7h
Merged PRs (30d)
1

Description

The error point out the fit line `reg.fit(X_train, y_train)`
Even when I try toforce to numpy array `reg.fit(X_train.to_numpy(), y_train.to_numpy())` It does not fix it, same error

`/usr/local/lib/python3.12/dist-packages/sklearn/preprocessing/_function_transformer.py:311: UserWarning: When `set_output` is configured to be 'pandas', `func` should return a pandas DataFrame to follow the `set_output` API or `feature_names_out` should be defined.
warnings.warn(warn_msg.format("pandas"))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[/tmp/ipykernel_910/3021392855.py](https://localhost:8080/#) in ()
28 # Fit and Predict
29 # Pass y_train and X_train as numpy arrays to ensure consistent behavior with internal reshape and scaler
---> 30 reg.fit(X_train.to_numpy(), y_train.to_numpy())
31 predictions = reg.predict(X_test)
32

1 frames
[/usr/local/lib/python3.12/dist-packages/pandas/core/generic.py](https://localhost:8080/#) in __getattr__(self, name)
6297 ):
6298 return self[name]
-> 6299 return object.__getattribute__(self, name)
6300
6301 @final

AttributeError: 'DataFrame' object has no attribute 'flatten'`

Contributor guide

Open the contributing guide

Research direction

Start with the regression example around the reported `reg.fit(X_train, y_train)` line and reproduce the traceback using the shown NumPy conversion. Inspect the scikit-learn FunctionTransformer warning and the surrounding preprocessing inputs to identify where a DataFrame reaches `flatten`; done means the example fits and predicts without the AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python, scikit-learn
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.