इंसिडेंस को प्लॉट करना
Predictor insight graph का सबसे महत्वपूर्ण हिस्सा इंसिडेंस मान होते हैं। किसी दिए गए वैरिएबल के संदर्भ में जनसंख्या के प्रत्येक समूह के लिए, इंसिडेंस मान उस समूह में targets का प्रतिशत दर्शाते हैं. इस अभ्यास में, आप एक Python फंक्शन लिखेंगे जो predictor insight graph टेबल के आधार पर किसी वैरिएबल के इंसिडेंस मानों को प्लॉट करता है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में प्रिडिक्टिव एनालिटिक्स परिचय
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
import matplotlib.pyplot as plt
import numpy as np
# The function to plot a predictor insight graph.
def plot_incidence(pig_table,variable):
# Plot the incidence line
____["____"].plot()
# Formatting the predictor insight graph
plt.xticks(np.arange(len(pig_table)), pig_table[variable])
plt.xlim([-0.5, len(pig_table) - 0.5])
plt.ylim([0, max(pig_table["Incidence"] * 2)])
plt.ylabel("Incidence", rotation=0, rotation_mode="anchor", ha="right")
plt.xlabel(variable)
# Show the graph
plt.show()