人工智能训练师_实操学习资料

更新时间: 试题数量: 购买人数: 提供作者:

有效期: 个月

章节介绍: 共有个章节

收藏
搜索
题库预览
互联网金融快速发展,使得个人金融理财更加便捷。信用评分技术是一种对贷款申请人或信用卡申请人进行风险评估的统计模型,可以结合客户提供的基础资料、历史信用数据及第三方平台数据,对客户信用状况进行综合评价。现根据提供的finance数据集和python文件,选择合适的特征,建立信用评分Logistic回归模型,并完成模型测试、结果分析和改进。 请补全如下代码: import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression import pickle from sklearn.metrics import classification_report from imblearn.over_sampling import SMOTE # 加载数据 file_path = 'finance.csv' data = pd.________(file_path) # 显示前五行的数据 print(data.________) # 选择自变量和因变量 X = data.________(['SeriousDlqin2yrs', 'Unnamed: 0'], axis=1) y = data['________'] # 分割训练集和测试集 X_train, X_test, y_train, y_test = ________ (X, y, test_size=0.2, random_state=42) # 训练Logistic回归模型 model = ________ (max_iter=1000) model.________ (X_train, y_train) # 保存模型 with open('2.2.1_model.pkl', 'wb') as file: pickle.dump(________, file) # 预测并保存结果 y_pred = model.________ (X_test) df = pd.DataFrame(y_pred, columns=['预测结果']) print(df) # 生成测试报告 report = classification_report(y_test, y_pred, zero_division=1) print("测试报告:") print(report) # 分析测试结果 accuracy = (y_test == y_pred).________() print(f"模型准确率:{accuracy:.2f}") # 处理数据不平衡 smote = ________ (random_state=42) X_resampled, y_resampled = smote.________ (X_train, y_train) # 重新训练模型 model.fit(________) # 重新预测 y_pred_resampled = model.________ (X_test) # 生成新的测试报告 report_resampled = classification_report(________, zero_division=1) print("测试报告:") print(report_resampled)
1