विभिन्न वैरिएबल सेट्स का उपयोग
अपने logistic regression मॉडल में ज़्यादा वैरिएबल जोड़ना, और इस तरह अधिक जटिलता लाना, अपने-आप अधिक सटीक मॉडल नहीं देता. इस अभ्यास में आप जाँच सकते हैं कि क्या किसी मॉडल में 3 वैरिएबल जोड़ने से वह अधिक सटीक बनता है.
variables_1 और variables_2 आपके एनवायरनमेंट में उपलब्ध हैं: आप उन्हें कंसोल पर प्रिंट करके देख सकते हैं कि वे कैसे दिखते हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में प्रिडिक्टिव एनालिटिक्स परिचय
अभ्यास निर्देश
variables_2का उपयोग करकेlogregमॉडल फिट करें, जिसमेंvariables_1की तुलना में 3 अतिरिक्त वैरिएबल हैं.- इस मॉडल के लिए प्रेडिक्शन बनाएँ.
- इस मॉडल का AUC कैलकुलेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create appropriate DataFrames
X_1 = basetable[variables_1]
X_2 = basetable[variables_2]
y = basetable[["target"]]
# Create the logistic regression model
logreg = linear_model.LogisticRegression()
# Make predictions using the first set of variables and assign the AUC to auc_1
logreg.fit(X_1, y)
predictions_1 = logreg.predict_proba(X_1)[:,1]
auc_1 = roc_auc_score(y, predictions_1)
# Make predictions using the second set of variables and assign the AUC to auc_2
logreg.____(____, ____)
predictions_2 = ____.____(____)[____,____]
auc_2 = ____(____, ____)
# Print auc_1 and auc_2
print(round(auc_1,2))
print(round(auc_2,2))