# భాగాలను దృశ్యీకరించడం |![ Sketchnote by [(@sketchthedocs)](https://sketchthedocs.dev) ](../../sketchnotes/11-Visualizing-Proportions.png)| |:---:| |భాగాలను దృశ్యీకరించడం - _స్కెచ్ నోట్ [@nitya](https://twitter.com/nitya) ద్వారా_ | ఈ పాఠంలో, మీరు మష్రూమ్‌ల గురించి ఒక dataset లోని విభిన్న రకాల ఫంగస్ ఎంతమేరకు ఉన్నాయో భాగాలను దృశ్యీకరించడానికి వేరే ప్రకృతి-కేంద్రీకృత dataset ఉపయోగిస్తారు. Audubon నుండి పొందిన 23 రకాల గిల్లెడ్ మష్రూమ్‌ల వివరాలు ఉన్న Agaricus మరియు Lepiota కుటుంబాల dataset ఉపయోగించి ఈ ఆసక్తికరమైన ఫంగస్‌లను పరిశీలిద్దాం. మీరు ఈ రుచికరమైన దృశ్యీకరణలతో ప్రయోగం చేయబోతున్నారు: - పై చార్ట్లు 🥧 - డోనట్ చార్ట్లు 🍩 - వాఫిల్ చార్ట్లు 🧇 > 💡 Microsoft Research నుండి [Charticulator](https://charticulator.com) అనే చాలా ఆసక్తికరమైన ప్రాజెక్ట్ ఉచిత డ్రాగ్ అండ్ డ్రాప్ ఇంటర్‌ఫేస్‌ను డేటా దృశ్యీకరణల కోసం అందిస్తుంది. వారి ట్యుటోరియల్స్‌లో ఒకటిలో కూడా ఈ మష్రూమ్ dataset ఉపయోగిస్తారు! కాబట్టి మీరు డేటాను అన్వేషించి లైబ్రరీని ఒకేసారి నేర్చుకోవచ్చు: [Charticulator ట్యుటోరియల్](https://charticulator.com/tutorials/tutorial4.html). ## [పాఠం ముందు క్విజ్](https://ff-quizzes.netlify.app/en/ds/quiz/20) ## మీ మష్రూమ్‌లను తెలుసుకోండి 🍄 మష్రూమ్‌లు చాలా ఆసక్తికరమైనవి. వాటిని అధ్యయనం చేయడానికి ఒక dataset ను దిగుమతి చేద్దాం: ```python import pandas as pd import matplotlib.pyplot as plt mushrooms = pd.read_csv('../../data/mushrooms.csv') mushrooms.head() ``` ఒక పట్టిక విశ్లేషణకు మంచి డేటాతో ముద్రించబడింది: | class | cap-shape | cap-surface | cap-color | bruises | odor | gill-attachment | gill-spacing | gill-size | gill-color | stalk-shape | stalk-root | stalk-surface-above-ring | stalk-surface-below-ring | stalk-color-above-ring | stalk-color-below-ring | veil-type | veil-color | ring-number | ring-type | spore-print-color | population | habitat | | --------- | --------- | ----------- | --------- | ------- | ------- | --------------- | ------------ | --------- | ---------- | ----------- | ---------- | ------------------------ | ------------------------ | ---------------------- | ---------------------- | --------- | ---------- | ----------- | --------- | ----------------- | ---------- | ------- | | Poisonous | Convex | Smooth | Brown | Bruises | Pungent | Free | Close | Narrow | Black | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban | | Edible | Convex | Smooth | Yellow | Bruises | Almond | Free | Close | Broad | Black | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Grasses | | Edible | Bell | Smooth | White | Bruises | Anise | Free | Close | Broad | Brown | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Meadows | | Poisonous | Convex | Scaly | White | Bruises | Pungent | Free | Close | Narrow | Brown | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban | తక్షణమే, మీరు గమనిస్తారు అన్ని డేటా వచనాత్మకంగా ఉంది. మీరు ఈ డేటాను చార్ట్‌లో ఉపయోగించడానికి మార్చుకోవాలి. నిజానికి, ఎక్కువ భాగం డేటా ఒక ఆబ్జెక్ట్‌గా ప్రదర్శించబడింది: ```python print(mushrooms.select_dtypes(["object"]).columns) ``` ఫలితం: ```output Index(['class', 'cap-shape', 'cap-surface', 'cap-color', 'bruises', 'odor', 'gill-attachment', 'gill-spacing', 'gill-size', 'gill-color', 'stalk-shape', 'stalk-root', 'stalk-surface-above-ring', 'stalk-surface-below-ring', 'stalk-color-above-ring', 'stalk-color-below-ring', 'veil-type', 'veil-color', 'ring-number', 'ring-type', 'spore-print-color', 'population', 'habitat'], dtype='object') ``` ఈ డేటాను తీసుకుని 'class' కాలమ్‌ను category గా మార్చండి: ```python cols = mushrooms.select_dtypes(["object"]).columns mushrooms[cols] = mushrooms[cols].astype('category') ``` ```python edibleclass=mushrooms.groupby(['class']).count() edibleclass ``` ఇప్పుడు, మీరు మష్రూమ్ డేటాను ముద్రిస్తే, అది poisonous/edible క్లాస్ ప్రకారం వర్గీకరించబడిందని చూడవచ్చు: | | cap-shape | cap-surface | cap-color | bruises | odor | gill-attachment | gill-spacing | gill-size | gill-color | stalk-shape | ... | stalk-surface-below-ring | stalk-color-above-ring | stalk-color-below-ring | veil-type | veil-color | ring-number | ring-type | spore-print-color | population | habitat | | --------- | --------- | ----------- | --------- | ------- | ---- | --------------- | ------------ | --------- | ---------- | ----------- | --- | ------------------------ | ---------------------- | ---------------------- | --------- | ---------- | ----------- | --------- | ----------------- | ---------- | ------- | | class | | | | | | | | | | | | | | | | | | | | | | | Edible | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | ... | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | 4208 | | Poisonous | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | ... | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | 3916 | ఈ పట్టికలో చూపించిన క్రమాన్ని అనుసరించి మీ class category లేబుల్స్ సృష్టిస్తే, మీరు పై చార్ట్ తయారు చేయవచ్చు: ## పై! ```python labels=['Edible','Poisonous'] plt.pie(edibleclass['population'],labels=labels,autopct='%.1f %%') plt.title('Edible?') plt.show() ``` ఇది, ఈ రెండు మష్రూమ్ తరగతుల ప్రకారం ఈ డేటా భాగాలను చూపించే పై చార్ట్. లేబుల్స్ క్రమం సరిగ్గా ఉండటం చాలా ముఖ్యం, కాబట్టి లేబుల్ అర్రే ఎలా నిర్మించబడిందో నిర్ధారించుకోండి! ![pie chart](../../../../translated_images/te/pie1-wb.e201f2fcc3354131.webp) ## డోనట్స్! కొంతమేర దృశ్యంగా ఆసక్తికరమైన పై చార్ట్ డోనట్ చార్ట్, ఇది మధ్యలో రంధ్రం ఉన్న పై చార్ట్. ఈ పద్ధతిని ఉపయోగించి మన డేటాను చూద్దాం. మష్రూమ్‌లు పెరుగుతున్న వివిధ వాతావరణాలను పరిశీలించండి: ```python habitat=mushrooms.groupby(['habitat']).count() habitat ``` ఇక్కడ, మీరు మీ డేటాను వాతావరణం ప్రకారం వర్గీకరిస్తున్నారు. 7 వాతావరణాలు ఉన్నాయి, కాబట్టి వాటిని మీ డోనట్ చార్ట్ లేబుల్స్‌గా ఉపయోగించండి: ```python labels=['Grasses','Leaves','Meadows','Paths','Urban','Waste','Wood'] plt.pie(habitat['class'], labels=labels, autopct='%1.1f%%', pctdistance=0.85) center_circle = plt.Circle((0, 0), 0.40, fc='white') fig = plt.gcf() fig.gca().add_artist(center_circle) plt.title('Mushroom Habitats') plt.show() ``` ![donut chart](../../../../translated_images/te/donut-wb.be3c12a22712302b.webp) ఈ కోడ్ ఒక చార్ట్ మరియు మధ్యలో ఒక వృత్తాన్ని గీయడం, ఆ మధ్య వృత్తాన్ని చార్ట్‌లో చేర్చడం చేస్తుంది. మధ్య వృత్తం వెడల్పును మార్చడానికి `0.40` ను మరొక విలువగా మార్చండి. డోనట్ చార్ట్లను లేబుల్స్ మార్చడానికి అనేక విధాలుగా సవరించవచ్చు. ముఖ్యంగా లేబుల్స్ పఠనీయత కోసం హైలైట్ చేయవచ్చు. మరింత తెలుసుకోండి [డాక్స్](https://matplotlib.org/stable/gallery/pie_and_polar_charts/pie_and_donut_labels.html?highlight=donut). ఇప్పుడు మీరు మీ డేటాను వర్గీకరించి దాన్ని పై లేదా డోనట్‌గా ప్రదర్శించడం ఎలా చేయాలో తెలుసుకున్నారంటే, మీరు ఇతర రకాల చార్ట్లను అన్వేషించవచ్చు. వాఫిల్ చార్ట్ ప్రయత్నించండి, ఇది కేవలం పరిమాణాన్ని అన్వేషించే వేరే విధానం. ## వాఫిల్స్! 'వాఫిల్' రకం చార్ట్ అనేది పరిమాణాలను 2D చతురస్రాల అర్రేగా దృశ్యీకరించే వేరే విధానం. ఈ dataset లోని మష్రూమ్ క్యాప్ రంగుల విభిన్న పరిమాణాలను దృశ్యీకరించడానికి ప్రయత్నించండి. దీని కోసం, మీరు [PyWaffle](https://pypi.org/project/pywaffle/) అనే సహాయక లైబ్రరీని ఇన్‌స్టాల్ చేసి Matplotlib ఉపయోగించాలి: ```python pip install pywaffle ``` మీ డేటా ఒక భాగాన్ని ఎంచుకోండి: ```python capcolor=mushrooms.groupby(['cap-color']).count() capcolor ``` లేబుల్స్ సృష్టించి డేటాను వర్గీకరించి వాఫిల్ చార్ట్ సృష్టించండి: ```python import pandas as pd import matplotlib.pyplot as plt from pywaffle import Waffle data ={'color': ['brown', 'buff', 'cinnamon', 'green', 'pink', 'purple', 'red', 'white', 'yellow'], 'amount': capcolor['class'] } df = pd.DataFrame(data) fig = plt.figure( FigureClass = Waffle, rows = 100, values = df.amount, labels = list(df.color), figsize = (30,30), colors=["brown", "tan", "maroon", "green", "pink", "purple", "red", "whitesmoke", "yellow"], ) ``` వాఫిల్ చార్ట్ ఉపయోగించి, మీరు ఈ మష్రూమ్ dataset క్యాప్ రంగుల భాగాలను స్పష్టంగా చూడవచ్చు. ఆసక్తికరంగా, చాలా గ్రీన్-క్యాప్ మష్రూమ్‌లు ఉన్నాయి! ![waffle chart](../../../../translated_images/te/waffle.5455dbae4ccf17d5.webp) ✅ Pywaffle చార్ట్లలో [Font Awesome](https://fontawesome.com/)లో అందుబాటులో ఉన్న ఏ ఐకాన్ అయినా ఉపయోగించగలదు. చతురస్రాల స్థానంలో ఐకాన్లను ఉపయోగించి మరింత ఆసక్తికరమైన వాఫిల్ చార్ట్ సృష్టించడానికి ప్రయోగాలు చేయండి. ఈ పాఠంలో, మీరు భాగాలను దృశ్యీకరించే మూడు మార్గాలను నేర్చుకున్నారు. మొదట, మీ డేటాను వర్గాలుగా వర్గీకరించాలి, ఆపై డేటాను ప్రదర్శించడానికి ఉత్తమ మార్గం - పై, డోనట్ లేదా వాఫిల్ ఎంచుకోవాలి. ఇవన్నీ రుచికరమైనవి మరియు dataset యొక్క తక్షణ స్నాప్‌షాట్‌ను వినియోగదారునికి అందిస్తాయి. ## 🚀 సవాలు ఈ రుచికరమైన చార్ట్లను [Charticulator](https://charticulator.com) లో పునఃసృష్టించడానికి ప్రయత్నించండి. ## [పాఠం తర్వాత క్విజ్](https://ff-quizzes.netlify.app/en/ds/quiz/21) ## సమీక్ష & స్వీయ అధ్యయనం ఎప్పుడైతే పై, డోనట్ లేదా వాఫిల్ చార్ట్ ఉపయోగించాలో స్పష్టంగా తెలియదు. ఈ విషయంపై చదవడానికి కొన్ని వ్యాసాలు: https://www.beautiful.ai/blog/battle-of-the-charts-pie-chart-vs-donut-chart https://medium.com/@hypsypops/pie-chart-vs-donut-chart-showdown-in-the-ring-5d24fd86a9ce https://www.mit.edu/~mbarker/formula1/f1help/11-ch-c6.htm https://medium.datadriveninvestor.com/data-visualization-done-the-right-way-with-tableau-waffle-chart-fdf2a19be402 ఈ క్లిష్ట నిర్ణయం గురించి మరింత సమాచారం కోసం పరిశోధన చేయండి. ## అసైన్‌మెంట్ [Excel లో ప్రయత్నించండి](assignment.md) --- **అస్పష్టత**: ఈ పత్రాన్ని AI అనువాద సేవ [Co-op Translator](https://github.com/Azure/co-op-translator) ఉపయోగించి అనువదించబడింది. మేము ఖచ్చితత్వానికి ప్రయత్నించినప్పటికీ, ఆటోమేటెడ్ అనువాదాల్లో పొరపాట్లు లేదా తప్పిదాలు ఉండవచ్చు. మూల పత్రం దాని స్వదేశీ భాషలోనే అధికారిక మూలంగా పరిగణించాలి. ముఖ్యమైన సమాచారానికి, ప్రొఫెషనల్ మానవ అనువాదం చేయించుకోవడం మంచిది. ఈ అనువాదం వలన కలిగే ఏవైనా అపార్థాలు లేదా తప్పుదారుల బాధ్యత మేము తీసుకోము.