d353133b31
- 新增强化学习个人项目报告,包含基于PyTorch从零实现的PPO算法 - 重构课程作业报告代码结构,提取运行时路径管理和notebook执行逻辑到独立模块 - 更新依赖文件requirements.txt,添加强化学习相关依赖 - 简化模型比较结果表格,仅保留基线逻辑回归模型数据
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import warnings
|
|
|
|
warnings.filterwarnings("ignore")
|
|
|
|
import matplotlib
|
|
|
|
matplotlib.use("Agg")
|
|
import matplotlib.pyplot as _real_mpl_plt
|
|
|
|
_real_mpl_plt.show = lambda *a, **kw: None
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
import json
|
|
import traceback
|
|
import numpy as np
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
import seaborn as sns
|
|
from sklearn.metrics import accuracy_score, f1_score, classification_report, confusion_matrix, ConfusionMatrixDisplay
|
|
from sklearn.model_selection import cross_val_score
|
|
from sklearn.preprocessing import StandardScaler, LabelEncoder
|
|
from sklearn.linear_model import LogisticRegression
|
|
from sklearn.ensemble import RandomForestClassifier, VotingClassifier
|
|
from sklearn.pipeline import Pipeline
|
|
from sklearn.compose import ColumnTransformer
|
|
from sklearn.preprocessing import OneHotEncoder
|
|
from sklearn.impute import SimpleImputer
|
|
from sklearn.cluster import KMeans
|
|
from sklearn.mixture import GaussianMixture
|
|
from sklearn.metrics import silhouette_score
|
|
from sklearn.decomposition import PCA
|
|
import xgboost as xgb
|
|
import optuna
|
|
optuna.logging.set_verbosity(optuna.logging.WARNING)
|
|
|
|
from src.notebook_runner import execute_notebook
|
|
from src.runtime_paths import build_paths
|
|
|
|
paths = build_paths()
|
|
print(f"Project root : {paths.project_root}")
|
|
print(f"Notebook : {paths.notebook}")
|
|
print(f"Data dir : {paths.data_dir}")
|
|
print(f"Output dir : {paths.output_dir}")
|
|
|
|
ns = vars()
|
|
|
|
result = execute_notebook(namespace=ns)
|
|
print(f"\nExecution finished: {result['status']}")
|
|
print(f"Cells run: {len([c for c in result['cells'] if c['status'] == 'ok'])}/{result['total']}")
|
|
print(f"Output dir: {result['outputs']['output_dir']}") |