<jupyter_start><jupyter_text>Vendo as correlações<jupyter_code>aux = xdata.copy()
aux2 = xdata.copy()

aux = aux.loc[:, xdata.columns]
aux['NU_NOTA_MT'] = aux2.NU_NOTA_MT

c = aux.corr()
c.NU_NOTA_MT.sort_values()
new_vector_training = [
    'NU_NOTA_COMP1',
    'NU_NOTA_COMP2',
    'NU_NOTA_COMP4',
    'NU_NOTA_COMP5',
    'NU_NOTA_COMP3',
    'NU_NOTA_REDACAO',
    'NU_NOTA_LC',
    'NU_NOTA_CH',
    'NU_NOTA_CN',
    'NU_NOTA_MT'
]

new_vector_test = [
    'NU_INSCRICAO',
    'NU_NOTA_COMP1',
    'NU_NOTA_COMP2',
    'NU_NOTA_COMP4',
    'NU_NOTA_COMP5',
    'NU_NOTA_COMP3',
    'NU_NOTA_REDACAO',
    'NU_NOTA_LC',
    'NU_NOTA_CH',
    'NU_NOTA_CN'
]
enemTrain_data = xdata.copy()
enemTrain_data = enemTrain_data.loc[:, new_vector_training]
enemTrain_data.dropna(subset=['NU_NOTA_MT'], inplace=True)
enemTrain_data.head()
y = enemTrain_data.NU_NOTA_MT
X = enemTrain_data.drop(['NU_NOTA_MT'], axis=1)
enem_validation_data = test.copy()
enem_validation_data_1 = enem_validation_data.loc[:, new_vector_test]
enem_validation_data_2 = enem_validation_data.loc[:, new_vector_test]
enem_train_X, enem_validation_X, enem_train_y, enem_validation_y = train_test_split(X, y, random_state = 0)
model = XGBRegressor(n_estimators=200, learning_rate=0.1)
model.fit(enem_train_X, enem_train_y, early_stopping_rounds=5, eval_set=[(enem_validation_X, enem_validation_y)], verbose=False)
enem_validation_data_1.drop(['NU_INSCRICAO'], axis=1, inplace=True)
predicted_nota = model.predict(enem_validation_data_1)
result_df = pd.DataFrame({'NU_INSCRICAO': enem_validation_data_2['NU_INSCRICAO'], 'NU_NOTA_MT': predicted_nota})
result_df.head()
result_df.isnull().any().any()
result_df_final = result_df.loc[: , ['NU_INSCRICAO', 'NU_NOTA_MT']]
result_df.to_csv('answer.csv', index=False)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup