机器学习-逻辑回归

预测乳腺癌案例

import numpy as np
import pandas as pd
# 机器学习
import sklearn
# 逻辑回归
from sklearn.linear_model import LogisticRegression
# 切割训练集和测试集
from sklearn.model_selection import train_test_split
# 画图工具
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['simHei']
mpl.rcParams['axes.unicode_minus'] = Falsenames = ['id','Clump Thickness', # 肿块厚度'Uniformity of Cell Size',# 电池尺寸均匀性'Uniformity of Cell Shape',# 细胞形状均匀性'Marginal Adhesion',# 边缘粘连'Single Epithelial Cell Size',# 单个上皮细胞大小'Bare Nuclei',# 裸核'Bland Chromatin',# 乏味染色体'Normal Nucleoli',# 正常核'Mitoses',# 游戏分裂'Class']
# 读取数据
data = pd.read_csv('./data/乳腺癌分类/breast-cancer-wisconsin.data', names=names)# value_counts()可以查看 有多少个不同的数字以及重复的数字有多少个
# 通过这个方法可以确定有多少列别,从而确定是几分类  data['Class'].value_counts()# data.info()可以查看所有列的数据类型,当有一个数据类型是object时,说明这里面有空缺值
# print(data.info())# 缺失值的替换,第一种:填0(不建议填0)
# data = data.replace('?', 0)
# 第二种 把包含?的一行数据删除掉
data = data.replace('?', np.nan).dropna(how='any')# 获得X,iloc通过索引操作数据,先行再列  id那一列与得病无关所以将id这一列不归为数据集中
X = data.iloc[:, 1:10]
# 获得Y
Y = data.iloc[:, -1:]
# 分割训练集和测试集
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=0)
# 创建逻辑回归
lr = LogisticRegression()
# 给予 训练集和测试
result = lr.fit(X_train, Y_train)# 查看准确率
print("训练集合上的准确率", result.score(X_train, Y_train))
print("测试集合上的准确率", result.score(X_test, Y_test))# 查看预测值
y_hat = lr.predict(X_test)
# 查看真实值 将DataFrame转换为Ndarray并拉平
Y_ = Y_test.values.reshape(-1)
# 对比预测值和真实值的差别
print(y_hat == Y_)
# [ True  True  True  True  True  True  True  True  True  True  True  True
#   True  True  True  True  True  True  True  True  True  True False  True
#   True  True  True  True]
Y_arr = (y_hat == Y_)
# 声明一个ndarray
Y_arr = np.array(Y_arr, dtype=int)
print(Y_arr) # False:0  True:1
# [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1]
# 求Y_arr得均值
print(np.mean(Y_arr))# 0.9642857142857143# 画图
x_len = range(len(X_test))
# 创建画布
plt.figure()
# 给Y轴限制
plt.ylim(0, 6)
# plot 表示画折线图 加上ro变成散点图
# 真实数据
plt.plot(x_len, Y_test, 'ro', markersize=8, label='真实值', zorder=3)
# 预测数据
plt.plot(x_len, lr.predict(X_test), 'go', markersize=14, label='预测值', zorder=2)# 显示label
# plt.legend(loc='upper left')
# plt.show()# 绘制ROC曲线
from sklearn import metrics
from sklearn.preprocessing import label_binarize
# label_binarize将Y的2-4变为0-1
y_t = label_binarize(Y_test, classes=(2, 4))
print(y_t.reshape(-1))# [0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 0]
Y_score = lr.decision_function(X_test)
# 计算真正例率和假正例率 y_true:真实值 y_score:y的评估分数
fpr, tpr, th = metrics.roc_curve(y_t.reshape(-1), Y_score)
# 计算曲线的面积
auc = metrics.auc(fpr, tpr)# 创建画布
plt.figure()
# c:color lw:画笔宽度
plt.plot(fpr, tpr, c='r', lw=2)
# 设置横坐标和纵坐标
plt.xlim(-0.01, 1.01)
plt.ylim(-0.01, 1.01)
# 横纵坐标的间隔 从0到1.1 每次间隔0.1
plt.xticks(np.arange(0, 1.1, 0.1))
plt.yticks(np.arange(0, 1.1, 0.1))
# 画一条直线 (0,0) (1,1) ls:线的样式
plt.plot((0, 1), (0, 1), c='#a0a0a0', ls='--')
# 加入坐标的声明
plt.xlabel('假正例率', fontsize=16)
plt.ylabel('真正例率', fontsize=16)
# 画格子
plt.grid(b=True, ls=':')plt.show()

泰坦尼克号案例

创建泰坦尼克号GUI.py

import tkinter as tk# 1 活
# 0 死
# pclass 1是最好的
import tkinter as tk
from Titanic import Titanicdef on_start_button_click():sex_input = sex_entry.get()age_input = float(age_entry.get())bro_input = float(bro_entry.get())parents_input = float(parents_entry.get())fare_input = float(fare_entry.get())p_class_input = float(p_class_entry.get())result_str = t.predict(sex_input, age_input, bro_input, parents_input, fare_input, p_class_input)# 在文本框中插入strresult_textarea.delete('1.0', 'end')result_textarea.insert('insert', result_str)pass# 创建窗口
root = tk.Tk()
t =Titanic()
# 窗口标题
root.title('泰坦尼克号预测')
# 设置窗口大小 widthxheight+x+y
# x代表乘法  距离屏幕左上角+x+y的位置
# root.geometry('300x600+500+100')# 标签Label显示 padx 左右编剧  pady上下边距
tk.Label(root, padx=20, pady=10, text='输入下面各个数值,来预测你在泰坦尼克号事故中是否存活下来').grid(row=0, columnspan=2)
tk.Label(root, text='性别(男/女)').grid(row=1, sticky=tk.E)#靠右
tk.Label(root, text='年龄').grid(row=2, sticky=tk.E)
tk.Label(root, text='船上的兄弟姐妹(0)').grid(row=3, sticky=tk.E)
tk.Label(root, text='父母亲(0)').grid(row=4, sticky=tk.E)
tk.Label(root, text='恐惧程度(0-1)').grid(row=5, sticky=tk.E)
tk.Label(root, text='仓位(1-3)').grid(row=6, sticky=tk.E)
tk.Label(root, text='Create By AzurLane').grid(row=7, sticky=tk.W)#靠左# 输出框控件
sex_entry = tk.Entry(root)
sex_entry.grid(row=1, column=1, padx=10, pady=10)
age_entry = tk.Entry(root)
age_entry.grid(row=2, column=1, padx=10, pady=10)
bro_entry = tk.Entry(root)
bro_entry.grid(row=3, column=1, padx=10, pady=10)
parents_entry = tk.Entry(root)
parents_entry.grid(row=4, column=1, padx=10, pady=10)
fare_entry = tk.Entry(root)# 恐惧
fare_entry.grid(row=5, column=1, padx=10, pady=10)
p_class_entry = tk.Entry(root)# 仓位
p_class_entry .grid(row=6, column=1, padx=10, pady=10)# 添加图片 rowspan列合并
photo = tk.PhotoImage(file='./data/siki.png')
tk.Label(image=photo).grid(row=1, column=2, rowspan=3, padx=20)
# 输入框
result_textarea = tk.Text(root, height=6, width=30)
result_textarea.grid(row=4, column=2, rowspan=2)
# 按钮控件
tk.Button(root, text='开始预测你的生死', command=on_start_button_click).grid(row=6, column=2, rowspan=2, ipadx=50)
# 显示
root.mainloop()

Titanic.py

# 处理数组
import numpy as np
import pandas as pd
# 机器学习
import sklearn
# 画图
import matplotlib.pyplot as plt
# 逻辑回归
from sklearn.linear_model import LogisticRegression# 切割数据分为训练集和测试集
def split_data(data, train_size=0.8, random_state=0):# sample:随机抽样# n:抽取的行数 frac:抽取行比例 replace:是否放回抽取 weight:概率数组 random_state:随机种子 axis:抽取的是行还是liedata_upset = data.sample(frac=1, random_state=random_state)# 把原来的数据给打乱# 分割x与yx = data_upset.iloc[:, 1:]# 第一个参数:选择所有行  第二个参数:从第2行开始选择y = data_upset.iloc[:, :1]# 第一个参数:选择所有列  第二个参数:只选择第一列# 训练集合大小num_train = int(len(data_upset) * train_size)# 切割训练集合x_train = x.iloc[:num_train, :]y_train = y.iloc[:num_train, :]# 切割测试集合x_test = x.iloc[num_train:, :]y_test = y.iloc[num_train:, :]return x_train, y_train, x_test, y_testclass Titanic:# 构造方法def __init__(self):data = pd.read_csv('./data/titanic.csv')# 在这些数据中name属性与最终结果并无多大关系,把name这一列去掉# sex这一列数值是names = ['Survived', 'Pclass', 'Sex', 'Age', 'Siblings/Spouses Aboard', 'Parents/Children Aboard', 'Fare']data = data[names]# fixme 对于sex这一列未使用哑编码时的操作# female:1  male:0# 如果是male返回0  不是返回1# data['Sex'] = np.where(data['Sex'] == 'male', 0, 1)# print(data.info())# todo 对sex做哑编码操作sex_one_hot = pd.get_dummies(data['Sex'], prefix='Sex')# todo 对p_class做哑编码操作pclass_one_hot = pd.get_dummies(data['Pclass'], prefix='Pclass')# 去除sex和Pclassnames = ['Survived', 'Age', 'Siblings/Spouses Aboard', 'Parents/Children Aboard', 'Fare']data = data[names]# 拼接DataFramedata = pd.concat([data, sex_one_hot, pclass_one_hot], axis=1)# todo 对连续型变量做无量纲化data['Fare'] = data['Fare'] = data['Fare'].apply(lambda x: (x - data['Fare'].min()) / (data['Fare'].max() - data['Fare'].min()))# print(data.info())# # 查看前五条数据# print(data.head(5))# 调用切割数据的函数x_train, y_train, x_test, y_test = split_data(data)# 逻辑回归# solver有以下的优化函数  ['liblinear','newton-cg','lbfgs','sag','saga']# liblinear:坐标轴下降法 lbfgs:拟牛顿法 newton-cg:牛顿法变种 seg:minibateself.lr = LogisticRegression(solver='lbfgs', max_iter=1000000)self.result = self.lr.fit(x_train, y_train)# 训练集上的准确率print('训练集上准确率', self.result.score(x_train, y_train))# 测试集上的准确率print('测试集上准确率', self.result.score(x_test, y_test))pass# 预测方法def predict(self, sex_input, age_input, bro_input, parents_input, fare_input, p_class_input):print(self.lr.coef_)print('预测')# print(self.lr.predict([[18, 0, 0, 0.2, 0, 1, 0, 0, 1]]))# 性别 年龄 兄妹 父母 恐惧程度 仓位x = [age_input, bro_input, parents_input, fare_input]# 已经对了sex_input和p_class_input进行哑编码操作,所以哑编码操作后生成的列就在fare_input后依次排列# 注意插入的顺序 要一一对应上if sex_input == '男':# extend是直接在后面追加0,1x.extend([0, 1])if p_class_input == 1:x.extend([1, 0, 0])elif p_class_input == 2:x.extend([0, 1, 1])elif p_class_input == 3:x.extend([0, 0, 1])else:print("仓位输入有误")return '仓位输入有误,请输入1到3任意数字,1为头等仓,3为经济舱'elif sex_input == '女':x.extend([1, 0])if p_class_input == 1:x.extend([1, 0, 0])elif p_class_input == 2:x.extend([0, 1, 1])elif p_class_input == 3:x.extend([0, 0, 1])else:print("仓位输入有误")return '仓位输入有误,请输入1到3任意数字,1为头等仓,3为经济舱'else:print("性别输入有误")return '性别输入有误,请输入男或女'result = self.lr.predict([x])if result == 0:result = '死'else:result = '活'return '在这次泰坦尼克号中,你'+result+'了'pass

葡萄酒分类

葡萄酒分类GUI.py

import tkinter as tk
from Winequality import  Winequalitydef on_start_button_click():fixed_acidity_input = float(fixed_acidity.get())volatile_acidity_input = float(volatile_acidity.get())citric_acid_input = float(citric_acid.get())residual_sugar_input = float(residual_sugar.get())chlorides_input = float(chlorides.get())free_sulfur_dioxide_input = float(free_sulfur_dioxide.get())total_sulfur_dioxide_input= float(total_sulfur_dioxide.get())density_input = float(density.get())pH_input = float(pH.get())sulphates_input = float(sulphates.get())alcohol_input = float(alcohol.get())# 显示结果result = w.perdict(fixed_acidity_input, volatile_acidity_input, citric_acid_input, residual_sugar_input, chlorides_input, free_sulfur_dioxide_input, total_sulfur_dioxide_input, density_input, pH_input, sulphates_input, alcohol_input)result_textarea.delete('1.0', 'end')result_textarea.insert('insert', "分类的结果为:" + str(result))passw = Winequality()
# 创建窗口
root = tk.Tk()root.title('葡萄酒分类质量')
# "";"";"";"";"";"";"";"";"";"";"";"quality"
tk.Label(root, padx=20, pady=10, text='输入下面各个数值').grid(row=0, columnspan=2)
# fixed acidity
tk.Label(root, text='非挥发性酸').grid(row=1, sticky=tk.E)
fixed_acidity = tk.Entry(root)
fixed_acidity.grid(row=1, column=1, padx=10, pady=10)# volatile acidity
tk.Label(root, text='挥发性酸').grid(row=2, sticky=tk.E)
volatile_acidity = tk.Entry(root)
volatile_acidity.grid(row=2, column=1, padx=10, pady=10)# citric acid
tk.Label(root, text='柠檬酸').grid(row=3, sticky=tk.E)
citric_acid = tk.Entry(root)
citric_acid.grid(row=3, column=1, padx=10, pady=10)# residual sugar
tk.Label(root, text='残糖').grid(row=4, sticky=tk.E)
residual_sugar = tk.Entry(root)
residual_sugar.grid(row=4, column=1, padx=10, pady=10)# chlorides
tk.Label(root, text='氯化物').grid(row=5, sticky=tk.E)
chlorides = tk.Entry(root)
chlorides.grid(row=5, column=1, padx=10, pady=10)# free sulfur dioxide
tk.Label(root, text='无氯二氧化硫').grid(row=6, sticky=tk.E)
free_sulfur_dioxide = tk.Entry(root)
free_sulfur_dioxide.grid(row=6, column=1, padx=10, pady=10)# total sulfur dioxide
tk.Label(root, text='二氧化硫总量').grid(row=7, sticky=tk.E)
total_sulfur_dioxide = tk.Entry(root)
total_sulfur_dioxide.grid(row=7, column=1, padx=10, pady=10)# density
tk.Label(root, text='密度').grid(row=8, sticky=tk.E)
density = tk.Entry(root)
density.grid(row=8, column=1, padx=10, pady=10)# pH
tk.Label(root, text='酸碱度').grid(row=9, sticky=tk.E)
pH = tk.Entry(root)
pH.grid(row=9, column=1, padx=10, pady=10)# sulphates
tk.Label(root, text='硫酸盐').grid(row=10, sticky=tk.E)
sulphates = tk.Entry(root)
sulphates.grid(row=10, column=1, padx=10, pady=10)# alcohol
tk.Label(root, text='酒精').grid(row=11, sticky=tk.E)
alcohol = tk.Entry(root)
alcohol.grid(row=11, column=1, padx=10, pady=10)
tk.Label(root, text='Create By AzurLane').grid(row=12, sticky=tk.W)#靠左# 显示图片
photo = tk.PhotoImage(file='./data/siki.png')
tk.Label(root, image=photo).grid(row=1, column=2, rowspan=2, padx=10, pady=5)
# 设置提示框
result_textarea = tk.Text(root, height=7, width=40)
result_textarea.grid(row=3, column=2, rowspan=2, padx=10, pady=0)
# 设置button
tk.Button(root, text='开始预测', command=on_start_button_click).grid(row=11, rowspan=2, column=2, ipadx=120)
# 显示
root.mainloop()

Winequality.py

# 处理数组
import numpy as np
import pandas as pd
# 机器学习
import sklearn
# 画图
import matplotlib as mpl
import matplotlib.pyplot as plt
# 逻辑回归
from sklearn.linear_model import LogisticRegression
# fixme 防止出现中文乱码
mpl.rcParams['font.sans-serif'] = ['simHei']
mpl.rcParams['axes.unicode_minus'] = False
from sklearn.preprocessing import label_binarize
from sklearn import metricsclass Winequality:# 初始方法 构建逻辑回归def __init__(self):# csv文件默认为逗号来分割,如果是;来分割的话需要设置sep属性red_data = pd.read_csv('./data/winequality-red.csv', sep=';')white_data = pd.read_csv('./data/winequality-white.csv', sep=';')# 合并两个DataFrame  用concat函数  axis为0代表在下面拼接data = pd.concat([red_data, white_data], axis=0)# fixme 需要查看数据是否有空缺值或者类型不符合 info不能查看空缺值只能查看数据是否有str。object当心可能会出现str# 打开csv文件 用ctrl+F 比如搜索两个,,(这个csv文件以逗号分割)# print(data.info())# 7分类问题  value_counts()可以查看总共多少个分类# 6:2836    5:2138    7:1079  4:216   8:193  3:30  9:5print(data['quality'].value_counts())# 删除带有NaNdata = data.dropna(how='any')# print(data.head(5))# 拿到训练集和测试集x_train, y_train, x_test, y_test = self.split_data(data)# 画图样本的个数self.test_num = len(x_test)self.test_y = y_testself.test_x = x_test# solver可以设置更换特征工程self.lr = LogisticRegression(max_iter=10000, solver='sag')self.lr.fit(x_train, y_train)print('训练集准确率', self.lr.score(x_train, y_train))print('测试集', self.lr.score(x_test, y_test))# 第一次是 0.545 0.536 明显是欠拟合 需要采取措施提高准确率# 更换特征方程为小梯度下降sag后 是0.534 0.528 说明这个模型本身而导致准确率过低# 6:2836    5:2138    7:1079  4:216   8:193  3:30  9:5  这是quality的七个分类# 我们在上面七个分类中可以明显看出第七个类别数量只有5个,数据量根本不够,这个可能导致本模型准确率偏低# todo 总结:训练的时候要求每个类的数据是均衡的数据,这样得出的准确率不会太过于低# todo 如果数据不均匀就用到特征工程了pass# 切割数据def split_data(self, data, train_size=0.8, random_state=0):# 先打乱数据 随机抽样data_upset = data.sample(frac=1, random_state=random_state)# 分割x与y# 列只要除了最后一列外的全部列x = data_upset.iloc[:, :-1]# 列只要最后一列y = data_upset.iloc[:, -1:]# 训练集合大小num_train = int(len(data_upset) * train_size)# 切割训练集合x_train = x.iloc[:num_train, :]y_train = y.iloc[:num_train, :]# 切割测试集合x_test = x.iloc[num_train:, :]y_test = y.iloc[num_train:, :]return x_train, y_train, x_test, y_testdef perdict(self, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol):result = self.lr.predict([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides, free_sulfur_dioxide, total_sulfur_dioxide, density, pH, sulphates, alcohol]])return str(result[0])# 可视化def visualization(self):# 样本的个数x_len = range(self.test_num)plt.figure()# 真实值plt.plot(x_len, self.test_y, 'ro', markersize=8, zorder=3)# 预测值plt.plot(x_len, self.lr.predict(self.test_x), 'go', markersize=14, zorder=2)plt.show()pass# ROC曲线def roc(self):y_ = label_binarize(self.test_y, classes=(3, 4, 5, 6, 7, 8, 9))y_score = self.lr.decision_function(self.test_x)fpr, tpr, th = metrics.roc_curve(y_.reshape(-1), y_score.reshape(-1))# 面积auc = metrics.auc(fpr, tpr)print('auc面积', auc)plt.figure()# roc曲线plt.plot(fpr, tpr, c='r', lw=1)plt.show()pass# t = Winequality()
# t.roc()

花分类案例

import numpy as np
import pandas as pdfrom sklearn.linear_model import LogisticRegression
import matplotlib as mpl
mpl.rcParams['font.sans-serif'] = ['simHei']
mpl.rcParams['axes.unicode_minus'] = False
import matplotlib.pyplot as pltfrom sklearn import metrics
from sklearn.preprocessing import label_binarize# KNN
from sklearn.neighbors import KNeighborsClassifier# 改变y值
def change_data(x):if x == 'Iris-setosa':return 0elif x == 'Iris-versicolor':return 1elif x == 'Iris-virginica':return 2else:return -1pass# 切割训练集和测试集
def split_data(data, train_size=0.8, random_state=2):data_upset = data.sample(frac=1, random_state=random_state, replace=False)# x_train y_train x_test y_test# 选择x y# 行都要 列选择除了最后一个外的x = data_upset.iloc[:, :-1]# 行都要 列只要最后一个y = data_upset.iloc[:, -1:]num = int(len(data_upset) * train_size)# 训练集x_train = x.iloc[:num, :]y_train = y.iloc[:num, :]# 测试集x_test = x.iloc[num:, :]y_test = y.iloc[num:, :]return x_train, x_test, y_train, y_test# 添加列索引
names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'cla']
data = pd.read_csv('./data/鸢尾花数据分类/iris.data', names=names)
# 把类别变为0 1 2
data['cla'] = data['cla'].apply(change_data)# 切割数据集
x_train, x_test, y_train, y_test = split_data(data, 0.7)# 创建逻辑回归
lr = LogisticRegression()# todo KNN
knn = KNeighborsClassifier(n_neighbors=3)# 给逻辑回归参数
result = lr.fit(x_train, y_train)
result_knn = knn.fit(x_train, y_train)# 准确率
print(result.score(x_train, y_train))
print('逻辑回归', result.score(x_test, y_test))
print('knn', result_knn.score(x_train, y_train))
print(result_knn.score(x_test, y_test))# todo 数据格式化
# 创建画布
plt.figure()
x_len = range(len(x_test))
# 真实值
plt.plot(x_len, y_test, 'ro', markersize=8, zorder=3, label='真实值')
# 预测值
plt.plot(x_len, lr.predict(x_test), 'go', markersize=14, zorder=2, label='预测值')
plt.ylim(-1, 3)
# 显示label
plt.legend(loc='upper left')
plt.show()# todo ROC曲线  三分类要把两个都拉直才行
y_ = label_binarize(y_test, classes=(0, 1, 2))
# 逻辑回归的损失
y_score = lr.decision_function(x_test)
# knn的损失
y_score_knn = knn.predict_proba(x_test)fpr, tpr, th = metrics.roc_curve(y_.reshape(-1), y_score.reshape(-1))
fpr_knn, tpr_knn, th_knn = metrics.roc_curve(y_.reshape(-1), y_score_knn.reshape(-1))
# 计算面积
auc = metrics.auc(fpr, tpr)
print('面积{}'.format(auc))
auc_knn = metrics.auc(fpr, tpr)
print('knn面积{}'.format(auc_knn))# 创建画布
plt.figure()
# lw:画笔宽度
plt.plot(fpr, tpr, c='r', lw=2)
plt.plot(fpr_knn, tpr_knn, c='b', lw=1)
# 绘制横坐标与纵坐标
plt.xlim(-0.01, 1.01)
plt.ylim(-0.01, 1.01)
# 坐标的间隔
plt.yticks(np.arange(0, 1.1, 0.1))
plt.xticks(np.arange(0, 1.1, 0.1))
# 绘制 y = x的图
plt.plot((0, 1), (0, 1), c='#a0a0a0', ls='--')
# 绘制格子
plt.grid(ls=':')plt.show()

总结

逻辑回归

逻辑回归的过程

处理逻辑回归

项目处理过程的API

读取数据集|查看数据集|数据的预处理

切割训练集和测试集|创建和训练模型|模型预测

模型评估与可视化

python——GUI界面

机器学习-了解逻辑回归的逻辑过程相关推荐

  1. 二元逻辑回归 · 数学推导过程及代码实现完全解析

    文章目录 概述 两个重要函数 预测的基本思想 二元逻辑回归 线性模型的简单回顾 从线性回归到二元逻辑回归 参数怎么估计 梯度下降 牛顿迭代 最近修改:2021/6/17 原文<从二元逻辑回归到多 ...

  2. 简单粗暴理解与实现机器学习之逻辑回归:逻辑回归介绍、应用场景、原理、损失以及优化...

    作者 | 汪雯琦 责编 | Carol 来源 | CSDN 博客 出品 | AI科技大本营(ID:rgznai100) 学习目标 知道逻辑回归的损失函数 知道逻辑回归的优化方法 知道sigmoid函数 ...

  3. 逻辑回归三部曲——逻辑回归项目实战(信贷数据+Python代码实现)

         逻辑回归已经在各大银行和公司都实际运用于业务,已经有很多前辈写过逻辑回归.本文将从我实际应用的角度阐述逻辑回归的由来,致力于让逻辑回归变得清晰.易懂.逻辑回归又叫对数几率回归,是一种广义线性 ...

  4. 逻辑回归三部曲——逻辑回归(logistics regression)原理-让你彻底读懂逻辑回归

         逻辑回归已经在各大银行和公司都实际运用于业务,已经有很多前辈写过逻辑回归.本文将从我实际应用的角度阐述逻辑回归原理,致力于让逻辑回归变得清晰.易懂.逻辑回归又叫对数几率回归,是一种广义的线性 ...

  5. 逻辑回归、逻辑回归的损失和优化

    日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) 3.1 逻辑回归介绍 逻辑回归(Logistic Regres ...

  6. matlab 逻辑回归实现,逻辑回归原理介绍及Matlab实现

    一.逻辑回归基本概念 1. 什么是逻辑回归 逻辑回归就是这样的一个过程:面对一个回归或者分类问题,建立代价函数,然后通过优化方法迭代求解出最优的模型参数,然后测试验证我们这个求解的模型的好坏. Log ...

  7. 个人总结:从 线性回归 到 逻辑回归 为什么逻辑回归又叫对数几率回归?

    逻辑回归不是回归算法,是分类算法,可以处理二元分类以及多元分类. 线性回归 线性回归的模型是求出特征向量Y和输入样本矩阵X之间的线性关系系数θ,满足Y = Xθ.此时Y是连续的,所以是回归模型. 对应 ...

  8. 吴恩达机器学习之逻辑回归:逻辑回归的假说表示、判定边界、代价函数、简化的成本函数和梯度下降、高级悠哈、多类别分类之一对多(详细笔记,建议收藏,已有专栏)

    吴恩达机器学习栏目清单 专栏直达:https://blog.csdn.net/qq_35456045/category_9762715.html 文章目录 6.逻辑回归(Logistic Regres ...

  9. 机器学习-对数几率回归(逻辑回归)算法

    文章目录 简介 激活函数 损失函数 优化算法 代码 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到网站. 简介 对数几率回归(Logistic Regre ...

最新文章

  1. 创建用于存放备份还原文件的网络文件夹(DPM配置管理系列七)
  2. notepad++节点_在C ++中删除链接列表的中间节点
  3. insert mysql后加where,如何在MySQL Insert語句中添加where子句?
  4. python画折线图代码实现_python如何绘制分布折线图 python绘制分布折线图代码示例...
  5. Nginx 反向代理可以缓存 HTTP POST 请求页面吗?
  6. 杭州恒生数米基金网招聘1-3年本科.NET软件工程师
  7. Redis主从复制知识点
  8. Redis(二)Redis客户端的使用
  9. react 多行或单行文本溢出省略显示省略号(...)
  10. 修改thinkpad 小红点(TrackPoint速度)
  11. php杨辉三角的规律,杨辉三角的规律以及定理
  12. vb.net 教程 5-19 拓展:制作一个QQ大家来找茬和美女找茬辅助工具
  13. hdu 4565(推公式、矩阵快速幂)
  14. 【资源共享】Office软件合集
  15. Photoshop软件介绍
  16. win7系统计算机虚拟内存不足,Win7系统虚拟内存不足的应对办法
  17. Java 复制PPT幻灯片
  18. 小白都能学会的python+opencv,带你从人脸识别做到车牌识别,成为别人口中赞叹的高手!
  19. 全国计算机优秀教师奖励大会,55位国内高校计算机专业优秀教师将获得公益性奖励...
  20. APP退守、小程序进击,谁在主导内容创业下半场?

热门文章

  1. TP5后端,VUE前端请求聚合数据新闻接口
  2. 美团“互联网下半场”的筹码:豪赌B端业务
  3. 对HackTheBox里面的Netmon进行攻破
  4. R语言中的多项式回归、局部回归、核平滑和平滑样条回归模型
  5. torch.Tensor(dim)与torch.Tensor((dim)), torch.Tensor(dim1,dim2)与torch.Tensor((dim1,dim2))的区别
  6. 工地反光衣穿戴检测算法
  7. mysql 矩阵运算_HDU 2276 Kiki amp; Little Kiki 2 (位运算+矩阵快速幂)
  8. 信源编码与信道编码-Source coding Channel coding
  9. 第一节计算机课学什么,第一节电脑课作文
  10. login.php 什么意思,php is_login()做什么用的;