1、源码
'''
一个例子
各种采样算法下,不均衡数据的分布情况
time: 2019-8-18
author: Bing
reference: https://blog.csdn.net/qq_30636613/article/details/86422589
'''
import numpy as np
from collections import Counter
from sklearn.datasets import make_classification
import matplotlib.pyplot as plt
from imblearn.over_sampling import RandomOverSampler as ROS
from imblearn.over_sampling import SMOTE
from imblearn.over_sampling import ADASYN
from sklearn.metrics import accuracy_score
from sklearn.svm import LinearSVC as svc
#绘制决策边界函数
def plot_decision_function(X, y, clf, ax,acc):
plot_step = 0.02
x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, plot_step),
np.arange(y_min, y_max, plot_step))
Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.sha