I am doing a regression model with scikit learn and trying to predict a binary outcome (0,1).
X = tset.iloc[:,24:36].values
y = tset.iloc[:,20].values
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=0)
logreg = LogisticRegression()
logreg.fit(X_train, y_train)
On my training dataframe, I have applied the logistic regression function above.
Now, I would like to take what the ML model has learned and in the test set, get the probability of each row being 1 as an additional column...so based on what the variables in row 1 are, in the new column it would have the probability that row 1 is 1 (in the binary classification), and so on for all the other rows in the test dataframe. If I could get the predicted output (0 or 1) that would be helpful too.
I can't seem to find any tutorials on this step... How do I go about doing this?
Item ID Variables Predicted Output Probability of Output
1 ... 1 .62
2 ... 0 .55
3 ... 0 .52
4 ... 1 .65
Would want it to look somewhat like that. ^