ML-LSSVM基于FOA的SVM分类器
发布时间
阅读量:
阅读量
导入时间模块。
导入numpy库。
导入matplotlib.pyplot模块。
从sklearn引入数据集模块。
从sklearn引入预处理模块。
从sklearn引入训练测试拆分模块。
从sklearn引入特征选择模型模块。
引入线性支持向量分类器模块和支持向量分类器模块。
引入分类报告、精确率分数以及混淆矩阵相关功能。
该数据集被成功加载。
这些特征和对应的标签从前100个样本中提取。
σ被设定为常数2。
γ被设定为常数1。
x = preprocessing.StandardScaler().fit_transform(X)
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.3,random_state=1)
def featureSelction(x,y):
clf = LinearSVC(penalty='l1',C=1.0,dual=False)
clf.fit(x,y)
model = SelectFromModel(clf,prefit=True)
tmp = model.transform(x)
common = []
for index in range(x.shape[1]):
if x[0,index] in list
全部评论 (0)
还没有任何评论哟~
