text two 4.7

数据处理 : 
    算子 map filter  groupby  apply 
数据切片


pandas :
    1.官网
        https://pandas.pydata.org/
    2.概述:
        pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool,
        【pandas就是一个数据分析的工具】
    3.编程模型【数据类型】
        1.Series
        2.DataFrame

1.Series
    1.Series is a one-dimensional labeled array 
    【Series 就是一个 一维 标签数组】
    
    2.capable of holding any data type 【integers, strings, floating point numbers, Python objects, etc.).】
        【存各种数据类型】
    3.The axis labels are collectively referred to as the index
        标签 就是索引  【可以用索引 取Series元素】

    实例化:

2.df 
    1.DataFrame is a 2-dimensional labeled data structure with columns of potentially different types
        【DataFrame 就是一个 二维 标签数组,多个不同数据类型的列】
        【 index (row labels) and columns 】

        【【DataFrame就是一个table  有行有列】
    2.如何创建df :
        Dict of 1D ndarrays, lists, dicts, or Series
        2-D numpy.ndarray
        Structured or record ndarray
        A Series
        Another DataFrame 
        【df 可以由多种数据 转化而来】
    
    3.a dict of Series objects
    

    df =》 table =》 有行有列 
    
    DataFrame = DataFrame【Series】

    实例化:

总结:
    1.df 就是table  
    2.Series 是一个table 就一个列 没有列名
    3.df = df [Series + 列名]


思考: 
    数据分析师 拿到一个数据一般做哪些事情? 【大数据工程师也是一样】
        1.数据加载 source 
        2.数据分析 transform 
        3.数据输出 sink

df 基本操作: 
    1.数据加载 

处理的数据文件格式:
    csv json text 
    结构化数据:
        csv: 按逗号进行分割 =》 excel打开的
        json: kv 
    text:
        普通文本数据

切片:
    取值

先练习一下上午讲的内容


filter : 


a=> b=> c 

select 

ifnull(name,0) as name_etl

from table 
where 
    name is null 
        is not null 


id name age  score  

select 
name,
sum(score) as score_all
from table 
group by 
name ;


机器学习:
    1.概念
    Simple and efficient tools for predictive data analysis
    【预测数据分析结果】

    用机器代替人做决策

    数据集 =》 训练 =》 模型 

    2.Built on NumPy, SciPy, and matplotlib、pandas


2.机器学习里面的常用术语 :

    1.数据集准备
        色泽= 绿色 、根=弯曲 、 敲声 = 浑浊  =》 熟的 
        色泽= 黑色 、根=弯曲 、 敲声 = 沉闷  =》 生的 
        色泽= 红色 、根=弯曲 、 敲声 = 清脆  =》 生的

    数据集:这组数据 的集合 
    样本:每一条数据
    维度:西瓜的判断条件
    标签(label):结果的判断就是标签

    2.模型怎么来的? 

        数据集 =》 训练 =》基于某个算法 =》 模型 【数学公式】

    机器学习的模型作用:
        输入三个维度 =》 判断出结果

人少:
    机器学习:  数据科学家 【基于数据 =》 分析 一些问题】
        1.数学 =》 算法 knn、kmeans 、线性回归、逻辑
        2.会写代码


3.机器学习的种类:
    1.有监督学习: 结果是 label的
        1.分类:
            通过模型 判断结果  生的还是熟的
        2.回归: 
            通过模型 判断结果 (熟了 0.9)
    2.无监督学习:结果是 没有label的
        1.聚类: =》 sql  group by 
    3.半监督学习: 
        使用标记数据+为标记数据 进行训练
    4.强化学习:
        阿法狗

4.如何判断模型好不好? 
    1.正确率、错误率
        正确率:(tp+tn) / (tp+tn+fp+fn)
        错误率率:(fp+fn) / (tp+tn+fp+fn)
    2.精确率、召回率
        P 精确率:(tp) /(tp+fp) 
        R 召回率:(tp) /(tp+fn)
    3.真正率、假正率:
        tpr= 
        fpr=
        roc 和auc 

Numpy pandas matplotlib
统计分析、假设、线下回归、逻辑回归、knn、朴素贝叶斯、aqi、时间序列、决策树、kmeans、分类模型评估

Numpy:
    1.官网
        https://numpy.org/
    1. what is numpy?
        The fundamental package for scientific computing with Python
    2.multidimensional array object 【编程模型】
        1.arrays and matrices [数组和矩阵]
        2.可以用来 数组操作、矩阵操作、线下代数、sort、random 

体验:
    求多元一次方程

        3x +y -2z = 5 
        x-y+4z = -2 
        2x +3z = 2.5 

        [0.5 4.5 0.5]
    # 把等式系数 抽象成 向量组


python list  vs  numpy arr  
python list
1.放不同数据类型的 元素 

numpy arr  : 
1.元素类型 必须统一

建议使用  numpy arr  比python list 效率高 【 numpy arr  底层代码使用 c 实现的】


1.如何创建 ndarray 
There are 6 general mechanisms for creating arrays:
    1Conversion from other Python structures (i.e. lists and tuples)
    2Intrinsic NumPy array creation functions (e.g. arange, ones, zeros, etc.)
    3Replicating, joining, or mutating existing arrays
    4Reading arrays from disk, either from standard or custom formats
    5Creating arrays from raw bytes through the use of strings or buffers
    6Use of special library functions (e.g., random)

NumPy arrays:
    1.ndarray  n N维数组对象
    2.【元素数据类型必须相同】

创建一维数组:
    1.数据类型转化
    2.内置函数

创建二维数组:
    1.数据类型转化
    2.内置函数

数组属性: 
    1.修改 sharp 
    2.转换数据类型: 
        1.nparr =》 python 
        2.nparr元素 int =》 float

数组切片: 
    切片:取值

一维数组: 

二维数组:


根据条件进行取值


ifnull(condition,xx,xxx)

5.数组的轴 (axis)
    1.numpy 轴 可以理解为方向 
    2.数组 0 1 2 表示
        eg :
            一维数组:只有一个 0 轴
            二维数组:0轴 1轴
            三维数组:0轴 1轴 2轴

    3.轴 用于计算:
        按照 0、1、2轴进行计算

np.xxx()  api 

np.sum
np.mean 

6.数组的计算

跟矩阵一样:
    1.数组与数的计算
    2.形状相同的数组计算
    3.不同形状的数组 计算? 
    4.行数 或 列数相同的 一维数组 与 多维数组 进行计算


7.数组中的空值 


数组的操作:

8.random 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值