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:
python实现基本的机器学习算法系列(2):logstic回归
最新推荐文章于 2024-03-28 00:45:34 发布
本文是Python实现基本机器学习算法系列的第二篇,重点讲解逻辑回归的原理、实现过程以及如何在Python中使用它进行预测分析。通过实例展示了如何加载数据、预处理、训练模型并评估性能。
摘要由CSDN通过智能技术生成