html table with matrix effect

本文提供了两个HTML页面示例,展示了如何使用CSS对表格进行样式设置。第一个示例展示了一个简单的带有边框的表格,并为特定单元格设置了红色边框。第二个示例则更进一步,展示了如何实现更复杂的表格布局,包括单元格背景颜色的交替变化、表格边框的折叠效果以及多个并排显示的表格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

同事帮写的。

test1.html

<html>
	<head></head>
	<style type="text/css">
		table {border: 1px solid #000;}
		td.item {border: 1px solid #f00;}
	</style>
	<body>
		<table>
			<tbody>
				<tr>
					<td class="item">a</td>
					<td class="item">b</td>
					<td class="item">c</td>
				</tr>
				<tr>
					<td class="blank"></td>
					<td class="item">y</td>
					<td class="item">z</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>

test2.html

<html>
	<head></head>
	<style type="text/css">
		table {
			border: 1px solid #000;
			border-collapse: collapse;
		}
		div.test-table {
			float: left;			
		}
		div.test-table + div.test-table {margin-left: 1px;}
		th, td.item {
			
			border: 1px solid #ccc;
			padding: 0px 5px;
			height: 1.5em;
		}
		td.odd {background-color: #eee;}
		td.even {background-color: #fff;}
	</style>
	<body>
		<div class="test-table">
			<table>
				<tbody>
					<tr>
						<th colspan="2">Compare</th>
					</tr>
					<tr>
						<td class="item odd">x</td>
						<td class="item odd">x</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="test-table">
			<table>
				<tbody>
					<tr>
						<th colspan="2">Compare</th>
					</tr>
					<tr>
						<td class="item odd">x</td>
						<td class="item odd"></td>
					</tr>
					<tr>
						<td class="item even">x</td>
						<td class="item even">x</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="test-table">
			<table>
				<tbody>
					<tr>
						<th colspan="2">Compare</th>
					</tr>
					<tr>
						<td class="item odd">x</td>
						<td class="item odd">x</td>
					</tr>
					<tr>
						<td class="item even"></td>
						<td class="item even"></td>
					</tr>
					<tr>
						<td class="item odd">x</td>
						<td class="item odd"></td>
					</tr>
				</tbody>
			</table>
		</div>		
	</body>
</html>


import pandas as pd import pymc as pm import numpy as np import pytensor.tensor as pt from scipy.sparse import csr_matrix # 加载数据 data = pd.read_excel('C:/Users/zyt/Desktop/操作.xlsx') # 使用 pivot_table 将数据转换为矩阵形式 matrix = pd.pivot_table( data, values='发病数', # 用作矩阵值的列 index='地区', # 行索引:地区名 columns='年份', # 列索引:年份 fill_value=0 # 填充缺失值为 0 ) # 获取数值数据 data_numeric = matrix.values # 31 × 16 的二维数组 # 加载邻接矩阵 adjacency_matrix = pd.read_excel('C:/Users/zyt/Desktop/33.xlsx', header=None).values # 修复邻接矩阵 adjacency_matrix = np.maximum(adjacency_matrix, adjacency_matrix.T) # 强制对称化 np.fill_diagonal(adjacency_matrix, 0) # 清理对角线 adjacency_matrix = (adjacency_matrix > 0).astype(int) # 确保元素为 0 或 1 # 转换为稀疏矩阵 W_sparse = csr_matrix(adjacency_matrix) # 构建贝叶斯时空独立模型 with pm.Model() as spatiotemporal_model: # 时间效应:ARIMA(0, 1, 2) time_effect_diff = pm.AR("time_effect_diff", rho=[0, 0], sigma=1.0, shape=data_numeric.shape[1] - 1) time_effect = pm.Deterministic("time_effect", pt.concatenate([[0], pt.cumsum(time_effect_diff)])) # 空间效应:条件自回归模型 (CAR) num_regions = data_numeric.shape[0] # CAR 模型的均值和精度 tau = pm.Gamma("tau", alpha=2, beta=0.5) # 更窄的先验 mu = pm.Normal("mu", mu=0, sigma=0.1, shape=num_regions) # 缩小标准差 space_effect = pm.CAR("space_effect", mu=mu, W=W_sparse, alpha=0.5, tau=tau, shape=num_regions) # 总效应:时间和空间效应的叠加 total_effect = pm.Deterministic( "total_effect", space_effect[:, None] + time_effect[None, :] ) # 观测模型:正态分布 likelihood = pm.Normal("likelihood", mu=total_effect.T, sigma=1, observed=data_numeric.T) # MCMC采样 trace = pm.sample(draws=1000, tune=1000, cores=1, target_accept=0.5) # 计算时间效应的后验均值和标准差 posterior_mean_time_effect = trace.posterior["time_effect"].mean(dim=("chain", "draw")) posterior_std_time_effect = trace.posterior["time_effect"].std(dim=("chain", "draw")) print("Time Effect Posterior Mean:", posterior_mean_time_effect) print("Time Effect Posterior Std:", posterior_std_time_effect) 此代码的后验抽样应用的是哪个算法
最新发布
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值