ebooks को conviction के साथ प्रमोट करना
पिछले अभ्यास में, हमने conviction निकालने के लिए एक फंक्शन परिभाषित किया था. हमें वह फंक्शन goodreads-10k डेटासेट की दो-पुस्तक permutations पर लागू करना था. इस अभ्यास में, हम उस फंक्शन को तीन सबसे लोकप्रिय पुस्तकों पर आज़माएँगे, जिनका उपयोग आपने पहले भी किया है: The Hunger Games, Harry Potter, और Twilight.
यह फंक्शन आपके लिए पहले से परिभाषित है और conviction नाम से उपलब्ध है. याद रखें, यह दो आर्ग्यूमेंट लेता है: antecedent और consequent. इसके अलावा, पहले के अभ्यासों से books DataFrame के कॉलम तीन अलग-अलग DataFrames के रूप में उपलब्ध हैं: potter, twilight, और hunger.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Market Basket Analysis
अभ्यास निर्देश
- {Twilight} \(\rightarrow\) {Potter} और {Potter} \(\rightarrow\) {Twilight} के लिए conviction निकालें.
- {Twilight} \(\rightarrow\) {Hunger} और {Hunger} \(\rightarrow\) {Twilight} के लिए conviction निकालें.
- {Potter} \(\rightarrow\) {Hunger} और {Hunger} \(\rightarrow\) {Potter} के लिए conviction निकालें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Compute conviction for twilight -> potter and potter -> twilight
convictionTP = conviction(twilight, potter)
convictionPT = conviction(____, twilight)
# Compute conviction for twilight -> hunger and hunger -> twilight
convictionTH = conviction(____, ____)
convictionHT = ____(hunger, twilight)
# Compute conviction for potter -> hunger and hunger -> potter
convictionPH = ____(potter, hunger)
convictionHP = ____
# Print results
print('Harry Potter -> Twilight: ', convictionHT)
print('Twilight -> Potter: ', convictionTP)