진화 변수 사용

Python 중급 예측 분석

Nele Verbiest

Senior Data Scientist @PythonPredictions

예측 모델 구축

# Import the linear_model module
from sklearn import linear_model

# Predictive variables variables = ["gender","age", "donations_last_year", "ratio_month_year"]
# Select predictors and target X = basetable[variables] y = basetable[["target"]]
# Construct the logistic regression model logreg = linear_model.LogisticRegression() logreg.fit(X, y)
Python 중급 예측 분석

예측 생성

# Import the linear_model module
from sklearn import linear_model

# Predictive variables variables = ["gender","age", "donations_last_year", "ratio_month_year"]
# Select predictors and target X = basetable[variables] y = basetable[["target"]]
# Construct the logistic regression model logreg = linear_model.LogisticRegression() logreg.fit(X, y)
# Make predictions
predictions = logreg.predict_proba(X)[:,1]
Python 중급 예측 분석

AUC로 예측 모델 평가

# Discretize the variable in 5 bins and add to the basetable
basetable["ratio_month_year_disc"] = pd.qcut(basetable["ratio_month_year"], 5)

# Construct the predictor insight graph table pig_table = create_pig_table(basetable, "target","ratio_month_year_disc") ```{python} # Plot the predictor insight graph plot_pig(pig_table, "ratio_month_year_disc")
Python 중급 예측 분석

예측 변수 인사이트 그래프

# Discretize the variable in 5 bins and add to the basetable
basetable["ratio_month_year_disc"] = pd.qcut(basetable["ratio_month_year"], 5)

# Construct the predictor insight graph table pig_table = create_pig_table(basetable, "target","ratio_month_year_disc") ```{python} # Plot the predictor insight graph plot_pig(pig_table, "ratio_month_year_disc")
Python 중급 예측 분석

인사이트 그래프 해석

Python 중급 예측 분석

연습해 봅시다!

Python 중급 예측 분석

Preparing Video For Download...