惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
S
Security Affairs
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
C
Cisco Blogs
T
Tor Project blog
The Hacker News
The Hacker News
雷峰网
雷峰网
MyScale Blog
MyScale Blog
博客园 - 司徒正美
AWS News Blog
AWS News Blog
GbyAI
GbyAI
Y
Y Combinator Blog
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
T
Tenable Blog
L
LangChain Blog
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
The Cloudflare Blog
A
About on SuperTechFans
IT之家
IT之家
F
Fortinet All Blogs
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
A
Arctic Wolf
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog

猫涅的秘密结社

hackthissite-org 数据库原理相关 关于在与我互动前你可能需要了解的事 信安roadmap 个人主页开发汇报 六级生词速记本——附考后感想 数据结构C++自学相关 NewStarCTF-2025 三款steam付费番茄钟软件测评 夏令营-ai hello-world qt环境下的c++程序编写 新新的年 qq机器人配置二三事 搞点java 读书笔记-当下的力量 网页小修时间 glibc更新记录 Vulhub在线靶场记录 Vulhub记录(旧的) 神奇脚本在哪里-CTF之Pwn BaseCTF高校联合新生赛2024 逆逆逆逆逆向-CTF之reverse 求解 夺旗时间 学学学 渗透测试相关 协议/漏洞/网络 最新的知识点 zico2解析 OverTheWire-bandit解析 CTF实战相关2 靶机解析-gigachad ctf实战相关1 复习time 开学季 维修时间 小小修整 学校实训-笔记 每周靶机之Beelzebub 读书笔记-如何阅读一本书 DC-4解析 DC-2解析 每周靶机之ted 靶机-DC-1 每周靶机之bob potato解析 xss跨站点脚本攻击 每周靶机之Tommyboy1dot0 owasp命令执行漏洞 owasp文件包含漏洞 每周靶机之WALLABY'S-NIGHTMARE owasp上传漏洞 Hackademic.RTB1 owasp与sql注入与sqlmap liunx中sudo服务相关知识 liunx中ssh服务相关知识 moneybox解析 C语言相关1 关于加入aplayer的方式 再来一次 关于在next7.8.0中建设评论功能这件事 目前的进展 编辑小提示
数据分析相关
nirvana_felis · 2024-04-27 · via 猫涅的秘密结社

数据分析是干啥的

-整合一堆杂乱无章的数据 把背后的信息提炼出来 使数据的价值最大化
–分析用户的消费行为 指定相应的方案 调整促销时间 力度 计算用户活跃度和产品的回购力度
–分析广告的点击率 决定广告的投放时间 制定广告方案 决定投放等等

例:
1.保险公司从大量的赔付申请数据中判断哪些存在骗保可能
2.支付宝通过用户消费记录和行为自动调整花呗额度
3.短视频通过用户的点击和观看行为给用户推送合适的视频

我为啥要学数据分析

因为我现在就得用
可以用于某些岗位或竞赛
python数据科学的基础
机器学习课程的基础

数据分析的流程

提出问题
准备数据
分析数据
获得结论
成果可视化

要用的工具

-numpy
-pandas
-matplotlib

开发环境

-anaconda|全球最受欢迎的数据啥啥啥|集成了数据分析和机器学习需要的全部环境
注意:安装目录不能有中文和特殊符号
-jupyter|anaconda提供的基于浏览器的可视化开发工具
启动方式:cmd-jupyter notebook-回车
新建方式:图形化页面-new-文件或者文件夹
python3:anaconda中的源文件
cell:可以在里面执行相关代码 code模式是代码 markdown模式是笔记
可以在编辑页面更换
快捷键:添加cell-a或者b
删除-x
修改cell的模式-m:修改成markdown
y:修改成code模式
执行cell-shift+enter
tab:自动补全
代开帮助文档:shift+tab

numpy模块的使用

创建numpy

1.1创建一个一维数组

1
2
3
4
5
import numpy as np
arr = np.array([1,2,3])
arr
输出:
array([1,2,3])

1.2创建一个多维数组

1
2
3
4
5
arr = np.array([1,2,3],[4,5,6])
arr
输出:
array([1,2,3],
[4,5,6])

数组和列表的区别是什么呢?
-数组中存储的数据元素类型都是统一的
-优先级:字符串>浮点型>整数

1
2
3
4
5
例如:
arr = np.array([1,2.2,3])
arr
输出:
array([1.,2.2,3.])

2.1将外部的一张图片读取并加载到numpy数组中

1
2
3
import matplotlib.pyplot as plt
img\_arr = plt.imread('./1.jpg')
plt.imshow(img\_arr)

输出结果即为1.jpg的图像内容

1
2
img\_arr = img\_arr - 100 
plt.imshow(img\_arr)

输出结果是色调有差别的图像内容

1
2
3
4
5
6
7
8
9
10
11
np.ones(shape=(3,4)) 
np.linspace(0,100,num=20)
np.arange(10,50,step=2)
np.random.randint(0,100,size=(5,6))
数组名.shape
数组名.ndim
数组名.size
数组名.dtype
创建数组的时候输入dtype参数来指定元素类型
或者通过 数组名.dtype = “指定类型” 来修改
type(数组名)

3.1numpy的索引和切片操作

索引和列表同理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
创建一个数组之后 我们可以取出数组的指定数据
数组名[1,4]
数组名[02]
数组名[:,0:2]
数组名[0:2,0:2]
数组名[::-1]
数组名[:,::-1]
数组名[::-1,::-1]
左右反转图片
img\_arr = plt.imread('./1.jpg')
plt.imshow(img\_arr[:,::-1,:])
上下反转图片
plt.imshow(img\_arr[::-1,:,:])
图片裁剪功能
plt.imshow(img\_arr[66:200,78:300,:])
变形(reshape)
数组名.reshape((30,))
数组名.reshape((2,15))
数组名.reshape((6,5))
级联操作
-将多个numpy数组进行横向纵向的拼接
axis轴向
0为列 纵向拼接 1为行 横向拼接(行与列无法对应会报错哦)
np.consatenate((数列1,数列2),axis=1)
图片的拼接
np.consatenate((数列1,数列2,数列3),axis=1)
plt.imshow(img\_arr)
常用聚合操作
-sum,max,min,mean
计算和 最大值 最小值 求均值
-sin,cos,tan
三角函数
around(a,decimals)
a:数组名 decimals:舍入的小数位数
numpy.amin()和numpy.amax(),用于计算数组中的元素沿指定轴的最小、最大值。
numpy.ptp(),计算数组中元素最大值与最小值的差
numpy.median(),计算数组中元素的中位数
std() var()输出标准差与方差 方差就是标准差的平方
使用例:
数组名[1].std()
还有数学里的矩阵相加 相减 相乘
eye()
.T
np.dot(数列1,数列2)

panda基础操作

numpy是用来处理数值型的数据 还有很多其他类型的数据(字符串,时间序列)
那么什么是pandas捏?
首先来认识pandas中的两个常用的类
-Series
-DataFrame
Series是一种类似于一维数组的对象,由下面两个部分组成:
values:一组数据
index:相关的数据索引标签
Series的创建
-由列表或numpy数组创建。
-由字典创建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from pandas import Series
s = Series(data=[1,2,3,'four'])
s

0 1
1 2
2 3
3 four
dtype:object
import numpy as np
Series(data=np.random.randint(0,100,size=(3,1)))

0 3
1 43
2 82
dtype:int64
from pandas import Series

s = Series(data=[1,2,3,'four'],index=['a','b','c','d'])
s
a 1
b 2
c 3
d four
dtype:object

dic = {
'语文':100,
'数学':99,
'理综':250,
}
s = Series(data=dic)
s
语文 100
数学 99
理综 250
dtype:int64
s.[0]
100
s.语文
100
s[0:2]
语文 100
数学 99
dtype:int64
s.shape
s.size
s.index
s.values
s.dtype
s.head(n)
s.tail(n)
s.unique
s.isnull
s.notnull
Series的算术运算
直接 a = 数组1+数组2即可
index一致的元素会进行算数运算 否则算空

————————————————————————————————————————
那么接下来是DataFrame 他是一个表格型的数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pandas import DataFrame
df = DataFrame(data=[1,2,3],[4,5,6])
df

0 1 2
————————
0 1 2 3
1 4 5 6
df = DataFrame(data=np.random.randint(0,100,size=(6,4)))
df

dic = {
'name':['zhangsan','lisi','wanglaowu'],
'salary':[1000,2000,3000]
}
df = DataFrame(data=dic,index=['a','b','c'])
df

name salary
——————————————————————
a zhangsan 1000
b lisi 2000
c wanglaowu 3000

values、columns、index、shape
df.values
df.columns
df.index
df.shape
df.dtype

df的索引&切片

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
df = DataFrame(data=dic,index=['a','b','c'])
df

name salary
——————————————————————
a zhangsan 1000
b lisi 2000
c wanglaowu 3000
df['name']

name
—————————————
a zhangsan
b lisi
c wanglaowu
显示多列时加逗号与另一个引号
df.loc[a]
df.iloc[[a,b]]

name salary
——————————————————————
a zhangsan 1000
b lisi 2000
df.iloc[a,b]
切片
df[0:2]
df.iloc[:,0:2]