rohitinu6 / Stock-Price-Prediction

This project focuses on predicting the stock prices of "The State Bank Of India" using machine learning Regression algorithms.
28 stars 48 forks source link

Simple ensemble method using random forest and AdaBoost #106

Open SaurabhIndi opened 2 days ago

SaurabhIndi commented 2 days ago

Is this a unique feature?

Is your feature request related to a problem/unavailable functionality? Please describe.

This code demonstrates a simple ensemble method using random forest and AdaBoost. It combines the predictions of these two models by taking their average. You can experiment with different ensemble techniques like stacking or voting, and adjust the hyperparameters of the individual models to find the best combination for your specific problem.

Proposed Solution

Ensemble Methods: Consider combining multiple models (e.g., random forest, AdaBoost) to potentially improve performance and reduce overfitting.

Screenshots

No response

Do you want to work on this issue?

Yes

If "yes" to above, please explain how you would technically implement this (issue will not be assigned if this is skipped)

from sklearn.ensemble import RandomForestRegressor, AdaBoostRegressor from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error

Assuming you have your features (X) and target variable (y)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

Create individual models

rf_model = RandomForestRegressor(n_estimators=100, random_state=42) adaboost_model = AdaBoostRegressor(n_estimators=100, random_state=42)

Train the models

rf_model.fit(X_train, y_train) adaboost_model.fit(X_train, y_train)

Make predictions

rf_predictions = rf_model.predict(X_test) adaboost_predictions = adaboost_model.predict(X_test)

Combine predictions (simple averaging)

ensemble_predictions = (rf_predictions + adaboost_predictions) / 2

Evaluate the ensemble model

ensemble_mse = mean_squared_error(y_test, ensemble_predictions) print("Ensemble MSE:", ensemble_mse)

github-actions[bot] commented 2 days ago

Ensure the issue is not similar or previously being worked on.Thanks for your time

ModZ777 commented 1 day ago

I'd like to work on this project. please assign it to me