You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My ML model is predicting the same output for different inputs can someone help me?
Here is the code
# Import necessary librariesimportpandasaspdfromsklearn.model_selectionimporttrain_test_splitfromsklearn.ensembleimportRandomForestRegressorfromsklearn.metricsimportmean_squared_error, mean_absolute_error, r2_score# Step 1: Load the datasetdata=pd.read_excel('C:\\Users\\hp\\Desktop\\SugarcaneDataset.xlsx') # Adjust the file path as needed# Step 2: Split the dataset into features (X) and target variable (y)X=data.drop(columns=['Brix']) # Featuresy=data['Brix'] # Target variable# Step 3: Split the dataset into training and testing setsX_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.2, random_state=42)
# Step 4: Initialize and train the Random Forest Regression modelrf_regressor=RandomForestRegressor(n_estimators=100, random_state=42) # Adjust hyperparameters as neededrf_regressor.fit(X_train, y_train)
# Step 5: Make predictions on the testing sety_pred=rf_regressor.predict(X_test)
# Step 6: Evaluate the model's performancemse=mean_squared_error(y_test, y_pred)
mae=mean_absolute_error(y_test, y_pred)
r2=r2_score(y_test, y_pred)
print("Mean Squared Error:", mse)
print("Mean Absolute Error:", mae)
print("R-squared:", r2)
Step 7: Optionally, deploy the model and document the process
Now when i want to get predicted value of diff samples it gives me the same for both even these both are different:
1)
Your model might be overfitting the training data, capturing noise rather than underlying patterns. This can lead to poor generalization to new data. You could try to; Check for multicollinearity among features, normalizing your features if they are on different scales or even Experiment with different machine learning algorithms.
This repo is for reporting the bugs for the Keras framework only.
From your code, it does not look like you're using Keras.
For support related questions you can post in Stack Overflow community.
My ML model is predicting the same output for different inputs can someone help me?
Here is the code
Step 7: Optionally, deploy the model and document the process
Now when i want to get predicted value of diff samples it gives me the same for both even these both are different:
1)
Why this is happening?
The text was updated successfully, but these errors were encountered: