Python Forum
Evaluate dataset with logistic regression
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Evaluate dataset with logistic regression
#1
To start I'll just say that I do a lot of work with Python but I'm venturing into new territory with math/data plotting so bear with me. My dataset includes 4 columns - person, x, y coordinates and a binary response to those coordinates. With this data I'm looking to do a few different things.

- Return a probability value for each set of x,y coordinates
- Create some sort of graph (heatmap/density?) that will show the the likelihood of 0/1 for areas of the graph
- Evaluate subsets of the data using the 'person' column

Based on the research I've done sklearn.linear_model LogisticRegression seems to be the best way to go about this (have also toyed with pyGAM). As my script shows the furthest I've gotten is running the "predict_proba" function on the dataset but either I'm doing something wrong elsewhere or I just don't know how to intepret the results because they seem way off. If anyone can help me with this I would really appreciate it.

data_df = frame[['person','x_value','y_value','binary_result']]

#Create a scatter plot of the x,y coordinates with regard to their binary result
fig = plt.figure(figsize=(4,4))
ax = fig.add_subplot(1, 1, 1)

bin_res = [0,1]
bin_col = ['r','g']

for res,col in zip(bin_res,bin_col):
    plot_df = data_df[(data_df['binary_result']  == res)]
    ax.scatter(plot_df['x_value'], plot_df['y_value'], c=col, marker='.')   

plt.show()

#Execute logistic regression on the dataset
x = data_df[['x_value','y_value']]
y = data_df[['binary_result']]

log_reg = linear_model.LogisticRegression(solver='lbfgs').fit(x,np.ravel(y))

predictions = log_reg.predict(x)
predict_a = log_reg.predict_proba(x)

print(predict_a)
*FYI I've also asked this question on StackOverflow
Reply


Messages In This Thread
Evaluate dataset with logistic regression - by chisox721 - Jun-05-2019, 06:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Evaluate Calculations yrstruly 0 1,022 Jun-17-2023, 06:51 PM
Last Post: yrstruly
  Hosmer-Lemeshow test in logistic regression Ninax 1 3,054 Feb-17-2021, 10:50 PM
Last Post: Larz60+
  Can I evaluate a Chebyshev polynomial using a function player1681 1 1,999 Nov-22-2019, 06:33 AM
Last Post: scidam
  Logistic regression with Tensorflow kiton 1 2,578 Nov-28-2018, 07:34 PM
Last Post: kiton

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020