plt.subplot(1,1,1) ConfusionMatrixDisplay(data['cm']).plot(cmap='Blues') plt.title('Confusion Matrix') plt.tight_layout() ifsave_path: plt.savefig(f"{save_path}/{model_name}_cm.png", bbox_inches='tight') ...
) for i in range(int(N))]) # 格式化布局 fig.update_layout( xaxis=dict(showgrid=False, zeroline=False, showticklabels=False), yaxis=dict(zeroline=False, gridcolor='white'), paper_bgcolor='rgb(233,233,233)', plot_bgcolor='rgb(233,233,233)', ) fig.show() 1. 2. 3. 4. 5. ...
shap.summary_plot(shap_values_nn,X_test) 最重要的能源消耗指标(基于DNN) 红色:特征重要性高 紫色:特征重要性中 蓝色:特征重要性低 通过决策图检验XAI-Shapley结果的有效性,如下图所示,展示不同重要特征向预期SHAP解释器值的收敛。 shap.decision_plot(explainer2.expected_value,shap_values_nn) 能耗决策图 上...
异常检测(Anomaly Detection)方法与Python实现 异常检测(Anomaly detection)是机器学习的常见应用,其目标是识别数据集中的异常或不寻常模式。尽管通常被归类为非监督学习问题,异常检测却具有与监督学习相似的特征。在异常检测中,我们通常处理的是未标记的数据,即没有明确的标签指示哪些样本是异常的。相反,算法需要根据数据...
def plot_decision_boundary(model, axis): x0, x1 = np.meshgrid( np.linspace(axis[0], axis[1], int((axis[1] - axis[0]) * 100)).reshape(-1, 1), np.linspace(axis[2], axis[3], int((axis[3] - axis[2]) * 100)).reshape(-1, 1) ...
colors=\[plt.cm.Spectral(i/float(len(labels\_2)))foriinrange(len(labels\_2))\]plt.figure(figsize=(12,8),dpi=80)squarify.plot(sizes=sizes\_2,label=labels\_2,color=colors,alpha=.8)plt.title('电影年份树状图')plt.axis('off') ...
import matplotlib.pyplot as pltimport numpy as np# 生成数据x = np.random.randn(1000)# 绘图plt.boxplot(x)# 添加网格plt.grid(axis='y', ls=':', lw=1, color='gray', alpha=0.4)plt.show() 8. 误差棒图 —— errorbar() 此函数用于绘制y轴方向或者x轴方向的误差范围: import matplotlib.py...
concat([topic_words, df], axis=1) topic_words.columns = pd.MultiIndex.from_tuples(topic_words.columns) pd.set_option('expand_frame_repr', False) print(topic_words.head()) pd.Series(topic_coherence, index=topic_labels).plot.bar(); 这显示了每个话题的以下顶级单词: 话题1话题2话题3话题4...
plt.plot(x, x, 'r--', x, x**2, 'bs', x, x**3, 'g^') plt.show() 图表显示结果为: 3.直方图 直方图也是一种常用的简单图表,本例中我们在同一张图片中绘制两个概率直方图。 import numpy as np import matplotlib.pyplot as plt np.random.seed(19680801) mu1, sigma1 = 100, 15 mu2,...
X_scores = clf.negative_outlier_factor_ plt.title('Locla Outlier Factor (LOF)') plt.scatter(X[:, 0], X[:, 1], color='k', s=3., label='Data points') # plot circles with radius proportional to thr outlier scores radius = (X_scores.max() - X_scores) / (X_scores.max() -...