title: How to find Logistic / Sigmoidal function parameters in Logistic Regression
body: <p>I want to estimate the best parameters (mentioned at very end : slope and intercept) for sigmoidal / logistic used in logistic regression for a medical data. Here's what I've done python:  </p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have Apache.mat file which contain 4 columns :  Apache score (0-72), Number of patients, Number of deaths, Proportion (ratio of Number of deaths to Number of patients) </p>
  
  <pre><code>datamat = loadmat('Apache.mat')
  data = pd.DataFrame(np.hstack((datamat['apacheII'], datamat['NoPatients'], 
  datamat['NoDeaths'], datamat['proportion'])))
  
  data.columns = ['apacheII', 'NoPatients', 'NoDeaths', 'proportion']
  </code></pre>
  
  <p>Here I've created the dataframe to work with.</p>
  
  <pre><code>x = np.array(data.drop(['NoPatients', 'NoDeaths', 'proportion'],1))
  </code></pre>
  
  <p>I've dropped the undesired columns and now only left with ApacheII score in 'x'</p>
  
  <pre><code>#scaling the data (normalizing)
  x = preprocessing.scale(x)
  
  y = np.array(data['proportion'])
  </code></pre>
  
  <p>Now, I've used LabelEncoder() function to encode 'y' so it could be compatible with LogisticRegression().</p>
  
  <pre><code>lab_enc = preprocessing.LabelEncoder()
  encoded = np.array(lab_enc.fit_transform(y))
  
  clf = LogisticRegression()
  clf.fit(x, encoded)
  print(clf.coef_)
  print(clf.intercept_)
  </code></pre>
  
  <p>The output is as follows:</p>
  
  <pre><code>[[-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]
  </code></pre>
  
  <p>I just want to find out the parameters for sigmoidal function which is generally used in Logistic Regression. How can I find the sigmoidal parameters (i.e intercept and slope) ?</p>
  
  <p>Here is sigmoidal function (if reference is needed): </p>
  
  <pre><code>def sigmoid(x, x0, k):
       y = 1 / (1 + np.exp(-k*(x-x0)))
       return y
  </code></pre>