<jupyter_start><jupyter_text><jupyter_code>from google.colab import drive
drive.mount('/content/drive')
try:
  # %tensorflow_version only exists in Colab.
  %tensorflow_version 2.x
except Exception:
  pass
#This is the code used for Tensorflow 2.x in Google Colab!!
# first step is to import the libraries that are currently required
import pandas as pd
import matplotlib.pyplot as plt
# x_data = range(0,l_data.shape[0]
import seaborn as sns
#LotFrontage
#LotArea
#YearBuilt
#TotalBsmtsf
#GarageArea
#PoolArea
import math
from IPython import display
from matplotlib import cm
from matplotlib import gridspec
from matplotlib import pyplot as plt
import numpy as np
from sklearn import metrics
from sklearn import preprocessing
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from keras.utils.np_utils import to_categorical # convert to one-hot-encoding
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D
from keras.optimizers import RMSprop
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
from sklearn.utils import shuffle
from tensorflow.python.data import Dataset
from sklearn.preprocessing import OneHotEncoder, LabelEncoder
pd.options.display.max_rows = 25
pd.options.display.float_format = '{:.5f}'.format
Digit_Recog_Data = pd.read_csv("/content/drive/My Drive/Digit Recog/train.csv")
Digit_Recog_TestData = pd.read_csv("/content/drive/My Drive/Digit Recog/test.csv")
Y_train = Digit_Recog_Data["label"]

# Drop 'label' column
X_train = Digit_Recog_Data.drop(labels = ["label"],axis = 1) 

X_train = X_train / 255.0
test = Digit_Recog_TestData / 255.0
X_train = X_train.values

random_seed = 4
X_train, X_test, y_train, y_test = train_test_split(X_train, Y_train, test_size = 0.2, random_state=random_seed)
rf = RandomForestClassifier(n_estimators = 100)
rf.fit(X_train, y_train)
pred = rf.predict(X_test)
test = Digit_Recog_TestData.values
testPred = rf.predict(test)
submissions=pd.DataFrame({"ImageId": list(range(1,len(testPred)+1)), "Label": testPred})
submissions.to_csv("/content/drive/My Drive/Digit Recog/Digit_Recog_5.csv", index=False, header=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08475298126064736, 'fraction_numerical': 0.011499148211243612, 'mean_word_length': 6.410094637223975, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '618911', 'license': 'MIT', 'n_tokens_mistral': 816, 'n_tokens_neox': 789, 'n_words': 214, 'path': 'Kaggle/Digit Recognizer/Digit_Recog_v5.ipynb', 'repo_name': '01-vyom/Machine-Learning-Projects', 'size': '2348'}