<jupyter_start><jupyter_text>Run from Here!!!!<jupyter_code>combined_train=pd.read_csv('combined_train.csv')
combined_test=pd.read_csv('combined_test.csv')
combined_train.info()
combined_train['has_repair_started'].mode()
combined_train['has_repair_started'].fillna(0.0,inplace=True)
combined_train.info()
id=combined_train['building_id']
combined_train.drop('building_id',axis=1,inplace=True)
for i in range(len(id)):
    if(pd.isnull(combined_train['count_families'][i])):
        combined_train['count_families'][i]=1
        print(i,id[i])
        break
combined_train.info()
combined_test.info()
from sklearn.preprocessing import LabelEncoder 
le=LabelEncoder()
label=le.fit_transform(combined_train['damage_grade'])
label
answer_label=pd.DataFrame(label,columns=['damage_grade'])
combined_train.drop('damage_grade',axis=1,inplace=True)
combined_train=pd.concat([combined_train,answer_label],axis=1)
combined_train.info()
area=pd.get_dummies(combined_train['area_assesed'],drop_first=True)
land=pd.get_dummies(combined_train['land_surface_condition'],drop_first=True)
foundation=pd.get_dummies(combined_train['foundation_type'],drop_first=True)
foundation.columns=['a','b','c','d']
roof=pd.get_dummies(combined_train['roof_type'],drop_first=True)
roof.columns=['e','f']
ground=pd.get_dummies(combined_train['ground_floor_type'],drop_first=True)
other=pd.get_dummies(combined_train['other_floor_type'],drop_first=True)
pos=pd.get_dummies(combined_train['position'],drop_first=True)
plan=pd.get_dummies(combined_train['plan_configuration'],drop_first=True)
cond=pd.get_dummies(combined_train['condition_post_eq'],drop_first=True)
owner=pd.get_dummies(combined_train['legal_ownership_status'],drop_first=True)
combined_train=pd.concat([combined_train,area,land,foundation,roof,ground,other,pos,plan,cond,owner],axis=1)
combined_train.drop(['area_assesed','land_surface_condition','foundation_type','roof_type','ground_floor_type','other_floor_type','position','plan_configuration','condition_post_eq','legal_ownership_status'],axis=1,inplace=True)
combined_train.info()
combined_train.info()
combined_train.info()
import seaborn as ses
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(20,20))
ses.heatmap(combined_train.corr(),cmap='coolwarm')
combined_train.drop(['E_shape','H_shape','L_shape','Multi-projected','Others','Rectangular','Square','T-shape','U-shape'],axis=1,inplace=True)
combined_train.drop(['has_secondary_use_agriculture','has_secondary_use_institution','has_secondary_use_health_post','has_secondary_use_other'],axis=1,inplace=True)
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(combined_train.drop('damage_grade',axis=1),combined_train['damage_grade'],test_size=0.01,random_state=53)
from sklearn.ensemble import RandomForestClassifier
from xgboost.sklearn import XGBClassifier
rf=RandomForestClassifier(random_state=111)
rf.fit(X_train,y_train)
print(rf.get_params)
predicted=rf.predict(X_test)
from sklearn.metrics import confusion_matrix,accuracy_score,recall_score,precision_score,f1_score
confusion_matrix(y_test,predicted)
accuracy_score(y_test,predicted)
combined_test.info()
tid=combined_test['building_id']
combined_test.drop(['damage_grade','building_id'],axis=1,inplace=True)
combined_test.info()
combined_test['has_repair_started'].mode()
combined_test['has_repair_started'].fillna(0.0,inplace=True)
combined_test.info()
area=pd.get_dummies(combined_test['area_assesed'],drop_first=True)
land=pd.get_dummies(combined_test['land_surface_condition'],drop_first=True)
foundation=pd.get_dummies(combined_test['foundation_type'],drop_first=True)
foundation.columns=['a','b','c','d']
roof=pd.get_dummies(combined_test['roof_type'],drop_first=True)
roof.columns=['e','f']
ground=pd.get_dummies(combined_test['ground_floor_type'],drop_first=True)
other=pd.get_dummies(combined_test['other_floor_type'],drop_first=True)
pos=pd.get_dummies(combined_test['position'],drop_first=True)
plan=pd.get_dummies(combined_test['plan_configuration'],drop_first=True)
cond=pd.get_dummies(combined_test['condition_post_eq'],drop_first=True)
owner=pd.get_dummies(combined_test['legal_ownership_status'],drop_first=True)
combined_test=pd.concat([combined_test,area,land,foundation,roof,ground,other,pos,plan,cond,owner],axis=1)
combined_test.drop(['area_assesed','land_surface_condition','foundation_type','roof_type','ground_floor_type','other_floor_type','position','plan_configuration','condition_post_eq','legal_ownership_status'],axis=1,inplace=True)
combined_test.drop(['E_shape','H_shape','L_shape','Multi-projected','Others','Rectangular','Square','T-shape','U-shape'],axis=1,inplace=True)
combined_test.drop(['has_secondary_use_agriculture','has_secondary_use_institution','has_secondary_use_health_post','has_secondary_use_other'],axis=1,inplace=True)
combined_train.info()
combined_test.info()
answer=rf.predict(combined_test)
answer
answer_label=le.inverse_transform(answer)
answer_label
df1=pd.DataFrame(tid,columns=['building_id'])
df1.to_csv('test_ids.csv',index=False)
tid=pd.read_csv('test_ids.csv')
df2=pd.DataFrame(answer_label,columns=['damage_grade'])
df2
output=pd.concat([tid,df2],axis=1)
output.info()
output
output.to_csv('output.csv',index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1537734064686968, 'fraction_numerical': 0.006998297711367505, 'mean_word_length': 20.495934959349594, 'pattern_counts': {'":': 0, '<': 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': '430955', 'license': 'MIT', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1928, 'n_words': 123, 'path': 'main notebook.ipynb', 'repo_name': 'mohanvamsi-1155/hackerearth_machine_learning_challenge_6', 'size': '5287'}