<jupyter_start><jupyter_text>Predict Trained Model on Actual Test Data<jupyter_code>import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
    sys.path.append(module_path)
    
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
import joblib
from sklearn.preprocessing import Normalizer
%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Load the saved model<jupyter_code>rf_mod = joblib.load("../models/sp_model_final.joblib")
rf_mod<jupyter_output><empty_output><jupyter_text>All good.Load the Test data from csv file<jupyter_code>df=pd.read_csv('../data/raw/test.csv')<jupyter_output><empty_output><jupyter_text>Performing basic investigation into the data<jupyter_code>df.head(5)
df.shape
df.info()
df.describe()<jupyter_output><empty_output><jupyter_text>Dropping feature columns not used in model traning<jupyter_code>df_cleaned = df.drop(['Id_old','Id', '3P Made', '3PA','3P%', 'BLK'], axis=1)
df_cleaned.shape
x=df_cleaned.copy()<jupyter_output><empty_output><jupyter_text>Applying the same Feature Scaling<jupyter_code>x = Normalizer().fit_transform(x) 
x<jupyter_output><empty_output><jupyter_text>Predict Result and Export to CSV for uploading to Kaggle<jupyter_code>y_pred=rf_mod.predict(x)
y_pred_proba=rf_mod.predict_proba(x)
np.unique(y_pred,return_counts=True)
y_pred_proba
rf_mod.classes_
df['TARGET_5Yrs'] = y_pred_proba[:,1]
df.to_csv('../data/predictions/TestResult_RF_Final.csv',index=False,columns=['Id', 'TARGET_5Yrs'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12413358538122243, 'fraction_numerical': 0.005671077504725898, 'mean_word_length': 9.114649681528663, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '424840', 'license': 'MIT', 'n_tokens_mistral': 617, 'n_tokens_neox': 609, 'n_words': 98, 'path': 'notebooks/Pitchandi_Sampath_Week1_03-predict.ipynb', 'repo_name': 'ronvoluted/kaggle-nba', 'size': '1587'}