import pandas as pd
df = pd.read_csv('http://bit.ly/kaggletrain', usecols=['Embarked', 'Survived']).dropna()
X = df[['Embarked']]
y = df['Survived']
from sklearn.preprocessing import OneHotEncoder
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
pipe = Pipeline([('ohe', OneHotEncoder()), ('clf', LogisticRegression())])
pipe.fit(X, y);
pipe.named_steps.clf.coef_
array([[ 0.5072001 , -0.13716737, -0.37001877]])
pipe.named_steps['clf'].coef_
array([[ 0.5072001 , -0.13716737, -0.37001877]])
pipe['clf'].coef_
array([[ 0.5072001 , -0.13716737, -0.37001877]])
pipe[1].coef_
array([[ 0.5072001 , -0.13716737, -0.37001877]])
© 2020 Data School. All rights reserved.