<jupyter_start><jupyter_text>Importing all the required libraries<jupyter_code>import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import BaggingClassifier
from sklearn.neural_network import MLPClassifier<jupyter_output><empty_output><jupyter_text>Reading the training dataset to Pandas DataFrame<jupyter_code>data = pd.read_csv('train.csv')
data.head()<jupyter_output><empty_output><jupyter_text>Getting the target variables to Y variable<jupyter_code>Y = data['Severity']
Y.shape<jupyter_output><empty_output><jupyter_text>Dropoing the irrelevent columns from training data<jupyter_code>data = data.drop(columns=['Severity','Accident_ID','Accident_Type_Code','Adverse_Weather_Metric'],axis=1)
data.head()<jupyter_output><empty_output><jupyter_text>creating the Label Encoder object which will encode the target severities to numerical form<jupyter_code>label_encode = LabelEncoder()
y = label_encode.fit_transform(Y)
x_train,x_test,y_train,y_test = train_test_split(data,y,test_size=0.3)
mlp1 = MLPClassifier(hidden_layer_sizes=(100,100,100), max_iter=500, alpha=0.0001,
                    solver='sgd', verbose=10,  random_state=21,tol=0.000000001)

mlp1.fit(x_train,y_train)
predictions = mlp1.predict(x_test)
acc1 = accuracy_score(y_test,predictions)
print('Accuracy - SGD : ',acc1)
mlp2 = MLPClassifier(hidden_layer_sizes=(100,100,100), max_iter=500, alpha=0.0001,
                    solver='lbfgs', verbose=10,  random_state=21,tol=0.000000001)

mlp2.fit(x_train,y_train)
predictions = mlp2.predict(x_test)
acc2 = accuracy_score(y_test,predictions)
print('Accuracy - LBFGS : ',acc2)
mlp3 = MLPClassifier(hidden_layer_sizes=(100,100,100), max_iter=500, alpha=0.0001,
                    solver='adam', verbose=10,  random_state=21,tol=0.000000001)

mlp3.fit(x_train,y_train)
predictions = mlp2.predict(x_test)
acc3 = accuracy_score(y_test,predictions)
print('Accuracy - ADAM : ',acc3)
test_data = pd.read_csv('test.csv')
accident_id = test_data['Accident_ID']
print(test_data.shape)
test_data = test_data.drop(columns=['Accident_ID','Accident_Type_Code','Adverse_Weather_Metric'],axis=1)
test_data.shape
predictions = bag.predict(test_data)
predictions = label_encode.inverse_transform(predictions)
result_df = pd.DataFrame({'Accident_ID':accident_id,'Severity':predictions})
result_df.head()
result_df.to_csv('Prediction.csv',index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11832669322709163, 'fraction_numerical': 0.04462151394422311, 'mean_word_length': 8.547528517110266, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '320487', 'license': 'MIT', 'n_tokens_mistral': 980, 'n_tokens_neox': 904, 'n_words': 131, 'path': 'Airplane_Accident - HackerEarth/10. HackerEarth ML - MLPClassifier.ipynb', 'repo_name': 'phileinSophos/ML-DL_Problems', 'size': '2510'}