<jupyter_start><jupyter_text>different models select different rules<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
models = [
    BoostedRulesClassifier(n_estimators=5),
    RuleFitClassifier(n_estimators=10, tree_size=3, max_rules=5),
    DecisionTreeClassifier(max_depth=3)
]
for m in tqdm(models):
    try:
        m.fit(X_train, y_train, feature_names=X_train.columns)
    except:
        m.fit(X_train, y_train)
    print(m, 'acc', accuracy_score(y_test, m.predict(X_test)))
    try:
        print('\t', m.rules_)
    except:
        pass<jupyter_output>0%|          | 0/3 [00:00<?, ?it/s]<jupyter_text>the same model with slight bootstrap sampling selects different rules<jupyter_code>np.random.seed(13)
for i in tqdm(range(3)):
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=43 + i)
    m = imodels.BayesianRuleListClassifier(max_iter=10, minsupport=0.12, random_state=43 + i)
    m.fit(X_train, y_train, feature_names=X_train.columns)
    print('acc', accuracy_score(y_test, m.predict(X_test)))
np.random.seed(13)
for i in tqdm(range(3)):
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=43 + i)
    m = imodels.BayesianRuleListClassifier(max_iter=100, minsupport=0.12, random_state=43 + i)
    m.fit(X_train, y_train, feature_names=X_train.columns)
    print('acc', accuracy_score(y_test, m.predict(X_test)))
    print('rules', print(m))
np.random.seed(13)
for i in tqdm(range(3)):
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=43 + i)
    m = imodels.BayesianRuleListClassifier(max_iter=500, minsupport=0.12, random_state=43 + i)
    m.fit(X_train, y_train, feature_names=X_train.columns)
    print('acc', accuracy_score(y_test, m.predict(X_test)))
    print('rules', print(m))
np.random.seed(13)
for i in tqdm(range(3)):
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=43 + i)
    m = imodels.BayesianRuleListClassifier(max_iter=5000, minsupport=0.12, random_state=43 + i)
    m.fit(X_train, y_train, feature_names=X_train.columns)
    print('acc', accuracy_score(y_test, m.predict(X_test)))
    print('rules', print(m))<jupyter_output>33%|███▎      | 1/3 [07:48<15:36, 468.45s/it]
{'fraction_non_alphanumeric': 0.14215686274509803, 'fraction_numerical': 0.0374331550802139, 'mean_word_length': 5.100543478260869, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '406047', 'license': 'MIT', 'n_tokens_mistral': 949, 'n_tokens_neox': 904, 'n_words': 153, 'path': 'experiments/notebooks/00_unstable_models_illustration.ipynb', 'repo_name': 'BerkeleyML/imodels', 'size': '2244'}