admin 管理员组

文章数量: 887019


2024年1月18日发(作者:仓颉语言华为)

###SVM输出# -*- coding: utf-8 -*-"""Created on Sat May 26 15:07:33 2018@author: hu"""from _model import LogisticRegressionfrom ts import load_iris

import numpy as np

from sklearn import datasets#数据加载iris = _iris()#花瓣长度和宽度,2,3、两个特征值X = [:,[2,3]]#类标赋值y = #数据分区导包from _validation import train_test_split#划分数据训练集和测试集,测试集30%X_train , X_test , y_train, y_test = train_test_split(X,y,test_size = 0.3, random_state=0)

#数据缩放,标准化from cessing import StandardScaler

sc=StandardScaler()(X_train)#计算特征样本均值和标准差X_train_std = orm(X_train)#对其样本均值和标准差做标准化处理X_test_std = orm(X_test)#对其样本均值和标准差做标准化处理

#数据加载iris = _iris()#花瓣长度和宽度,2,3、两个特征值X = [:,[2,3]]#类标赋值y = #数据分区导包from _validation import train_test_split#划分数据训练集和测试集,测试集30%X_train , X_test , y_train, y_test = train_test_split(X,y,test_size = 0.3, random_state=0)

#数据缩放,标准化from cessing import StandardScaler

sc=StandardScaler()(X_train)#计算特征样本均值和标准差X_train_std = orm(X_train)#对其样本均值和标准差做标准化处理X_test_std = orm(X_test)#对其样本均值和标准差做标准化处理from import ListedColormapimport as plt

#可视化函数def plot_decision_regions(X,y,classifier,test_idx=None ,resolution = 0.02):

#set marker generator and color map

markers = ('s','x','o','^','v') colors = ('red','blue','lightgreen','gray','cyan') cmap = ListedColormap(colors[len((y))])

#plot the decision suiface x1_min,x1_max = X[:,0].min()-1, X[:,0].max()+1 x2_min,x2_max = X[:,0].min()-1, X[:,0].max()+1

xx1,xx2 = id((x1_min,x1_max,resolution), (x2_min,x2_max,resolution))

Z= t(([(),()]).T)

Z = e() rf(xx1,xx2,Z,alpha=0.4,cmap=cmap) ((),()) ((),())

####逻辑回归输出

# -*- coding: utf-8 -*-"""Created on Fri May 25 10:35:50 2018@author: hu"""from _model import LogisticRegressionfrom ts import load_iris

import numpy as np

from sklearn import datasets#数据加载iris = _iris()#花瓣长度和宽度,2,3、两个特征值X = [:,[2,3]]#类标赋值y = #数据分区导包from _validation import train_test_split#划分数据训练集和测试集,测试集30%X_train , X_test , y_train, y_test = train_test_split(X,y,test_size = 0.3, random_state=0)

#数据缩放,标准化from cessing import StandardScaler

sc=StandardScaler()(X_train)#计算特征样本均值和标准差X_train_std = orm(X_train)#对其样本均值和标准差做标准化处理X_test_std = orm(X_test)#对其样本均值和标准差做标准化处理

#定义逻辑回归模型

lr = LogisticRegression(C=1000.0,random_state=0)#在强正则化参数C<0.1时罚项使得所有权重都趋向0


本文标签: 数据 标准差 标准化 样本均值 逻辑