{"cells":[{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"import pandas as pd\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport json","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"df = pd.read_csv('../input/cassava-leaf-disease-classification/train.csv')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Label Distribution"},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"with open('../input/cassava-leaf-disease-classification/label_num_to_disease_map.json', 'r') as f:\n    lab2dis = json.load(f)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"lab2dis","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"df['label_name'] = df['label'].apply(lambda x: lab2dis[str(x)])","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(18, 5))\nsns.countplot(x='label_name', data=df, order=list(lab2dis.values()))","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Visualization"},{"metadata":{},"cell_type":"markdown","source":"## Cassava Bacterial Blight (CBB)"},{"metadata":{},"cell_type":"markdown","source":"### What is Cassava Bacterial Blight (CBB)?"},{"metadata":{},"cell_type":"markdown","source":"> The first sign of the disease is wilting and dying of leaves (Photo CBB 1 & 2). The leaf wilting is accompanied by a viscous amber to orange coloured exudation from the leaf stalks (petioles) and young stems (Photos CBB 3 - 5). As the disease progresses the diseased shoots die so that the plants show the characteristic “dieback” symptoms, with bare leafless stems pointing upward (Photo CBB 6). When large numbers of adjacent plants exhibit the dieback symptoms, the crop appears as a forest of leafless stems which gives rise to the name in French of “la maladie des cierges” or candle disease (Photo CBB 7).The earliest symptoms visible on cassava leaves are dark-greenish water-soaked areas limited by the leaf veins and which show gummy exudation on the water-soaked areas (Photo CBB 8). The lesions enlarge and eventually coalesce along the veins or edges of the leaf, killing the leaf.The vascular bundles of infected petioles and stems are also necrotic, appearing as brown or black bands.There have been reports that seeds from CBB diseased plants that carry a high load of the pathogen are sometimes deformed and necrotic, but the consensus is that CBB infected seeds are asymptomatic carriers and that there are no diagnostic symptoms of CBB on cassava seeds. The bacterium lies dormant in the seed embryo, with dormancy breaking shortly after the\nseeds begin germination.\nNo symptoms of CBB have been recorded on or in cassava roots.  \n> [Cassava Bacterial Blight, Plantvillage](https://plantvillage.psu.edu/diseases/cassava-bacterial-blight)"},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"cbb_df = df.loc[df['label']==0].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"img1 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbb_df.iloc[0,0]}')\nimg2 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbb_df.iloc[1,0]}')\nimg3 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbb_df.iloc[2,0]}')\n\nfig, ax = plt.subplots(figsize=(20, 20))\n\nplt.subplot(1,3,1)\nplt.imshow(img1)\n\nplt.subplot(1,3,2)\nplt.imshow(img2)\n\nplt.subplot(1,3,3)\nplt.imshow(img3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Cassava Brown Streak Disease (CBSD)"},{"metadata":{},"cell_type":"markdown","source":"### What is Brown Streak Disease (CBSD)?"},{"metadata":{},"cell_type":"markdown","source":"> The name brown streak was given to the disease from the brown lesions which sometimes appear on young green stems. These were the first symptoms of the disease to be recognised; however stem lesions are not the most characteristic symptom of infection and occur only infrequently.  \nUnlike symptoms induced by the majority of plant viruses, those of CBSD in cassava normally affect mature or nearly mature leaves but not expanding, immature leaves. They consist of a characteristic yellow or necrotic vein banding which may enlarge and coalesce to form comparatively large, yellow patches. Tuberous root symptoms may also be present: these consist of dark-brown necrotic areas within the tuber and reduction in root size; lesions in roots can result in post-harvest spoilage of the crop. Leaf and/or stem symptoms can occur without the development of tuber symptoms; thus, of plants with above-ground symptoms surveyed in southern Tanzania, 21% failed to develop root necrosis (Hillocks et al., 1996).  \nThe symptoms of the disease vary greatly with variety and environmental conditions, making diagnosis difficult, particularly when plants are infected both with CBSD and cassava mosaic disease.  \nThe virus species UCBSV and CBSV cannot be differentiated according to symptoms induced in cassava. However several cassava cultivars are not susceptible to UCBSV (Winter et al., 2010).  \n>[Cassava brown streak viruses, CABI](https://www.cabi.org/isc/datasheet/17107)"},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"cbsd_df = df.loc[df['label']==1].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"img1 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbsd_df.iloc[0,0]}')\nimg2 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbsd_df.iloc[1,0]}')\nimg3 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cbsd_df.iloc[2,0]}')\n\nfig, ax = plt.subplots(figsize=(20, 20))\n\nplt.subplot(1,3,1)\nplt.imshow(img1)\n\nplt.subplot(1,3,2)\nplt.imshow(img2)\n\nplt.subplot(1,3,3)\nplt.imshow(img3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Cassava Green Mottle (CGM)"},{"metadata":{},"cell_type":"markdown","source":"### What is Cassava Green Mottle (CGM)?"},{"metadata":{},"cell_type":"markdown","source":">Young leaves are puckered with faint to distinct yellow spots (Photo 1), green patterns (mosaics), and twisted margins (Photo 2). Usually, the shoots recover from symptoms and appear healthy. Occasionally, plants become severely stunted, edible roots are absent or, if present, they are small and woody when cooked.\nIn the lab, the virus can be passed between plants in sap, and also in seed. Thirty percent of the seed of infected tobacco plants was infected. Whether it also spreads in seed of cassava is unknown. Seed is not used for growing cassava, so spread on Choiseul is most likely in diseased cuttings. However, there are other possibilities.  \nIn a trial on Choiseul, 4% of plants grown from cuttings taken from Guadalcanal became diseased within 250 days from planting. How this infection occurred is unknown, but there are several possibilities. Plants touching each other in the wind may have transferred sap between those infected and healthy. There is also the possibility of spread by nematodes and pollen. The virus is thought to be a member of the nepovirus group, and members of this group are spread in these ways.  \n>[Fact sheet - Cassava green mottle (068) - pestnet.org](http://www.pestnet.org/fact_sheets/cassava_green_mottle_068.htm)"},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"cgm_df = df.loc[df['label']==2].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"img1 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cgm_df.iloc[0,0]}')\nimg2 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cgm_df.iloc[1,0]}')\nimg3 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cgm_df.iloc[2,0]}')\n\nfig, ax = plt.subplots(figsize=(20, 20))\n\nplt.subplot(1,3,1)\nplt.imshow(img1)\n\nplt.subplot(1,3,2)\nplt.imshow(img2)\n\nplt.subplot(1,3,3)\nplt.imshow(img3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Cassava Mosaic Disease (CMD)"},{"metadata":{},"cell_type":"markdown","source":"### What is Cassava Mosaic Disease (CMD)?"},{"metadata":{},"cell_type":"markdown","source":">The symptoms of CMD, first described fully by Storey and Nichols (1938), occur as characteristic leaf mosaic patterns that affect discrete areas and are determined at an early stage of leaf development. Leaf chlorosis may be pale yellow or nearly white with only a tinge of green, or just discernibly paler than normal. The chlorotic areas are usually clearly demarcated and vary in size from that of a whole leaflet to small flecks or spots. Leaflets may show a uniform mosaic pattern or the mosaic pattern is localised to a few areas which are often at the bases. Distortion, reduction in leaflet size and general stunting appear to be secondary effects associated with symptom severity.  \nSymptoms vary from leaf to leaf, shoot to shoot and plant to plant, even of the same variety and virus strain in the same locality. Variation in symptoms may be due to differences in virus strain, the sensitivity of the host genotype, plant age, and environmental factors such as soil fertility, soil moisture availability, radiation and particularly temperature.  \nSome leaves situated between affected ones may seem normal and give the appearance of recovery. This behaviour is influenced by the ambient temperature and host-plant resistance. However, symptoms may recur on recovered plants when environmental conditions again favour symptom expression (Gibson and Otim-Nape, 1997). The first few leaves produced by an infected cutting are sometimes symptomless and are subsequently followed by severely affected leaves, but there is a tendency for symptom severity to diminish as plants age, especially in resistant varieties. Symptoms tend to reappear on the axillary growth after the shoot tips are removed. De-topping is sometimes adopted to enhance expression in screening clones for resistance (Jennings, 1960).  \nPhysiological and histological examinations reveal that infected leaves have palisade cells that are either short or undifferentiated from those of the spongy mesophyll tissues (Chant and Beck, 1959). Leaves of plants affected by CMD have marked reductions and distortions of the chloroplasts, increased respiration and peroxidase activity, and decreased total carbohydrate and rates of photosynthesis. Changes have also been observed in the peroxidase isoenzyme components of CMD-affected plants (Bates and Chant, 1970; Chant et al., 1971).  \n[Cassava mosaic disease (African cassava mosaic) - CABI](https://www.cabi.org/isc/datasheet/2747)"},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"cmd_df = df.loc[df['label']==3].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":false},"cell_type":"code","source":"img1 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cmd_df.iloc[0,0]}')\nimg2 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cmd_df.iloc[1,0]}')\nimg3 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{cmd_df.iloc[2,0]}')\n\nfig, ax = plt.subplots(figsize=(20, 20))\n\nplt.subplot(1,3,1)\nplt.imshow(img1)\n\nplt.subplot(1,3,2)\nplt.imshow(img2)\n\nplt.subplot(1,3,3)\nplt.imshow(img3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Healthy"},{"metadata":{"trusted":false,"_kg_hide-input":true},"cell_type":"code","source":"heal_df = df.loc[df['label']==4].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"img1 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{heal_df.iloc[0,0]}')\nimg2 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{heal_df.iloc[1,0]}')\nimg3 = Image.open(f'../input/cassava-leaf-disease-classification/train_images/{heal_df.iloc[2,0]}')\n\nfig, ax = plt.subplots(figsize=(20, 20))\n\nplt.subplot(1,3,1)\nplt.imshow(img1)\n\nplt.subplot(1,3,2)\nplt.imshow(img2)\n\nplt.subplot(1,3,3)\nplt.imshow(img3)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}