शुरू करेंमुफ़्त में शुरू करें

Logistic Regression का एक पैरामीटर निकालना

अब आप logistic regression मॉडल के एक महत्वपूर्ण पैरामीटर को निकालने का अभ्यास करेंगे. Logistic regression में कुछ और पैरामीटर भी होते हैं जिन्हें आप यहाँ नहीं देखेंगे, लेकिन आप उन्हें scikit-learn.org पर LogisticRegression() मॉड्यूल की 'Attributes' सेक्शन में देख सकते हैं.

यह पैरामीटर यह समझने के लिए महत्वपूर्ण है कि वैरिएबल्स का target पर प्रभाव किस दिशा में और कितनी मात्रा में है.

इस अभ्यास में हम coefficient पैरामीटर (जो coef_ attribute में मिलता है) निकालेंगे, उसे मूल कॉलम नामों के साथ zip करेंगे, और देखेंगे कि किन वैरिएबल्स का target वैरिएबल पर सबसे बड़ा सकारात्मक प्रभाव था.

आपके पास उपलब्ध होगा:

  • log_reg_clf नाम का एक logistic regression मॉडल ऑब्जेक्ट
  • X_train DataFrame

sklearn और pandas आपके लिए इम्पोर्ट कर दिए गए हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Hyperparameter Tuning

पाठ्यक्रम देखें

अभ्यास निर्देश

  • training DataFrame में उपयोग किए गए मूल कॉलम नामों की एक लिस्ट बनाएँ.
  • logistic regression estimator के coefficients निकालें.
  • coefficients और वैरिएबल नामों का एक DataFrame बनाएँ और उसे देखें.
  • coefficient के आकार के आधार पर शीर्ष 3 'positive' वैरिएबल्स प्रिंट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Create a list of original variable names from the training DataFrame
original_variables = ____

# Extract the coefficients of the logistic regression estimator
model_coefficients = ____.____[____]

# Create a dataframe of the variables and coefficients & print it out
coefficient_df = pd.DataFrame({"Variable" : ____, "Coefficient": ____})
print(coefficient_df)

# Print out the top 3 positive variables
top_three_df = coefficient_df.sort_values(by=____, axis=0, ascending=____)[0:____]
print(top_three_df)
कोड संपादित करें और चलाएँ