【深度学习】论文复现-对论文数据集的一些处理

devtools/2024/12/22 2:14:05/

如何书写伪代码:
ref:https://www.bilibili.com/video/BV12D4y1j7Zf/?vd_source=3f7ae4b9d3a2d84bf24ff25f3294d107

i=14时产出的图片比较合理

import json
import os.path
from matplotlib.ticker import FuncFormatter
import pandas as pd
import matplotlib.pyplot as plt# csv_path= r"/home/justin/Desktop/code/python_project/mypaper/data_process/CAM-01-SRV-lvm0.csv"
# df = pd.read_csv(csv_path, header=0, sep=",")
# df.head(5)
# df = df[["Timestamp", "Hostname", "DiskNumber", "Type", "LBA", "Size", "ResponseTime"]][df["Type"] == "Read"].reset_index(drop=True)
# base_dir = os.path.dirname(os.path.abspath(__file__))
# for i in range(1, 30):
#     # 勾画出,数据的请求分布
#     start_row = i * 100
#     end_row = (i + 1) * 100
#     print(start_row, end_row)
#     df1 = df[['LBA']][start_row:end_row]
#     from matplotlib.ticker import ScalarFormatter
#     plt.plot(df1.index, df1.LBA)
#     plt.title('Irregularity of I/O access locality')
#     plt.xlabel('Access Order')
#     plt.ylabel('Logical Block Address (unit:B)')
#     def format_ticks(x, _):
#         return f'{int(x):,}'
#     plt.gca().yaxis.set_major_formatter(FuncFormatter(format_ticks),ScalarFormatter(useMathText=False))
#     plt.gca().yaxis.get_major_formatter().set_scientific(False)
#     plt.subplots_adjust(left=0.25)
#     # plt.show()
#     save_img_path = os.path.join(base_dir, 'weak_locality','irregularity_io_access_locality_{}.png'.format(i))
#     print(save_img_path)
#     plt.savefig(save_img_path, format='png')
#     plt.clf()import os
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter, MultipleLocator# Load the CSV file
csv_path = r"/home/justin/Desktop/code/python_project/mypaper/data_process/CAM-01-SRV-lvm0.csv"
df = pd.read_csv(csv_path, header=0, sep=",")
df.head(5)
pd.set_option('display.max_rows', None)  # Show all rows
pd.set_option('display.max_columns', None)  # Show all columns
pd.set_option('display.expand_frame_repr', False)  # Prevent line wrapping for large DataFrames# Optionally, if you want to set width and precision for better formatting
pd.set_option('display.width', None)  # Auto-detect the width of the display
pd.set_option('display.precision', 3) # Filter the DataFrame for 'Read' types and specific columns
df = df[["Timestamp", "Hostname", "DiskNumber", "Type", "LBA", "Size", "ResponseTime"]][df["Type"] == "Read"].reset_index(drop=True)
# Calculate the differences
df['LBA_diff'] = df['LBA'].diff()# Drop NaN values resulting from the difference computation
df = df.dropna(subset=['LBA_diff'])
LBA_diff_list = df['LBA_diff'].tolist()# def find_repeated_sequences(lst, length):
#     """
#     Find and return the first and last indices of the first repeating sequence of the given length.#     :param lst: List of integers to search for repeating sequences.
#     :param length: Length of the sequence to look for.
#     :return: Tuple containing the first and last indices of the first repeating sequence, or None if not found.
#     """
#     sequence_indices = {}
#     first_index = None
#     last_index = None#     # Iterate through the list to find sequences of the specified length
#     for i in range(len(lst) - length + 1):
#         # Get the current sequence as a tuple (to allow it to be a dictionary key)
#         current_sequence = tuple(lst[i:i + length])#         if current_sequence in sequence_indices:
#             # If the sequence has been seen before, update indices
#             first_index = sequence_indices[current_sequence][0]  # First occurrence
#             last_index = i  # Update last occurrence
#             break  # Only need the first repeating sequence
#         else:
#             # Store the index of the first occurrence of this sequence
#             sequence_indices[current_sequence] = (i,)#     return (first_index, last_index)# # Example usage
# lst = LBA_diff_list[20000:]
# length = 5# result = find_repeated_sequences(lst, length)
# print(f"First occurrence: {result[0]}, Last occurrence: {result[1]}")
# print(df[20117:20123],df[20119:20125])
# # Exit the script if needed
# exit("==========")
# # Get the base directory path
# base_dir = os.path.dirname(os.path.abspath(__file__))# Get the base directory path
base_dir = os.path.dirname(os.path.abspath(__file__))for i in range(1, 30):if i!=14:continue# Define the start and end row indicesstart_row = i * 100end_row = (i + 1) * 100print(start_row, end_row)# Slice the necessary part of the DataFramedf1 = df[['LBA']][start_row:end_row].reset_index(drop=True)# Plot the dataplt.plot(df1.index, df1.LBA)plt.title('Irregularity of I/O Access Locality')plt.xlabel('Access Order (unit:times)')plt.ylabel('Logical Block Address (unit:B)')# Function to format y-ticks with commasdef format_ticks(x, _):return f'{int(x):,}'# Set the y-axis major formatterplt.gca().yaxis.set_major_formatter(FuncFormatter(format_ticks))# Set x-axis major and minor ticksplt.gca().xaxis.set_major_locator(MultipleLocator(10))  # Major ticks every 10 unitsplt.gca().xaxis.set_minor_locator(MultipleLocator(5))   # Minor ticks every 2 unitsax = plt.gca()  # Get the current axesax.spines['top'].set_visible(False)    # Hide the top spineax.spines['right'].set_visible(False)  # Hide the right spineax.spines['left'].set_visible(True)    # Show the left spineax.spines['bottom'].set_visible(True)# Adjust the margins if necessaryplt.subplots_adjust(left=0.25)# Constructing the save image pathsave_img_path = os.path.join(base_dir, 'weak_locality', 'irregularity_io_access_locality_{}.png'.format(i))print(save_img_path)# Save the plot as a PNG fileplt.savefig(save_img_path, format='png')# Clear the figure after savingplt.clf()# Plot the 'Size' columndf2 = df[['Size']][start_row:end_row].reset_index(drop=True)    # Set the figure sizeplt.plot(df2['Size'], marker='o',markersize=2,linestyle='-',linewidth=0.5)  # Plot with markersplt.title('Variablity of I/O Access Size')plt.xlabel('Access Order(unit:times)')plt.ylabel('Size(Unit:B)')plt.gca().xaxis.set_major_locator(MultipleLocator(10))  # Major ticks every 10 unitsplt.gca().xaxis.set_minor_locator(MultipleLocator(5))   # Minor ticks every 2 unitsax = plt.gca()  # Get the current axesax.spines['top'].set_visible(False)    # Hide the top spineax.spines['right'].set_visible(False)  # Hide the right spineax.spines['left'].set_visible(True)    # Show the left spineax.spines['bottom'].set_visible(True)# plt.grid()  # Add grid for better readabilityplt.tight_layout()  # Adjust layout to avoid clippingsave_img_path = os.path.join(base_dir, 'weak_locality', 'io_access_locality_size_{}.png'.format(i))plt.savefig(save_img_path, format='png')print(save_img_path)plt.clf()

Total count: 246990497, Only once count: 52128003, ratio: 21.11%
Mean: 35004.78260010141
Median: 32768.0 中位数
Mode: 65536.0 众数
Minimum: 512.0 最小值
Maximum: 6410240.0 最大值

\documentclass{article}
\usepackage[ruled,longend,linesnumber]{algorithm2e}
\usepackage{xeCJK}\begin{document}
\begin{algorithm}
\KwIn{我在B站刷到了本视频}
\KwOut{我学会了,给个三连}
\Begin{
我在B站刷到了本视频\;
看标题好像有点用,点进去看看\;
\While{视频正在播放}{继续观看\;\tcc{不考虑没看懂某一部分,所以一直回看的死循环}\eIf{理解}{看下部分\;下部分变为这部分\;}{回看这部分\;}
}
我学会了,给个三连!
}
\caption{如何生成好看的伪代码}
\end{algorithm}\end{document}
\documentclass{article}
\usepackage[ruled, longend, linesnumbered]{algorithm2e}
\usepackage{xeCJK}\begin{document}\begin{algorithm}
\KwIn{ $T$: LBA Sequence; \ $L$: Window size;}
\KwOut{$X$, $y$}
\tcc{X是列表,每个item包含(Delta-LBA,SIZE)两个元素数据\;y是列表,每个item包含(Delta-LBA,SIZE)两个元素数据\; L是滑动窗口大小}
\Begin{$i \gets 0$ \; $j \gets 0$ \; \While{$i + L < T.length()$}{$X[j] \gets T[i:i+L-1]$\;$y[j] \gets T[i+L]$\;$i \gets i+k$\;$j \gets j+1$\;}\KwRet{$X$, $y$}
}
\caption{LBA Feature Preprocessor}
\end{algorithm}\end{document}

http://www.ppmy.cn/devtools/144245.html

相关文章

企业为何需要可视化数据分析系统

作为当今企业最核心的资产之一的数据&#xff0c;已经成为企业发展的重要基础。随着企业的不断发展壮大&#xff0c;随之在数据处理层面就面临重要的困扰&#xff0c;面对海量数据如何提取有效信息就是关键所在。因此在这样的背景之一&#xff0c;可视化数据分析系统的构建就成…

FPGA设计-使用 lspci 和 setpci 调试xilinx的PCIe 问题

目录 简介 lspci lspci-TV lspci-vvv 注意事项 lspci -vs lspci -vvvs 设置pci 识别setpci中的寄存器 setpci -s 00:01.0 d0.b42 简介 lspci 和 setpci 命令在 Linux 发行版中本身可用。该命令具有各种级别的输出&#xff0c;并提供非常有用的时间点查看 PCI 总线…

pytorch repeat方法和expand方法的区别

PyTorch 中的 repeat 和 expand 方法都用于调整张量的形状或重复张量&#xff0c;但它们在实现方式和内存使用上有显著的区别。以下是详细对比&#xff1a; 1. repeat 方法 功能&#xff1a;通过实际复制数据来重复张量的内容。内存&#xff1a;会分配新的内存存储重复后的张…

基于SpringBoot+layui+html实现电影院售票系统【源码+数据库文件+包部署成功+答疑解惑问到会为止】

代码包运行启动成功&#xff01;不管你有没有运行环境&#xff0c;哪怕你是刚买的新电脑&#xff0c;也包启动运行成功&#xff01;有不懂的地方随便问&#xff01;问到会为止&#xff01; 功能介绍 基于SpringBoot实现电影院售票系统设计了超级管理员、管理员、测试、用户四种…

GaussDB数据库中SQL诊断解析之配置SQL限流

配置SQL限流 GaussDB提供SQL限流功能&#xff0c;当存在异常SQL&#xff08;如存在不优索引&#xff09;、SQL并发量上升时&#xff0c;通过SQL限流功能控制异常SQL的访问量或者并发量&#xff0c;保障服务的可用性。 前提条件 登录账号需要具备授权项“gaussdb:instance:li…

接口测试-Fidder及jmeter使用

一、接口测试的基础 1.接口的含义 也叫做API&#xff0c;是一组定义、程序及协议的集合&#xff0c;提供访问一组例程的能力&#xff0c;无需访问源码获理解内部工作细节 2.接口的分类 代码内部的接口&#xff0c;程序模块间的接口&#xff0c;对于程序接口测试&#xff0c;需…

springboot中Controller内文件上传到本地以及阿里云

上传文件的基本操作 <form action"/upload" method"post" enctype"multipart/form-data"> <h1>登录</h1> 姓名&#xff1a;<input type"text" name"username" required><br> 年龄&#xf…

图书馆管理系统(三)基于jquery、ajax

任务3.4 借书还书页面 任务描述 这部分主要是制作借书还书的界面&#xff0c;这里我分别制作了两个网页分别用来借书和还书。此页面&#xff0c;也是通过获取books.txt内容然后添加到表格中&#xff0c;但是借还的操作没有添加到后端中去&#xff0c;只是一个简单的前端操作。…