逻辑回归分类Sklearn的make_moon数据集

本文通过代码展示了如何利用Sklearn库中的make_moon函数生成非线性可分数据,并应用逻辑回归进行分类。通过实例详细讲解了数据生成到模型训练的全过程。
摘要由CSDN通过智能技术生成

直接上代码

from sklearn.datasets import make_moons
from numpy import *
import numpy as np
import operator
from os import listdir
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
#创建数据集
x, y = make_moons(n_samples=200, noise=0.15, random_state=0)
# Max-Min标准化
# 建立MinMaxScaler对象
# minmax = preprocessing.MinMaxScaler()
# # 标准化处理
# data_minmax = minmax.fit_transform(x)
# MaxAbs标准化
# # 建立MinMaxScaler对象
minmax= preprocessing.MaxAbsScaler()
# 标准化处理
data_minmax  = minmax.fit_transform(x)

m, n = shape(data_minmax)
w = ones((1,1))

data_minmax = np.insert(data_minmax, 0, values=w, axis=1)

# print(data_maxabs)
x_train, x_test, y_train, y_test = train_test_split(
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值