lab_4: code review

This commit is contained in:
parent d7f693945d
commit f5d149a2d7

View File

@ -166,7 +166,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Конвертация данных:"
"### Предобработка данных:"
]
},
{
@ -1130,7 +1130,7 @@
},
{
"cell_type": "code",
"execution_count": 323,
"execution_count": null,
"metadata": {},
"outputs": [
{
@ -1177,10 +1177,10 @@
"\n",
"\n",
"# Оценка качества различных моделей на основе метрик\n",
"def evaluate_models(models, \n",
" pipeline_end, \n",
" X_train, y_train, \n",
" X_test, y_test) -> dict[str, dict[str, Any]]:\n",
"def evaluate_models(models: dict[str, Any], \n",
" pipeline_end: Pipeline, \n",
" X_train: DataFrame, y_train, \n",
" X_test: DataFrame, y_test) -> dict[str, dict[str, Any]]:\n",
" results: dict[str, dict[str, Any]] = {}\n",
" \n",
" for model_name, model in models.items():\n",
@ -1298,7 +1298,7 @@
},
{
"cell_type": "code",
"execution_count": 325,
"execution_count": null,
"metadata": {},
"outputs": [
{
@ -1368,6 +1368,7 @@
"# Меняем знак, так как берем отрицательное значение MSE\n",
"new_best_mse = -new_grid_search.best_score_\n",
"\n",
"\n",
"# Обучение модели с лучшими параметрами для новых значений\n",
"model_best = RandomForestRegressor(**new_best_params)\n",
"model_best.fit(X_train_processing_result, y_train)\n",
@ -1379,6 +1380,7 @@
"mse = metrics.mean_squared_error(y_test, y_pred)\n",
"rmse = np.sqrt(mse)\n",
"\n",
"\n",
"# Вывод результатов\n",
"print(\"Старые параметры:\", old_best_params)\n",
"print(\"Лучший результат (MSE) на старых параметрах:\", old_best_mse)\n",