I have a linear regression classifier. I want to implement and plot a sigmoid curve using the parameters (slope and inrtercept) of my linear regression model but i am getting some error
code:
import pandas as pd
import seaborn as sb
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import math
glucose1 = [i for i in range(100,123)]
glucose2 = [i for i in range(130,140)]
glucose = glucose1 + glucose2
diabetes = [1 if i>126 else 0 for i in glucose]
Data = pd.DataFrame(list(zip(glucose,diabetes)), columns = ['Glucose','Diabetes'])
Data.head()
Y = Data['Diabetes'].values
X = Data['Glucose'].values
LR = LinearRegression()
LR.fit(X.reshape(-1,1),Y)
def sigmoid(b0,b1,x):
a = []
for item in x:
a.append(1/(1 + math.exp(-(b0 + b1 * x))))
return a
sig = sigmoid(LR.intercept_, LR.coef_, X)
plt.plot(X,sig)
plt.show()
the error message:
TypeError Traceback (most recent call last) in () 28 return a 29 ---> 30 sig = sigmoid(LR.intercept_, LR.coef_, X) 31 32 plt.plot(X,sig)
in sigmoid(b0, b1, x) 25 a = [] 26 for item in x: ---> 27 a.append(1/(1 + math.exp(-(b0 + b1 * x)))) 28 return a 29
TypeError: only size-1 arrays can be converted to Python scalars