Commit 84329738 authored by Leodegario Lorenzo II's avatar Leodegario Lorenzo II
Browse files

Add get included features from regularization function

parent 82050193
......@@ -508,6 +508,14 @@ class MLModels:
# Show figure
def get_included_features(self, setting, tol=1e-7):
"""Return the included features during regularization given setting"""
# Get setting index
setting_num = self._setting.index(setting)
return self.feature_names[
(np.abs(self.all_coef) > 1e-7)[setting_num, :]]
def plot_accuracy_num_features(self, num_pts=None, tol=1e-7):
Plot the accuracy versus numbe of features used in L1/L2 reg
......@@ -835,6 +843,13 @@ class MLModels:
stratify=stratify, smote=smote,
test_size=test_size, scaling=scaling)
# Set feature names
if feature_names is not None:
m.feature_names = np.array(feature_names)
m.feature_names = np.array(
list(map(str, range(X.shape[1]))))
# Append result
trained_methods[k] = m
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment