<jupyter_start><jupyter_text>Computer Vision: Plants Classification This dataset is based on the **Plant Seedlings Dataset**, which contains images of approximately 960 unique plants belonging to 12 species at several growth stages, with a resolution of about 10 pixels per mm of annotated RGB images.The dataset includes the following species:|English     |Latin               |EPPO||:-----------|:-------------------|:---||Maize       |Zea mays L.         |ZEAMX||Common wheat|Triticum aestivum L.|TRZAX||Sugar beet|Beta vulgaris var. altissima|BEAVA||Scentless Mayweed|Matricaria perforata Mérat|MATIN||Common Chickweed|Stellaria media|STEME||Shepherd’s Purse|Capsella bursa-pastoris|CAPBP||Cleavers|Galium aparine L.|GALAP||Charlock|Sinapis arvensis L.|SINAR||Fat Hen|Chenopodium album L.|CHEAL||Small-flowered Cranesbill|Geranium pusillum|GERSS||Black-grass|Alopecurus myosuroides|ALOMY||Loose Silky-bent|Apera spica-venti|APESV|Your mission, should you choose to accept it... consist on:- create a model that classifies the full range of categories as accuretely as possible.- save the model for further analysis.If you're caught of killed during the mission, the dataen team will disavow any knowledge of your actions. This notebook will not self-destruct (disappointing right?). Good luck!<jupyter_code>%matplotlib inline

import os
import sys
from time import time
import pickle
import pathlib
import itertools
from tqdm import tqdm_notebook as tqdm
import numpy as np
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import seaborn as sns
import pandas_profiling

np.random.seed(42)<jupyter_output><empty_output><jupyter_text>1. Data Preparation 1.1 Load data<jupyter_code>PLANT_CLASSES = ['Black-grass', 'Charlock', 'Cleavers', 'Common Chickweed', 'Common wheat', 
                 'Fat Hen', 'Loose Silky-bent', 'Maize', 'Scentless Mayweed', 
                 'Shepherds Purse', 'Small-flowered Cranesbill', 'Sugar beet']
CLASSES_DICT_NAMES = {name: k for k, name in zip(range(len(PLANT_CLASSES)), PLANT_CLASSES)}
CLASSES_DICT_NUM = {k: name for k, name in zip(range(len(PLANT_CLASSES)), PLANT_CLASSES)}

DF_PART1 = "./data/plants_part1.gz"
DF_PART2 = "./data/plants_part2.gz"
DF_PART3 = "./data/plants_part3.gz"
RESHAPE_SIZE = (65, 65, 3)
RANDOM_STATE = 42

CLASSES_DICT_NAMES
df_p1 = pd.read_csv(DF_PART1)
df_p2 = pd.read_csv(DF_PART2)
df_p3 = pd.read_csv(DF_PART3)
df = pd.concat([df_p1, df_p2, df_p3], axis=0)
df.shape
df.columns[:10]<jupyter_output><empty_output><jupyter_text>We can ignore the column 'label'. The column class is the entry we must use for our classification.The rest of the columns belong to the image and we must reshape those values into 65x65x3 to obtain the images.<jupyter_code>df_labels = df[['class']]
df.drop(labels=['label', 'class'], axis=1, inplace=True)
df_images = df.values.reshape(-1, *RESHAPE_SIZE)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10906612133605999, 'fraction_numerical': 0.014996591683708248, 'mean_word_length': 5.231422505307855, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '458922', 'license': 'MIT', 'n_tokens_mistral': 1063, 'n_tokens_neox': 966, 'n_words': 296, 'path': 'computer_vision/jdr_01_CV_Plants_base.ipynb', 'repo_name': 'jgdelrio/ChallengeLearning', 'size': '2934'}