İnsidansları görselleştirme
Predictor insight grafiğinin en önemli öğesi insidans değerleridir. Verilen bir değişkene göre popülasyondaki her grup için insidans değerleri, o gruptaki hedeflerin yüzdesini yansıtır. Bu egzersizde, predictor insight grafiği tablosu verildiğinde bir değişkenin insidans değerlerini çizen bir Python fonksiyonu yazacaksın.
Bu egzersiz, kursun bir parçasıdır
Python ile Öngörücü Analitiğe Giriş
Uygulamalı etkileşimli egzersiz
Bu egzersizi bu örnek kodu tamamlayarak deneyin.
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()