#忽略警告
import warnings
warnings.filterwarnings(‘ignore’)
import pandas as pd
import numpy as np
import re
import os 查看文件路径
from datetime import datetime
读文件的
import json
聚类
from sklearn import cluster #聚类
import scipy.cluster.hierarchy as sch #绘制谱系图
#画图
import matplotlib.pyplot as plt
import seaborn as sns 热力图
import pyechar #地图,云
import wordcloud #云
from IPython.display import Image #保存树图
import pydotplus
xgboost 绘制图的包
分词文本分析
import jieba
import jieba.posseg as jp
from snownlp import SnowNLP
from gensim import corpora,models # LDA主题
from sklearn.feature_extraction.text import TfidfVectorizer,CountVectorizer #词编码
词向量和句向量
from sklearn.externals import joblib #模型加载保存
张老师
#模型评估
from sklearn.metrics
import
分类器评估
confusion_matrix #混淆矩阵
accuracy_score #准确率
precision_score #精准率
recall_score #召回
roc_curve #ROC(fpr,tpr,阈值)
roc_auc_score #auc
classification_report #评估报告
回归评估
mean_squared_error #均方误差
r2_score #R方
from statsmodels.stats.outliers_influence import variance_inflation_factor # VIF 方差膨胀因子
聚类评估
ch
si
回归模型
from sklearn.linear_model
import
Ridge,
RidgeCV
Lasso
LassoCV
SGDRegressor
LinearRegression
from statsmodels.formula.api import ols
特征选择
from sklearn.feature_selection
import
f_regression #相关系数
SelectFromModel
卡方
方差分析
集成算法
from sklearn.ensemble
import
RandomForestClassifier
AdaBoostClassifier
import xgboost as xgb
stacking的包
失衡数据
from imblearn.over_sampling import SMOTE #采样
from imblearn.under_sampling import ClusterCentroids #欠采样
#预处理
from sklearn.preprocessing
import
OneHotEncoder
StandardScaler
MinMaxScaler
LabelEncoder #标签编码
label_binarize
from patsy.highlevel import dmatrices # 哑元化
from sklearn.impute import SimpleImputer #补充缺失值
#模型调优
from sklearn.model_selection
import
train_test_split
GridSearchCV
推荐
from efficient_apriori import apriori #关联
协同过滤没包(计算距离矩阵的包)
分类器模型
from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import MultinomialNB
from sklearn.tree import DecisionTreeClassifier
svm 包