from sklearn.metrics import accuracy_score, precision_score, recall_score from time import time val_features_raw = pd.read_csv('val_features_raw.csv') val_features_reduced = pd.read_csv('val_features_reduced.csv') val_features_transformed = pd.read_csv('val_features_transformed.csv') val_labels = pd.read_csv('val_labels.csv') # Read in models models = {} for mdl in ['raw_original', 'raw_reduced', 'raw_transformed']: models[mdl] = joblib.load('mdl_{}_features.pkl'.format(mdl)) def evaluate_model(name, model, features, labels): start = time() pred = model.predict(features) end = time() accuracy = round(accuracy_score(labels, pred), 3) precision = round(precision_score(labels, pred), 3) recall = round(recall_score(labels, pred), 3) print('{} -- \tAccuracy: {} / Precision: {} / Recall: {} / Latency: {}ms'.format(name, accuracy, precision, recall, round((end - start)*1000, 1))) # Evaluate all of our models on the validation set evaluate_model('Raw Features', models['raw_original'], val_features_raw, val_labels) evaluate_model('reduced Features', models['raw_reduced'], val_features_reduced, val_labels) evaluate_model('Transformed Features', models['raw_transformed'], val_features_transformed, val_labels)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter