Working through a logistic regression example and encountering some difficulties when approaching the statsmodels portion. I have difficulties in the past with Python 3 and pandas dataframes where the df returns an iterator not a list. I have tried adjusting the same with 'logit' however still receiving a ValueError
import numpy as np
import pandas as pd
import os
import statsmodels.api as sm
import pylab as pl
df = pd.read_csv('admissions.csv')
df.head(n=5)
df.columns = ['admit', 'gre', 'gpa', 'prestige']
dummy_ranks = pd.get_dummies(df['prestige'], prefix='prestige')
cols_to_keep = ['admit', 'gre', 'gpa']
data = df[cols_to_keep].join(dummy_ranks.ix[:, 'prestige_2':])
data['intercept'] = 1.0
train_cols = data.columns[1:]
logit = sm.Logit(data['admit'], data[train_cols])
result = logit.fit()
ValueError: On entry to DLASCL parameter number 5 had an illegal value
missing
keyword in the models. – Fluorescent