<jupyter_start><jupyter_text>Training data scores<jupyter_code>(stacked_scores, stacked_cm, stacked_fi), (multi_scores, multi_cm, multi_fi) = clf.score(X_train, y_train, sample_weight=weights_train)
multi_scores["stacked model"] = stacked_scores
multi_scores
multi_cm["random forest"].sum().sum()
X_train.shape
clf.steps[-1][1].multiestimator.estimators[2]
fi = clf.steps[1][1].estimator_.feature_importances_
col = clf.steps[0][1].transform(X_test).columns
col=list(col)
fidf = pd.DataFrame(fi, index=col)
fidf.sort_values(0,ascending=False)<jupyter_output><empty_output><jupyter_text>Check on the random forest thing...<jupyter_code>import sklearn.base
import types
import copy
def fake_fit(self, *args, **kwargs):
    return self
    
rf_est = copy.deepcopy(clf.steps[1][1].estimator_)
rf_est.fit = types.MethodType(fake_fit, rf_est)
rf_fs_pipe = sklearn.pipeline.Pipeline([
    copy.deepcopy(clf.steps[0]),
    ("classification", MultiEstimator([("rf", rf_est)]))
])
rf_fs_pipe.fit(X_train, y_train, classification__sample_weight=weights_train)
def blah(*args, **kwargs):
    return None, np.zeros((153689, 153689))
permutation_importance.get_score_importances = blah
rf_fs_pipe.score(X_train, y_train, sample_weight=weights_train)
rf2_pipe = sklearn.pipeline.Pipeline(
    copy.deepcopy(clf.steps[:2]) +
    [("classification", MultiEstimator(copy.deepcopy(clf.steps[-1][1].multiestimator.estimators[:1])))
        
])
#rf2_pipe.steps[-1][1].estimators[0][1].fit = types.MethodType(fake_fit, rf2_pipe.steps[-1][1].estimators[0][1])
rf2_pipe.steps[-1][1].estimators[0][1].max_depth = 4
rf2_pipe.fit(X_train, y_train, classification__sample_weight=weights_train)
def blah(*args, **kwargs):
    return None, np.zeros((7433, 7433))
permutation_importance.get_score_importances = blah
rf2_pipe.score(X_test, y_test, sample_weight=weights_test)
transform_steps_fixed = copy.deepcopy(clf.steps[:2])
transform_steps_fixed[1][1].fit = types.MethodType(fake_fit, transform_steps_fixed[1][1])
mlp_pipe = sklearn.pipeline.Pipeline(transform_steps_fixed + [
    ("classification", MultiEstimator([("mlp", OneLayerNNClassifier(n_epochs=5000, regularization=0.01, dropout=1))]))
])
mlp_pipe.fit(X_train, y_train, classification__sample_weight=weights_train)
def blah(*args, **kwargs):
    return None, np.zeros((7405, 7405))
permutation_importance.get_score_importances = blah
mlp_pipe.score(X_test, y_test, sample_weight=weights_test)<jupyter_output>/rufous/occupancy_detection/modules/modules/build/all_of_it/lib/python3.6/site-packages/sklearn/preprocessing/label.py:128: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
  y = column_or_1d(y, warn=True)
/rufous/occupancy_detection/modules/modules/build/all_of_it/lib/python3.6/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples.
  'precision', 'predicted', average, warn_for)
/rufous/occupancy_detection/modules/modules/build/all_of_it/lib/python3.6/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples.
  'precision', 'predicted', average, warn_for)
{'fraction_non_alphanumeric': 0.13604826546003015, 'fraction_numerical': 0.02956259426847662, 'mean_word_length': 7.416243654822335, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '431502', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1182, 'n_words': 189, 'path': 'src/NHTS_worktime_Pipeline.ipynb', 'repo_name': 'NREL/TEAM-TDM', 'size': '3315'}