python实现基本的机器学习算法系列(2):logstic回归

本文是Python实现基本机器学习算法系列的第二篇,重点讲解逻辑回归的原理、实现过程以及如何在Python中使用它进行预测分析。通过实例展示了如何加载数据、预处理、训练模型并评估性能。
摘要由CSDN通过智能技术生成
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import numpy as np


X, y_ = make_blobs(n_samples=10000, n_features=2, centers=2)#, random_state=123)
# plt.figure(figsize=(8,6))
# plt.scatter(X[:,0],X[:,1], c=y_)
# plt.pause(0.5)
# plt.close()

y = y_[:, np.newaxis]   # 维度从(10000,)变为(10000, 1)
x_train, x_test, y_train, y_test = train_test_split(X,y)

x_train = np.c_[x_train, np.ones(x_train.shape[0])]
x_test = np.c_[x_test, np.ones(x_test.shape[0])]


class Logstic_GD:
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值