<jupyter_start><jupyter_text>IMPORT LIBRARIES<jupyter_code>import numpy as np
import pandas
import pickle
from ScoringAndEvaluation import Get_Class_Probabilities, Evaluate_Predictions
%matplotlib inline<jupyter_output><empty_output><jupyter_text>SET FILE LOCATION, LOCATION TO TEST DATA AND MODEL FILE<jupyter_code>dirpath = '..\\..\\outputs'

# Transformed test data for scoring
transformed_test_file = dirpath + "\\test_data_engineered.pkl"
inFile = open(transformed_test_file, 'rb')
testDataFrame = pickle.load(inFile)
inFile.close()

## Model files
RandomForest_model_file = dirpath + '\\CVRandomForestModel.pkl'
ElasticNet_model_file = dirpath + '\\CVElasticNetModel.pkl'

## PDF files for output of ROC plots
RandomForestROCplotpath = dirpath + '\\RandomForestROCCurve.pdf'
ElasticNetROCplotpath = dirpath + '\\ElasticNetROCCurve.pdf'<jupyter_output><empty_output><jupyter_text>PERFORM SCORING AND EVALUATION<jupyter_code># LOAD TEST DATA
y_test = testDataFrame["income"].values
X_test = testDataFrame.drop("income", axis=1)

# RANDOMFOREST MODEL
y_pred = Get_Class_Probabilities(transformed_test_file, RandomForest_model_file);
RFAuc = Evaluate_Predictions(y_pred, y_test, RandomForestROCplotpath)
print ("Random Forest AUC: " + str(round(RFAuc, 3)))

# ELASTICNET MODEL
y_pred = Get_Class_Probabilities(transformed_test_file, ElasticNet_model_file);
EnetAuc = Evaluate_Predictions(y_pred, y_test, ElasticNetROCplotpath)
print ("ElasticNet AUC: " + str(round(EnetAuc, 3)))<jupyter_output>Random Forest AUC: 0.917
ElasticNet AUC: 0.897
{'fraction_non_alphanumeric': 0.09987029831387809, 'fraction_numerical': 0.007133592736705577, 'mean_word_length': 8.1301775147929, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '2653', 'license': 'MIT', 'n_tokens_mistral': 583, 'n_tokens_neox': 551, 'n_words': 107, 'path': 'code/02_modeling/ScoringAndEvaluation.ipynb', 'repo_name': 'Azure/MachineLearningSamples-TDSPUCIAdultIncome', 'size': '1542'}