// Determine total number of features
total_num_features = X.shape[1]
print("num featuers")
print(total_num_features)
// Initialize weights
distance_weights = np.ones(total_num_features)
After Change
core_fit = core.fit(self.X_mat, self._y, distance_weights, self.weight_flag)
//reset distance_weights so that only previous run affects next one
distance_weights = np.ones(total_num_features)
// When all weights become 0, break
if all(w == 0 for w in core_fit.feature_importances_):