Kaggle competition: Forest Cover Type Prediction
train = pd.read_csv(".. /input/train.csv" ).drop("ID_code",axis=1)
 y_train = train['target']
X_train = train.drop(['target'], axis = 1)
 X_test = pd.read_csv(".. /input/test.csv" ).drop("ID_code",axis=1 )<prepare_x_and_y>
dataset_train = pd.read_csv('/kaggle/input/forest-cover-type-prediction/train.csv')
 dataset_test = pd.read_csv('/kaggle/input/forest-cover-type-prediction/test.csv')
 dataset_train_copy = dataset_train.copy()
dataset_test_copy = dataset_test.copy()
sample = 0
if(sample == 1):
sample_train_0 = train[train.target == 0].sample(n = 4000, random_state = 1573456)
 sample_train_1 = train[train.target == 1].sample(n = 400, random_state = 1573456)
 train = sample_train_0.append(sample_train_1)
 y_train = sample_train['target']
X_train = sample_train.drop(['target'], axis = 1 )<normalization>
dataset_train_copy.drop('Id', axis=1, inplace=True)
 dataset_test_copy.drop('Id', axis=1, inplace=True )
mmscale = MinMaxScaler()
X_train_scaled = mmscale.fit_transform(X_train)
 X_test_scaled = mmscale.transform(X_test )<normalization>
X = dataset_train_copy.iloc[:, :-1].values
y = dataset_train_copy.iloc[:, -1].values
X_submission = dataset_test_copy.iloc[:, :].values
pca = PCA()
factors_train = pca.fit_transform(X_train_scaled)
 factors_test = pca.transform(X_test_scaled )<set_options>
sc = StandardScaler()
X_train = sc.fit_transform(X)
 X_submission = sc.transform(X_submission)
 y_train = y
explained_variance = pca.explained_variance_ratio_<create_dataframe>
classifier = RandomForestClassifier(n_estimators = 30, criterion = 'entropy', random_state = 0)
 classifier.fit(X_train, y_train )
pd.DataFrame(explained_variance,columns=['explained_variance'] ).plot(kind='box' )<count_values>
y_submission = classifier.predict(X_submission)
 dataset_submission = pd.DataFrame({'Id':dataset_test.iloc[:,0], 'Cover_Type': y_submission})
 dataset_submission.set_index('Id', inplace=True )
sum(explained_variance[:200] )<create_dataframe>
dataset_submission.to_csv('Submission.csv' )