import datetime
import pandas as pd
import numpy as np
import os
import seaborn as sns
import re
import matplotlib.pyplot as pl
import warnings
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import MinMaxScaler
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import cross_val_score
from sklearn.metrics import accuracy_score, classification_report, fbeta_score, \
make_scorer, mean_absolute_error, roc_auc_score, precision_score
warnings.filterwarnings('always')
warnings.filterwarnings('ignore')
sns.set(style="darkgrid")
pl.rcParams['font.sans-serif']=['SimHei']# 用来正常显示中文标签
pl.rcParams['axes.unicode_minus']=False# 用来正常显示%matplotlib inline
deffeature_plot(importances, X_train, y_train):# Display the five most important features
indices = np.argsort(importances)[::-1]
columns = X_train.columns.values[indices[:5]]
values = importances[indices][:5]# Creat the plot
fig = pl.figure(figsize =(9,5))
pl.title("Normalized Weights for First Five Most Predictive Features", fontsize =16)
rects = pl.bar(np.arange(5), values, width =0.6, align="center", color ='#00A000', \
label ="Feature Weight")# make bar chart higher to fit the text label
axes = pl.gca()
axes.set_ylim([0, np.max(values)*1.1])# add text label on each bar
delta = np.max(values)*0.02for rect in rects:
height = rect.get_height()
pl.text(rect.get_x()+ rect.get_width()/2.,
height + delta,'%.2f'% height,
ha='center',
va='bottom')# Detect if xlabels are too long
rotation =0for i in columns:iflen(i)>20:
rotation =10# If one is longer than 20 than rotate 10 degrees break
pl.xticks(np.arange(5), columns, rotation = rotation)
pl.xlim((-0.5,4.5))
pl.ylabel("Weight", fontsize =12)
pl.xlabel("Feature", fontsize =
银行精准营销解决方案营销活动以电话为基础,一般,银行的客服人员需要联系客户至少一次。数据集中包含有客户年龄,职业婚姻,教育水平等信息,通过这些信息建模,预测客户是否将认购该银行的产品一.数据和库的导入import datetimeimport pandas as pdimport numpy as npimport osimport seaborn as snsimport re...