Data Analysis with Python
Module 2 Data Wrangling
处理缺失值
 
使用Python去除缺失值 
pandas包中的dataframes.dropna(),当inplace参数为True时,直接在原数据框内操作 
数据格式化
数据标准化
数据分组
数据转换(Categorical→Numeric)
 
Why One-Hot Encode Data in Machine Learning?中提到,将分类型数据转为数值型数据的两种方法: 
1. Integer-Encoding,针对有序分类变量 
2. One-Hot Encoding,针对无序分类变量
可使用pandas.get_dummies()进行转换。 
Module 3 Exploratory Data Analysis(EDA)
统计描述
- df.describe()
- value_counts() 
 
- Box Plots 
 seaborn.boxplot
 
- Scatter Plot 
 matplotlib.pyplot.scatter()
 
Groupby in Python
- df.groupby()
- pivot table(透视表) 
 df.pivot_table(),转化后便于阅读和查看,但不便于进行数据处理
 
- Heat Map 
 
方差分析(ANOVA)
相关分析(correlation)
Correlation doesn’t imply causation!
统计相关性
皮尔森相关分析
 
scipy.stats.pearsonr() 
 
两者相关性很强。
Module 4 Model Development
线性回归
一元线性回归 Simple Linear Regression(SLR)
举例:y^=b0+b1xy^=b0+b1x 
可以使用scikit-learn中的sklearn.linear_model.LinearRegression()进行训练和预测
多元线性回归 Multiple Linear Regression(MLR)
举例:Y^=b0+b1x1+b2x2+b3x3+b4x4Y^=b0+b1x1+b2x2+b3x3+b4x4 
 
模型评估可视化
- Regression Plot 
 seaborn.regplot()
 
- Residual Plot 
 
 seaborn.residplot()
 借助残差图可以观察数据分布情况,大致判断数据是否呈线性相关
 
- Distribution Plot 
 seaborn.displot()
 
多项式线性回归和管道操作
多项式线性回归 Polynomial Regression
 
 
 
管道操作 Pipeline
 
Measures for In-Sample Evaluation
- Mean Squared Errors(MSE) 
 MSE=1n∑i=1n(Yi−Y^i)2MSE=1n∑i=1n(Yi−Y^i)2
 sklearn.metrics.mean_squared_error()
 
 
 
Prediction and Decision Making
 
 
Multiple Linear Regression(MLR) 
Simple Linear Regression(SLR) 
Mean Squared Errors(MSE)
Module5 Model Evaluation
 
最后一条有疑问,不会造成过拟合吗??????????
拆分数据集为训练集和测试集: 
 
交叉验证示意图: 
3折交叉验证: 
 
查看预测结果: 
Over-fitting, Under-fitting and Model Slection
Rigid Regression
sklearn.linear_model.Ridge() 
岭回归中文文档,通过参数α调整模型,从而防止过拟合。 
Grid Search
网格搜索通过交叉验证的方法来自动调整超参数hyperparameters 
机器学习中的超参数 
Parameter和Hyperparameter的区别,原文。简单来说,参数是训练过程中通过数据自动调整的,而超参数一般都是手动选择,用于调整估计模型过程的。 
sklearn.model_selection.GridSearchCV() 
查看各组合的结果: 
视频内容只是简介,关键还是要用lab里的 jupyter notebook 练手。
参考资料: 
1. https://cognitiveclass.ai/ 
2. http://pandas.pydata.org/pandas-docs/stable/index.html 
3. http://scikit-learn.org/stable/index.html
 
                    
                     
                    
                 
                    
                

 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号