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

ग्रुप साइज का प्लॉट बनाना

Predictor insight graph भविष्यवाणी करने वाले वैरिएबल्स के बारे में जानकारी देता है। हर वैरिएबल आबादी को कई ग्रुप्स में बाँटता है। Predictor insight graph में एक लाइन होती है जो हर ग्रुप के लिए औसत target incidence दिखाती है, और एक बार होता है जो ग्रुप के साइज दिखाता है. इस अभ्यास में, आप सीखेंगे कि predictor insight graph टेबल दिए जाने पर, एक फंक्शन कैसे लिखें और लागू करें जो predictor insight graph प्लॉट करता है.

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

Python में प्रिडिक्टिव एनालिटिक्स परिचय

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

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

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

# The function to plot a predictor insight graph
def plot_pig(pig_table, variable):
    
    # Plot formatting
    plt.ylabel("Size", rotation=0, rotation_mode="anchor", ha="right")
    
    # Plot the bars with sizes 
    pig_table["____"].plot(kind="bar", width=0.5, color="lightgray", edgecolor="none") 
    
    # Plot the incidence line on secondary axis
    pig_table["____"].plot(secondary_y=True)
    
    # Plot formatting
    plt.xticks(np.arange(len(pig_table)), pig_table[variable])
    plt.xlim([-0.5, len(pig_table) - 0.5])
    plt.ylabel("Incidence", rotation=0, rotation_mode="anchor", ha="left")
    
    # Show the graph
    plt.show()
कोड संपादित करें और चलाएँ