累积局部效应 (ALE) 图分析记录

Git地址:https://github.com/blent-ai/ALEPython/tree/dev

查看源码需要pip install alepython安装,这边查看源码发现就实际就一个py文件而已,我懒得再去安装,故直接下载源码,调用方法也可;

 

# -*- coding: utf-8 -*-
"""ALE plotting for continuous or categorical features."""
from collections.abc import Iterable
from functools import reduce
from itertools import product
from operator import addimport matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy
import seaborn as sns
from matplotlib.patches import Rectangle
from scipy.spatial import cKDTreedef _parse_features(features):"""Standardise representation of column labels.Args:features : objectOne or more column labels.Returns:features : array-likeAn array of input features.Examples-------->>> _parse_features(1)array([1])>>> _parse_features(('a', 'b'))array(['a', 'b'], dtype='<U1')"""if isinstance(features, Iterable) and not isinstance(features, str):# If `features` is a non-string iterable.return np.asarray(features)else:# If `features` is not an iterable, or it is a string, then assume it# represents one column label.return np.asarray([features])def _check_two_ints(values):"""Retrieve two integers.Parameters----------values : [2-iterable of] intValues to process.Returns-------values : 2-tuple of intThe processed integers.Raises------ValueErrorIf more than 2 values are given.ValueErrorIf the values are not integers.Examples-------->>> _check_two_ints(1)(1, 1)>>> _check_two_ints((1, 2))(1, 2)>>> _check_two_ints((1,))(1, 1)"""if isinstance(values, (int, np.integer)):values = (values, values)elif len(values) == 1:values = (values[0], values[0])elif len(values) != 2:raise ValueError("'{}' values were given. Expected at most 2.".format(len(values)))if not all(isinstance(n_bin, (int, np.integer)) for n_bin in values):raise ValueError("All values must be an integer. Got types '{}' instead.".format({type(n_bin) for n_bin in values}))return valuesdef _get_centres(x):"""Return bin centres from bin edges.Parameters----------x : array-likeThe first axis of `x` will be averaged.Returns-------centres : array-likeThe centres of `x`, the shape of which is (N - 1, ...) for`x` with shape (N, ...).Examples-------->>> import numpy as np>>> x = np.array([0, 1, 2, 3])>>> _get_centres(x)array([0.5, 1.5, 2.5])"""return (x[1:] + x[:-1]) / 2def _ax_title(ax, title, subtitle=""):"""Add title to axis.Parameters----------ax : matplotlib.axes.AxesAxes object to add title to.title : strAxis title.subtitle : str, optionalSub-title for figure. Will appear one line below `title`."""ax.set_title("\n".join((title, subtitle)))def _ax_labels(ax, xlabel=None, ylabel=None):"""Add labels to axis.Parameters----------ax : matplotlib.axes.AxesAxes object to add labels to.xlabel : str, optionalX axis label.ylabel : str, optionalY axis label."""if xlabel is not None:ax.set_xlabel(xlabel)if ylabel is not None:ax.set_ylabel(ylabel)def _ax_quantiles(ax, quantiles, twin="x"):"""Plot quantiles of a feature onto axis.Parameters----------ax : matplotlib.axes.AxesAxis to modify.quantiles : array-likeQuantiles to plot.twin : {'x', 'y'}, optionalSelect the axis for which to plot quantiles.Raises------ValueErrorIf `twin` is not one of 'x' or 'y'."""if twin not in ("x", "y"):raise ValueError("'twin' should be one of 'x' or 'y'.")# Duplicate the 'opposite' axis so we can define a distinct set of ticks for the# desired axis (`twin`).ax_mod = ax.twiny() if twin == "x" else ax.twinx()# Set the new axis' ticks for the desired axis.getattr(ax_mod, "set_{twin}ticks".format(twin=twin))(quantiles)# Set the corresponding tick labels.# Calculate tick label percentage values for each quantile (bin edge).percentages = (100 * np.arange(len(quantiles), dtype=np.float64) / (len(quantiles) - 1))# If there is a fractional part, add a decimal place to show (part of) it.fractional = (~np.isclose(percentages % 1, 0)).astype("int8")getattr(ax_mod, "set_{twin}ticklabels".format(twin=twin))(["{0:0.{1}f}%".format(percent, format_fraction)for percent, format_fraction in zip(percentages, fractional)],color="#545454",fontsize=7,)getattr(ax_mod, "set_{twin}lim".format(twin=twin))(getattr(ax, "get_{twin}lim".format(twin=twin))())def _first_order_quant_plot(ax, quantiles, ale, **kwargs):"""First order ALE plot.Parameters----------ax : matplotlib.axes.AxesAxis to plot onto.quantiles : array-likeALE quantiles.ale : array-likeALE to plot.**kwargs : plot properties, optionalAdditional keyword parameters are passed to `ax.plot`."""ax.plot(_get_centres(quantiles), ale, **kwargs)def _second_order_quant_plot(fig, ax, quantiles_list, ale, mark_empty=True, n_interp=50, **kwargs
):"""Second order ALE plot.Parameters----------ax : matplotlib.axes.AxesAxis to plot onto.quantiles_list : array-likeALE quantiles for the first (`quantiles_list[0]`) and second(`quantiles_list[1]`) features.ale : masked arrayALE to plot. Where `ale.mask` is True, this denotes bins where no samples wereavailable. See `mark_empty`.mark_empty : bool, optionalIf True, plot rectangles over bins that did not contain any samples.n_interp : [2-iterable of] int, optionalThe number of interpolated samples generated from `ale` prior to contourplotting. Two integers may be given to specify different interpolation stepsfor the two features.**kwargs : contourf properties, optionalAdditional keyword parameters are passed to `ax.contourf`.Raises------ValueErrorIf `n_interp` values were not integers.ValueErrorIf more than 2 values were given for `n_interp`."""centres_list = [_get_centres(quantiles) for quantiles in quantiles_list]n_x, n_y = _check_two_ints(n_interp)x = np.linspace(centres_list[0][0], centres_list[0][-1], n_x)y = np.linspace(centres_list[1][0], centres_list[1][-1], n_y)X, Y = np.meshgrid(x, y, indexing="xy")ale_interp = scipy.interpolate.interp2d(centres_list[0], centres_list[1], ale.T)CF = ax.contourf(X, Y, ale_interp(x, y), cmap="bwr", levels=30, alpha=0.7, **kwargs)if mark_empty and np.any(ale.mask):# Do not autoscale, so that boxes at the edges (contourf only plots the bin# centres, not their edges) don't enlarge the plot.plt.autoscale(False)# Add rectangles to indicate cells without samples.for i, j in zip(*np.where(ale.mask)):ax.add_patch(Rectangle([quantiles_list[0][i], quantiles_list[1][j]],quantiles_list[0][i + 1] - quantiles_list[0][i],quantiles_list[1][j + 1] - quantiles_list[1][j],linewidth=1,edgecolor="k",facecolor="none",alpha=0.4,))fig.colorbar(CF)def _get_quantiles(train_set, feature, bins):"""Get quantiles from a feature in a dataset.Parameters----------train_set : pandas.core.frame.DataFrameDataset containing feature `feature`.feature : column labelFeature for which to calculate quantiles.bins : intThe number of quantiles is calculated as `bins + 1`.Returns-------quantiles : array-likeQuantiles.bins : intNumber of bins, `len(quantiles) - 1`. This may be lower than the original`bins` if identical quantiles were present.Raises------ValueErrorIf `bins` is not an integer.Notes-----When using this definition of quantiles in combination with a half open interval(lower quantile, upper quantile], care has to taken that the smallest observationis included in the first bin. This is handled transparently by `np.digitize`."""if not isinstance(bins, (int, np.integer)):raise ValueError("Expected integer 'bins', but got type '{}'.".format(type(bins)))quantiles = np.unique(np.quantile(train_set[feature], np.linspace(0, 1, bins + 1), interpolation="lower"))bins = len(quantiles) - 1return quantiles, binsdef _first_order_ale_quant(predictor, train_set, feature, bins):"""Estimate the first-order ALE function for single continuous feature data.Parameters----------predictor : callablePrediction function.train_set : pandas.core.frame.DataFrameTraining set on which the model was trained.feature : column labelFeature name. A single column label.bins : intThis defines the number of bins to compute. The effective number of bins maybe less than this as only unique quantile values of train_set[feature] areused.Returns-------ale : array-likeThe first order ALE.quantiles : array-likeThe quantiles used."""quantiles, _ = _get_quantiles(train_set, feature, bins)# Define the bins the feature samples fall into. Shift and clip to ensure we are# getting the index of the left bin edge and the smallest sample retains its index# of 0.indices = np.clip(np.digitize(train_set[feature], quantiles, right=True) - 1, 0, None)# Assign the feature quantile values to two copied training datasets, one for each# bin edge. Then compute the difference between the corresponding predictionspredictions = []for offset in range(2):mod_train_set = train_set.copy()mod_train_set[feature] = quantiles[indices + offset]predictions.append(predictor(mod_train_set))# The individual effects.effects = predictions[1] - predictions[0]# Average these differences within each bin.index_groupby = pd.DataFrame({"index": indices, "effects": effects}).groupby("index")mean_effects = index_groupby.mean().to_numpy().flatten()ale = np.array([0, *np.cumsum(mean_effects)])# The uncentred mean main effects at the bin centres.ale = _get_centres(ale)# Centre the effects by subtracting the mean (the mean of the individual# `effects`, which is equivalently calculated using `mean_effects` and the number# of samples in each bin).ale -= np.sum(ale * index_groupby.size() / train_set.shape[0])return ale, quantilesdef _second_order_ale_quant(predictor, train_set, features, bins):"""Estimate the second-order ALE function for two continuous feature data.Parameters----------predictor : callablePrediction function.train_set : pandas.core.frame.DataFrameTraining set on which the model was trained.features : 2-iterable of column labelThe two desired features, as two column labels.bins : [2-iterable of] intThis defines the number of bins to compute. The effective number of bins maybe less than this as only unique quantile values of train_set[feature] areused. If one integer is given, this is used for both features.Returns-------ale : (M, N) masked arrayThe second order ALE. Elements are masked where no data was available.quantiles : 2-tuple of array-likeThe quantiles used: first the quantiles for `features[0]` with shape (M + 1,),then for `features[1]` with shape (N + 1,).Raises------ValueErrorIf `features` does not contain 2 features.ValueErrorIf more than 2 bins are given.ValueErrorIf bins are not integers."""features = _parse_features(features)if len(features) != 2:raise ValueError("'features' contained '{n_feat}' features. Expected 2.".format(n_feat=len(features)))quantiles_list, bins_list = tuple(zip(*(_get_quantiles(train_set, feature, n_bin)for feature, n_bin in zip(features, _check_two_ints(bins)))))# Define the bins the feature samples fall into. Shift and clip to ensure we are# getting the index of the left bin edge and the smallest sample retains its index# of 0.indices_list = [np.clip(np.digitize(train_set[feature], quantiles, right=True) - 1, 0, None)for feature, quantiles in zip(features, quantiles_list)]# Invoke the predictor at the corners of the bins. Then compute the second order# difference between the predictions at the bin corners.predictions = {}for shifts in product(*(range(2),) * 2):mod_train_set = train_set.copy()for i in range(2):mod_train_set[features[i]] = quantiles_list[i][indices_list[i] + shifts[i]]predictions[shifts] = predictor(mod_train_set)# The individual effects.effects = (predictions[(1, 1)] - predictions[(1, 0)]) - (predictions[(0, 1)] - predictions[(0, 0)])# Group the effects by their indices along both axes.index_groupby = pd.DataFrame({"index_0": indices_list[0], "index_1": indices_list[1], "effects": effects}).groupby(["index_0", "index_1"])# Compute mean effects.mean_effects = index_groupby.mean()# Get the indices of the mean values.group_indices = mean_effects.indexvalid_grid_indices = tuple(zip(*group_indices))# Extract only the data.mean_effects = mean_effects.to_numpy().flatten()# Get the number of samples in each bin.n_samples = index_groupby.size().to_numpy()# Create a 2D array of the number of samples in each bin.samples_grid = np.zeros(bins_list)samples_grid[valid_grid_indices] = n_samplesale = np.ma.MaskedArray(np.zeros((len(quantiles_list[0]), len(quantiles_list[1]))),mask=np.ones((len(quantiles_list[0]), len(quantiles_list[1]))),)# Mark the first row/column as valid, since these are meant to contain 0s.ale.mask[0, :] = Falseale.mask[:, 0] = False# Place the mean effects into the final array.# Since `ale` contains `len(quantiles)` rows/columns the first of which are# guaranteed to be valid (and filled with 0s), ignore the first row and column.ale[1:, 1:][valid_grid_indices] = mean_effects# Record where elements were missing.missing_bin_mask = ale.mask.copy()[1:, 1:]if np.any(missing_bin_mask):# Replace missing entries with their nearest neighbours.# Calculate the dense location matrices (for both features) of all bin centres.centres_list = np.meshgrid(*(_get_centres(quantiles) for quantiles in quantiles_list), indexing="ij")# Select only those bin centres which are valid (had observation).valid_indices_list = np.where(~missing_bin_mask)tree = cKDTree(np.hstack(tuple(centres[valid_indices_list][:, np.newaxis]for centres in centres_list)))row_indices = np.hstack([inds.reshape(-1, 1) for inds in np.where(missing_bin_mask)])# Select both columns for each of the rows above.column_indices = np.hstack((np.zeros((row_indices.shape[0], 1), dtype=np.int8),np.ones((row_indices.shape[0], 1), dtype=np.int8),))# Determine the indices of the points which are nearest to the empty bins.nearest_points = tree.query(tree.data[row_indices, column_indices])[1]nearest_indices = tuple(valid_indices[nearest_points] for valid_indices in valid_indices_list)# Replace the invalid bin values with the nearest valid ones.ale[1:, 1:][missing_bin_mask] = ale[1:, 1:][nearest_indices]# Compute the cumulative sums.ale = np.cumsum(np.cumsum(ale, axis=0), axis=1)# Subtract first order effects along both axes separately.for i in range(2):# Depending on `i`, reverse the arguments to operate on the opposite axis.flip = slice(None, None, 1 - 2 * i)# Undo the cumulative sum along the axis.first_order = ale[(slice(1, None), ...)[flip]] - ale[(slice(-1), ...)[flip]]# Average the diffs across the other axis.first_order = (first_order[(..., slice(1, None))[flip]]+ first_order[(..., slice(-1))[flip]]) / 2# Weight by the number of samples in each bin.first_order *= samples_grid# Take the sum along the axis.first_order = np.sum(first_order, axis=1 - i)# Normalise by the number of samples in the bins along the axis.first_order /= np.sum(samples_grid, axis=1 - i)# The final result is the cumulative sum (with an additional 0).first_order = np.array([0, *np.cumsum(first_order)]).reshape((-1, 1)[flip])# Subtract the first order effect.ale -= first_order# Compute the ALE at the bin centres.ale = (reduce(add,(ale[i : ale.shape[0] - 1 + i, j : ale.shape[1] - 1 + j]for i, j in list(product(*(range(2),) * 2))),)/ 4)# Centre the ALE by subtracting its expectation value.ale -= np.sum(samples_grid * ale) / train_set.shape[0]# Mark the originally missing points as such to enable later interpretation.ale.mask = missing_bin_maskreturn ale, quantiles_listdef ale_plot(model,train_set,features,bins=10,monte_carlo=False,predictor=None,features_classes=None,monte_carlo_rep=50,monte_carlo_ratio=0.1,rugplot_lim=1000,
):"""Plots ALE function of specified features based on training set.Parameters----------model : objectAn object that implements a 'predict' method. If None, a `predictor` functionmust be supplied which will be used instead of `model.predict`.train_set : pandas.core.frame.DataFrameTraining set on which model was trained.features : [2-iterable of] column labelOne or two features for which to plot the ALE plot.bins : [2-iterable of] int, optionalNumber of bins used to split feature's space. 2 integers can only be givenwhen 2 features are supplied in order to compute a different number ofquantiles for each feature.monte_carlo : boolean, optionalCompute and plot Monte-Carlo samples.predictor : callableCustom prediction function. See `model`.features_classes : iterable of str, optionalIf features is first-order and a categorical variable, plot ALE according todiscrete aspect of data.monte_carlo_rep : intNumber of Monte-Carlo replicas.monte_carlo_ratio : floatProportion of randomly selected samples from dataset for each Monte-Carloreplica.rugplot_lim : int, optionalIf `train_set` has more rows than `rugplot_lim`, no rug plot will be plotted.Set to None to always plot rug plots. Set to 0 to always plot rug plots.Raises------ValueErrorIf both `model` and `predictor` are None.ValueErrorIf `len(features)` not in {1, 2}.ValueErrorIf multiple bins were given for 1 feature.NotImplementedErrorIf `features_classes` is not None."""if model is None and predictor is None:raise ValueError("If 'model' is None, 'predictor' must be supplied.")if features_classes is not None:raise NotImplementedError("'features_classes' is not implemented yet.")fig, ax = plt.subplots()features = _parse_features(features)if len(features) == 1:if not isinstance(bins, (int, np.integer)):raise ValueError("1 feature was given, but 'bins' was not an integer.")if features_classes is None:# Continuous data.if monte_carlo:mc_replicates = np.asarray([[np.random.choice(range(train_set.shape[0]))for _ in range(int(monte_carlo_ratio * train_set.shape[0]))]for _ in range(monte_carlo_rep)])for k, rep in enumerate(mc_replicates):train_set_rep = train_set.iloc[rep, :]# Make this recursive?if features_classes is None:# The same quantiles cannot be reused here as this could cause# some bins to be empty or contain disproportionate numbers of# samples.mc_ale, mc_quantiles = _first_order_ale_quant(model.predict if predictor is None else predictor,train_set_rep,features[0],bins,)_first_order_quant_plot(ax, mc_quantiles, mc_ale, color="#1f77b4", alpha=0.06)ale, quantiles = _first_order_ale_quant(model.predict if predictor is None else predictor,train_set,features[0],bins,)_ax_labels(ax, "Feature '{}'".format(features[0]), "")_ax_title(ax,"First-order ALE of feature '{0}'".format(features[0]),"Bins : {0} - Monte-Carlo : {1}".format(len(quantiles) - 1,mc_replicates.shape[0] if monte_carlo else "False",),)ax.grid(True, linestyle="-", alpha=0.4)if rugplot_lim is None or train_set.shape[0] <= rugplot_lim:sns.rugplot(train_set[features[0]], ax=ax, alpha=0.2)_first_order_quant_plot(ax, quantiles, ale, color="black")_ax_quantiles(ax, quantiles)elif len(features) == 2:if features_classes is None:# Continuous data.ale, quantiles_list = _second_order_ale_quant(model.predict if predictor is None else predictor,train_set,features,bins,)_second_order_quant_plot(fig, ax, quantiles_list, ale)_ax_labels(ax,"Feature '{}'".format(features[0]),"Feature '{}'".format(features[1]),)for twin, quantiles in zip(("x", "y"), quantiles_list):_ax_quantiles(ax, quantiles, twin=twin)_ax_title(ax,"Second-order ALE of features '{0}' and '{1}'".format(features[0], features[1]),"Bins : {0}x{1}".format(*[len(quant) - 1 for quant in quantiles_list]),)else:raise ValueError("'{n_feat}' 'features' were given, but only up to 2 are supported.".format(n_feat=len(features)))plt.show()return ax

本地源码验证使用:

 

参考:8.2 Accumulated Local Effects (ALE) Plot | Interpretable Machine Learning

https://github.com/blent-ai/ALEPython/tree/dev

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/478406.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

远程控制软件:探究云计算和人工智能的融合

在数字化时代&#xff0c;远程控制工具已成为我们工作与生活的重要部分。用户能够通过网络远程操作和管理另一台计算机&#xff0c;极大地提升了工作效率和便捷性。随着人工智能&#xff08;AI&#xff09;和云计算技术的飞速发展&#xff0c;远程控制工具也迎来了新的发展机遇…

正则表达式灾难:重新认识“KISS原则”的意义

RSS Feed 文章标题整理 微积分在生活中的应用与思维启发 捕鹿到瞬时速度的趣味探索 微积分是一扇通往更广阔世界的门&#xff0c;从生活中学习思维的工具。 数据库才是最强架构 你还在被“复杂架构”误导吗&#xff1f; 把业务逻辑写入数据库&#xff0c;重新定义简单与效率。…

网络原理(一):应用层自定义协议的信息组织格式 初始 HTTP

目录 1. 应用层 2. 自定义协议 2.1 根据需求 > 明确传输信息 2.2 约定好信息组织的格式 2.2.1 行文本 2.2.2 xml 2.2.3 json 2.2.4 protobuf 3. HTTP 协议 3.1 特点 4. 抓包工具 1. 应用层 在前面的博客中, 我们了解了 TCP/IP 五层协议模型: 应用层传输层网络层…

【JUC-Interrupt】中断相关概念

线程中断 一、相关概念二、API2.1、isInterrupted方法2.2、interrupted方法2.3、interrupt 三、总结&#xff1a; 一、相关概念 一个线程不应该由其他线程中断或停止&#xff0c;应该有线程自己来决定。 在Java中没有办法立即停止一个线程&#xff0c;因此提供了用于停止线程…

直播技术-Android基础框架

目录 &#xff08;一&#xff09;直播间架构 &#xff08;二&#xff09;核心任务调度机制 &#xff08;1&#xff09;复制从滑动直播间加载流程 &#xff08;2&#xff09;核心任务调度机制-代码设计 &#xff08;3&#xff09;核心任务调度机制-接入指南 (三&#xff0…

【es6】原生js在页面上画矩形添加选中状态高亮及显示调整大小控制框(三)

接上篇文章&#xff0c;这篇实现下选中当前元素显示调整大小的控制框&#xff0c;点击document取消元素的选中高亮状态效果。 实现效果 代码逻辑 动态生成控制按钮矩形,并设置响应的css // 动态添加一个调整位置的按钮addScaleBtn(target) {const w target.offsetWidth;con…

ArcGIS应用指南:ArcGIS制作局部放大地图

在地理信息系统&#xff08;GIS&#xff09;中&#xff0c;制作详细且美观的地图是一项重要的技能。地图制作不仅仅是简单地将地理数据可视化&#xff0c;还需要考虑地图的可读性和美观性。局部放大图是一种常见的地图设计技巧&#xff0c;用于展示特定区域的详细信息&#xff…

记录一些PostgreSQL操作

本文分享一些pg操作 查看版本 select version(); PostgreSQL 11.11 查看安装的插件 select * from pg_available_extensions; 查看分词效果 select ‘我爱北京天安门,天安门上太阳升’::tsvector; ‘天安门上太阳升’:2 ‘我爱北京天安门’:1select to_tsvector(‘我爱北京天…

RHCSA作业2

压缩 将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz [rootjyh ~]# cd /etc [rootjyh etc]# tar -czf etcback.tar.gz /etc tar: Removing leading / from member names tar: /etc/etcback.tar.gz: file changed as we read it [rootjyh etc]# ls使当…

大语言模型(LLM)安全:十大风险、影响和防御措施

一、什么是大语言模型&#xff08;LLM&#xff09;安全&#xff1f; 大语言模型&#xff08;LLM&#xff09;安全侧重于保护大型语言模型免受各种威胁&#xff0c;这些威胁可能会损害其功能、完整性和所处理的数据。这涉及实施措施来保护模型本身、它使用的数据以及支持它的基…

递推进阶与入门递归

一、递推进阶&#xff0c;勇攀高峰 昆虫繁殖 题目描述 科学家在热带森林中发现了一种特殊的昆虫&#xff0c;这种昆虫的繁殖能力很强。每对成虫过X个月产Y对卵&#xff0c;每对卵要过两个月长成成虫。假设每个成虫不死&#xff0c;第一个月只有一对成虫&#xff0c;且卵长成成虫…

深入浅出:JVM 的架构与运行机制

一、什么是JVM 1、什么是JDK、JRE、JVM JDK是 Java语言的软件开发工具包&#xff0c;也是整个java开发的核心&#xff0c;它包含了JRE和开发工具包JRE&#xff0c;Java运行环境&#xff0c;包含了JVM和Java的核心类库&#xff08;Java API&#xff09;JVM&#xff0c;Java虚拟…

极客大挑战2024wp

极客大挑战2024wp web 和misc 都没咋做出来&#xff0c;全靠pwn✌带飞 排名 密码学和re没做出几个&#xff0c;就不发了 web ez_pop 源代码 <?php Class SYC{public $starven;public function __call($name, $arguments){if(preg_match(/%|iconv|UCS|UTF|rot|quoted…

C++设计模式-策略模式-StrategyMethod

动机&#xff08;Motivation&#xff09; 在软件构建过程中&#xff0c;某些对象使用的算法可能多种多样&#xff0c;经常改变&#xff0c;如果将这些算法都编码到对象中&#xff0c;将会使对象变得异常复杂&#xff1b;而且有时候支持不使用的算法也是一个性能负担。 如何在运…

【初阶数据结构和算法】leetcode刷题之设计循环队列

文章目录 一、实现循环队列1.大致思路分析2.循环队列的结构定义和初始化结构定义初始化 3.循环队列的判空和判满判空和判满难点分析判空判满 4.循环队列的入队列和出队列入队列出队列 5.循环队列取队头和队尾元素取队头元素取队尾元素 6.循环队列的销毁7.最后题解源码 一、实现…

【网络通信】数据集合集!

本文将为您介绍经典、热门的数据集&#xff0c;希望对您在选择适合的数据集时有所帮助。 1 RITA 更新时间&#xff1a;2024-11-22 访问地址: GitHub 描述&#xff1a; RITA 是一个用于网络流量分析的开源框架。 该框架以 TSV 或 JSON 格式提取 Zeek 日志&#xff0c;目前支…

.net core MVC入门(一)

文章目录 项目地址一、环境配置1.1 安装EF core需要包1.2 配置数据库连接二、使用EF创建表2.1 整体流程梳理2.1 建表详细流程三、添加第一个视图3.1整体流程梳理3.1 添加视图,并显示在web里四、使用EF增加Catogory数据,并且读取数据到页面4.1整体流程梳理4.2 实现五、增加Cat…

蓝桥杯不知道叫什么题目

小蓝有一个整数&#xff0c;初始值为1&#xff0c;他可以花费一些代价对这个整数进行变换。 小蓝可以花贵1的代价将教数增加1。 小蓝可以花费3的代价将整数增加一个值,这个值是整数的数位中最大的那个(1到9) .小蓝可以花费10的代价将整数变为原来的2倍, 例如&#xff0c;如果整…

css效果

css炫彩流光圆环效果 <!DOCTYPE html> <html><head><meta charset"utf-8" /><title></title><style>*{margin: 0;padding: 0;}body{width: 100%;height: 100vh;}.container{position: relative;width: 100%;height: 100vh…

提供html2canvas+jsPDF将HTML页面以A4纸方式导出为PDF后,内容分页时存在截断的解决思路

前言 最近公司有个系统要做一个质量报告导出为PDF的需求&#xff0c;这个报表的内容是固定格式&#xff0c;但是不固定内容多少的&#xff0c;网上找了很多资料&#xff0c;没有很好的解决我的问题&#xff0c;pdfmakde、还有html2CanvasjsPDF以及Puppeteer无头浏览器的方案都不…