{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"![plant](https://images.theconversation.com/files/288176/original/file-20190815-136190-cn8sg3.jpg?ixlib=rb-1.1.0&rect=0%2C793%2C5515%2C2753&q=45&auto=format&w=1356&h=668&fit=crop)","metadata":{}},{"cell_type":"markdown","source":"#  Introduction\n**Plants are one of the most important things in the earth in anticipation, and the third thing is life on earth, there are humans and animals, both of them have rights and have many duties, so we should also give the plants the rights they want, which we must give to them, so it is no less than the other things that deserve life without the plants There are many intentions that provide many things such as oxygen and other things, so it also provides that it takes carbon dioxide, which in itself is harmful to health and causes many problems in life. We all know that the plant is not responsible for purifying the air from this harmful gas. Taking care of the plant and taking into account what it is and what we must do towards it, we turn to it and see what are the reasons that it faces in life that harm it, and we solve it as soon as possible.**","metadata":{}},{"cell_type":"markdown","source":"# **The contents of the data set**\n1. image\n2. labels","metadata":{}},{"cell_type":"markdown","source":"# Import some of libraries do we want","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt \nimport os\nimport seaborn as sns\nimport plotly.graph_objects as go\nimport cv2\nfrom skimage.io import imshow, imread, imsave","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:28.377169Z","iopub.execute_input":"2021-11-19T22:09:28.377792Z","iopub.status.idle":"2021-11-19T22:09:29.934013Z","shell.execute_reply.started":"2021-11-19T22:09:28.377677Z","shell.execute_reply":"2021-11-19T22:09:29.933021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_image_path='../input/plant-pathology-2021-fgvc8/train_images'\ntest_image_path='../input/plant-pathology-2021-fgvc8/test_images'\ndf=pd.read_csv('../input/plant-pathology-2021-fgvc8/train.csv')\nsample_submition=pd.read_csv('../input/plant-pathology-2021-fgvc8/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:29.935509Z","iopub.execute_input":"2021-11-19T22:09:29.935794Z","iopub.status.idle":"2021-11-19T22:09:29.989938Z","shell.execute_reply.started":"2021-11-19T22:09:29.935767Z","shell.execute_reply":"2021-11-19T22:09:29.988765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(10)","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:29.992267Z","iopub.execute_input":"2021-11-19T22:09:29.992725Z","iopub.status.idle":"2021-11-19T22:09:30.023231Z","shell.execute_reply.started":"2021-11-19T22:09:29.992682Z","shell.execute_reply":"2021-11-19T22:09:30.022162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.025366Z","iopub.execute_input":"2021-11-19T22:09:30.025678Z","iopub.status.idle":"2021-11-19T22:09:30.045617Z","shell.execute_reply.started":"2021-11-19T22:09:30.025647Z","shell.execute_reply":"2021-11-19T22:09:30.044178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Describe Data**","metadata":{}},{"cell_type":"code","source":"df.describe()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.047058Z","iopub.execute_input":"2021-11-19T22:09:30.047464Z","iopub.status.idle":"2021-11-19T22:09:30.114117Z","shell.execute_reply.started":"2021-11-19T22:09:30.047430Z","shell.execute_reply":"2021-11-19T22:09:30.113112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":" Show some of information about data\n","metadata":{}},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.117540Z","iopub.execute_input":"2021-11-19T22:09:30.119269Z","iopub.status.idle":"2021-11-19T22:09:30.141392Z","shell.execute_reply.started":"2021-11-19T22:09:30.119232Z","shell.execute_reply":"2021-11-19T22:09:30.140494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns ","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.143021Z","iopub.execute_input":"2021-11-19T22:09:30.143792Z","iopub.status.idle":"2021-11-19T22:09:30.159175Z","shell.execute_reply.started":"2021-11-19T22:09:30.143725Z","shell.execute_reply":"2021-11-19T22:09:30.158095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['labels'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.162413Z","iopub.execute_input":"2021-11-19T22:09:30.162827Z","iopub.status.idle":"2021-11-19T22:09:30.186785Z","shell.execute_reply.started":"2021-11-19T22:09:30.162785Z","shell.execute_reply":"2021-11-19T22:09:30.184528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['image'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.189113Z","iopub.execute_input":"2021-11-19T22:09:30.189910Z","iopub.status.idle":"2021-11-19T22:09:30.221372Z","shell.execute_reply.started":"2021-11-19T22:09:30.189855Z","shell.execute_reply":"2021-11-19T22:09:30.219442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Ploting and Show some of detilas by using histplot ","metadata":{}},{"cell_type":"code","source":"sns.histplot(df['labels'].value_counts(sort=True))","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.223367Z","iopub.execute_input":"2021-11-19T22:09:30.223800Z","iopub.status.idle":"2021-11-19T22:09:30.442387Z","shell.execute_reply.started":"2021-11-19T22:09:30.223752Z","shell.execute_reply":"2021-11-19T22:09:30.441407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"op = df['labels'].value_counts()\nfig = go.Figure(data=[go.Pie(labels=op.index,values=op.values)])\nfig.update_layout(title='Label distribution')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.443680Z","iopub.execute_input":"2021-11-19T22:09:30.443998Z","iopub.status.idle":"2021-11-19T22:09:30.572403Z","shell.execute_reply.started":"2021-11-19T22:09:30.443965Z","shell.execute_reply":"2021-11-19T22:09:30.571449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# some of comments for this plot :\nwe see here scab prasent of 44.7% and healthy 42.8% ","metadata":{}},{"cell_type":"markdown","source":"# Now we can see some of plant here and see what is the problims in here","metadata":{}},{"cell_type":"code","source":"def visualize_batch(path,image_ids, labels):\n    plt.figure(figsize=(16, 12))\n    \n    for ind, (image_id, label) in enumerate(zip(image_ids, labels)):\n        plt.subplot(3, 3, ind + 1)\n        image = cv2.imread(os.path.join(path, image_id))\n        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n\n        plt.imshow(image)\n        plt.title(f\"Class: {label}\", fontsize=12)\n        plt.axis(\"off\")\n    plt.show()\nts = df.sample(9)\nimage_ids = ts[\"image\"].values\nlabels = ts[\"labels\"].values\nvisualize_batch(train_image_path,image_ids,labels)","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:30.573762Z","iopub.execute_input":"2021-11-19T22:09:30.574308Z","iopub.status.idle":"2021-11-19T22:09:42.626311Z","shell.execute_reply.started":"2021-11-19T22:09:30.574248Z","shell.execute_reply":"2021-11-19T22:09:42.624244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submition['labels'] = sample_submition\nsample_submition.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:42.627838Z","iopub.execute_input":"2021-11-19T22:09:42.628225Z","iopub.status.idle":"2021-11-19T22:09:42.641785Z","shell.execute_reply.started":"2021-11-19T22:09:42.628188Z","shell.execute_reply":"2021-11-19T22:09:42.640650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submition.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2021-11-19T22:09:42.643176Z","iopub.execute_input":"2021-11-19T22:09:42.643753Z","iopub.status.idle":"2021-11-19T22:09:42.659719Z","shell.execute_reply.started":"2021-11-19T22:09:42.643710Z","shell.execute_reply":"2021-11-19T22:09:42.658318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}