Primary competition visual

Africa Biomass Challenge

Helping Côte d'Ivoire
$10 000 USD
Completed (almost 3 years ago)
Earth Observation
Prediction
1223 joined
276 active
Starti
Jan 27, 23
Closei
May 21, 23
Reveali
May 21, 23
User avatar
GideonG
Zindi Ambassador to Nigeria
NotFittedError: This LinearRegression instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
Notebooks · 5 Apr 2023, 09:21 · 1
Please help me check the 4th to the last cell in the starter notebook, where # predict on giz test data. It's showing the above error so I couldn't even run the baseline model let alone submitting. What Can I do please?

pred_giz = pipe.predict(s2_images)

Discussion 1 answer
User avatar
Jaw22
Zindi africa

You receive this error because you need to call 'fit' with appropriate arguments before using this estimator" occurs when you are trying to use a LinearRegression model in Python without first fitting it to your data.

Hence, to resolve this error, you need to call the fit method on your LinearRegression instance with appropriate arguments before you can use it to make predictions. look at the following example for hints on how to resolve this:

==============================================================

from sklearn.linear_model import LinearRegression

# Create a LinearRegression instance

lr = LinearRegression()

# Fit the model to your training data

X_train = ...

y_train = ...

lr.fit(X_train, y_train) #This is the line of code that is missing in your algorithm dovetail it to your solution.

# Now you can use the model to make predictions on new data

X_test = ...

y_pred = lr.predict(X_test)

========================================================

I hope it make sense.

5 Apr 2023, 10:52
Upvotes 1