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

Aggregated target की गणना करें

मान लीजिए आप एक predictive मॉडल बनाना चाहते हैं जो यह बताता है कि किन donors के किसी महीने में 50 euro से अधिक दान करने की संभावना सबसे अधिक है.

दिया गया basetable basetable पहले से population के प्रत्येक donor के लिए एक पंक्ति रखता है, जहाँ कॉलम donor_id donor को दर्शाता है. timeline यह बताती है कि target 1 होना चाहिए अगर donor ने January 2017 में 50 euro से अधिक दान किया है, अन्यथा 0.

pandas dataframe gifts_201701 में January 2017 की सभी donations हैं. इस अभ्यास में आप basetable में target कॉलम जोड़ेंगे.

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

इंटरमीडिएट Predictive Analytics in Python

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

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

  • gifts_summed बनाइए, जिसमें gifts_201701 के प्रत्येक donor के लिए donations का sum हो.
  • gifts_summed से एक सूची targets निकलिए जिसमें वे donors हों जिन्होंने target अवधि में 50 Euro से अधिक दान किया हो.
  • target को basetable में जोड़ें.
  • target incidence की गणना करें और प्रिंट करें.

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

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

# Sum of donations for each donor in gifts_201701
gifts_summed = ____.groupby("____")["____"].____().reset_index()

# List with targets
targets = list(gifts_summed["id"][____["____"] > ____])

# Add targets to the basetable
basetable["target"] = pd.Series([____ if donor_id in targets else ____ for donor_id in basetable["donor_id"]])

# Calculate and print the target incidence
print(round(____["____"].____() / ____(____), 2))
कोड संपादित करें और चलाएँ