INNER CODE UNIT · Python
WA
SalvatoreRa/tutorial · machine learning/scripts/MAR.py:186
WA= np.sum(WA)
print(WA)
m = [j, ms, perc, 'Mean', accuracy_score(y_test, y_test_pred), mae,
RMSR, KL, E, FR, WA, time.time() - algo_time]
results.loc[len(results)] = m
#### Imputing with the Median
# we are using here just the median, the principle is the same for the mean
# we are using the median because is common method
print('Imputation with Median')
imp = SimpleImputer(missing_values=np.nan, strategy='median')
imp.fit(X_train)
X_train_imp =imp.transform(X_train)
X_test_imp =imp.transform(X_test)
clf = xgb.XGBClassifier(random_state=42)
clf.fit(X_train_imp, y_train)