एक रैंडम मॉडल
इस अभ्यास में आप cumulative gains curve की बेसलाइन दोबारा बनाएँगे, यानी एक रैंडम मॉडल की cumulative gains curve.
इसके लिए, आपको रैंडम प्रेडिक्शंस बनानी होंगी। plot_cumulative_gain मेथड को इन प्रेडिक्शंस के लिए दो मान चाहिए: एक तब जब target 0 हो और एक जब target 1 हो। ये मानों का योग 1 होना चाहिए, इसलिए एक वैध प्रेडिक्शंस लिस्ट उदाहरण के लिए [(0.02,0.98),(0.27,0.73),...,(0.09,0.91)] हो सकती है.
Python में, आप a और b के बीच एक रैंडम मान इस तरह जनरेट कर सकते हैं:
import random
random_value = random.uniform(a,b)
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में प्रिडिक्टिव एनालिटिक्स परिचय
अभ्यास निर्देश
random,matplotlibऔरscikitplotमॉड्यूल इम्पोर्ट करें- एक लिस्ट
random_predictionsबनाएँ जिसमें 0 और 1 के बीच के रैंडम नंबर शामिल हों. - लिस्ट
random_predictionsको इस तरह एडजस्ट करें कि उसमें ट्यूपल्स(r,a)हों, जहाँrलिस्ट का मूल मान है औरaऐसा मान है कि \(r+a=1\). - टारगेट के वास्तविक मान
targets_testमें हैं। अपने रैंडम मॉडल का cumulative gains ग्राफ दिखाएँ.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import the modules
import ____
import ____ as plt
import ____ as skplt
# Generate random predictions
random_predictions = [random.uniform(____,____) for _ in range(len(targets_test))]
# Adjust random predictions
random_predictions = [(r, ____ - ____) for r in random_predictions]
# Plot the cumulative gains graph
skplt.metrics.plot_cumulative_gain(targets_test, ____)
plt.show()