Skip to content

Commit

Permalink
Ensemble method added with validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SaurabhIndi authored Oct 11, 2024
1 parent c5e8845 commit 333db66
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Stock_Price_Prediction(Updated).ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5220,7 +5220,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
"### Ensemble method using random forest and AdaBoost"
]
},
{
Expand Down Expand Up @@ -5255,6 +5255,42 @@
"ensemble_mse = mean_squared_error(y_test, ensemble_predictions)\n",
"print(\"Ensemble MSE:\", ensemble_mse)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Validation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import accuracy_score, mean_squared_error, mean_absolute_error\n",
"\n",
"# Assuming we have the true labels (y_test) and the ensemble predictions (ensemble_predictions)\n",
"\n",
"# Calculate accuracy\n",
"accuracy = accuracy_score(y_test, ensemble_predictions.round())\n",
"print(\"Accuracy:\", accuracy)\n",
"\n",
"# Calculate RMSE\n",
"rmse = mean_squared_error(y_test, ensemble_predictions, squared=False)\n",
"print(\"RMSE:\", rmse)\n",
"\n",
"# Calculate MAE\n",
"mae = mean_absolute_error(y_test, ensemble_predictions)\n",
"print(\"MAE:\", mae)\n",
"\n",
"# Other relevant metrics\n",
"# For example, if your target variable is categorical:\n",
"# precision = precision_score(y_test, ensemble_predictions.round())\n",
"# recall = recall_score(y_test, ensemble_predictions.round())\n",
"# f1_score = f1_score(y_test, ensemble_predictions.round())"
]
}
],
"metadata": {
Expand Down

0 comments on commit 333db66

Please sign in to comment.