From f5d149a2d727cfd1ce1e41885ef1e789825a6c30 Mon Sep 17 00:00:00 2001 From: Factorino73 Date: Sat, 16 Nov 2024 21:59:40 +0400 Subject: [PATCH] lab_4: code review --- lab_4/lab4.ipynb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lab_4/lab4.ipynb b/lab_4/lab4.ipynb index fd32985..e564bd3 100644 --- a/lab_4/lab4.ipynb +++ b/lab_4/lab4.ipynb @@ -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": [ { @@ -1344,7 +1344,7 @@ "\n", "# Результаты подбора для старых параметров\n", "old_best_params = old_grid_search.best_params_\n", - " # Меняем знак, так как берем отрицательное значение MSE\n", + "# Меняем знак, так как берем отрицательное значение MSE\n", "old_best_mse = -old_grid_search.best_score_\n", "\n", "\n", @@ -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",