I know that logistic regression uses 0s and 1s for the dependent variable. But how are the 0s and 1s allocated when the variable is defined as a category, "Healthy" vs. "Sick"? In other words, what is the reference level? Is "Healthy" given a 0 because H is first in the alphabet?
import pandas as pd
import numpy as np
import os
from sklearn.model_selection import RepeatedKFold, cross_val_score
from sklearn.linear_model import LogisticRegression
# index_col=0 eliminates the dumb index column
baseball_train = pd.read_csv(r"baseball_train.csv",index_col=0,
dtype={'Opp': 'category', 'Result': 'category',
'Name': 'category'}, header=0)
baseball_test = pd.read_csv(r"baseball_test.csv",index_col=0,
dtype={'Opp': 'category', 'Result': 'category',
'Name': 'category'}, header=0)
# take all independent variables
X = baseball_train.iloc[:,:-1]
# drop opp and result because I don't want them
X = X.drop(['Opp','Result'],axis=1)
# dependent variable
y = baseball_train.iloc[:,-1]
# Create logistic regression
logit = LogisticRegression(fit_intercept=True)
model = logit.fit(X,y)
Here, Name is the dependent variable with categories: "Nolan" and "Tom" not 0s and 1s