python logistic参数_如何在Logistic回归中寻找Logistic/Sigmoidal函数参数

我想估计用于医学数据logistic回归的sigmoidal/logistic的最佳参数(在末尾提到:斜率和截距)。以下是我在python中所做的:import numpy as np

from sklearn import preprocessing, svm, neighbors

from sklearn.linear_model import LinearRegression, LogisticRegression

from sklearn.model_selection import train_test_split

from sklearn import preprocessing, svm, utils

from scipy.io import loadmat

import pandas as pd

我有阿帕奇.mat包含4列的文件:Apache评分(0-72)、患者人数、死亡人数、比例(死亡人数与患者人数之比)

^{pr2}$

这里我已经创建了要使用的数据帧。在x = np.array(data.drop(['NoPatients', 'NoDeaths', 'proportion'],1))

我已经删除了不想要的列,现在只剩下了“x”中的ApacheII分数#scaling the data (normalizing)

x = preprocessing.scale(x)

y = np.array(data['proportion'])

现在,我已经使用LabelEncoder()函数对'y'进行编码,这样它就可以与LogisticRegression()兼容。在lab_enc = preprocessing.LabelEncoder()

encoded = np.array(lab_enc.fit_transform(y))

clf = LogisticRegression()

clf.fit(x, encoded)

print(clf.coef_)

print(clf.intercept_)

输出如下:[[-0.49124107]

[-0.23528893]

[-0.19035795]

[-0.30312848]

[-0.25783808]

[-0.37161079]

[-0.12332468]

[-0.16797195]

[-0.05660718]

[-0.21279785]

[-0.22142453]

[-0.10105617]

[-0.14562868]

[ 0.00991192]

[-0.012247 ]

[ 0.03206243]

[ 0.07635461]

[ 0.20951544]

[ 0.12067417]

[-0.03441851]

[ 0.16504852]

[ 0.09850035]

[ 0.23179558]

[ 0.05420914]

[ 1.47513463]]

[-1.79691975 -2.35677113 -2.35090141 -2.3679202 -2.36017388 -2.38191049

-2.34441678 -2.34843121 -2.34070389 -2.35368047 -1.57944984 -2.3428732

-2.3462668 -2.33974088 -2.33975687 -2.34002906 -2.34151792 -2.35329447

-2.34422478 -2.34007746 -2.34814388 -2.34271603 -2.35632459 -2.34062229

-1.72511457]

我只想找出Logistic回归中常用的sigmoidal函数的参数。如何找到S形参数(即截距和斜率)?在

这里是sigmoidal函数(如果需要参考):def sigmoid(x, x0, k):

y = 1 / (1 + np.exp(-k*(x-x0)))

return y

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值