<jupyter_start><jupyter_text>To treat Null values of Credit_Product<jupyter_code>raw_Data['Credit_Product'].value_counts()
# To balance the data, lets fill NA values for Credit_Product as 'Yes'

raw_Data_treat = raw_Data.copy()
raw_Data_treat['Credit_Product'].fillna('Yes', inplace=True)<jupyter_output><empty_output><jupyter_text>Exploratroy Data Analysis - Understanding the Target Variable Trend with resepct to Features<jupyter_code># Relation between Gender and Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index()
display (b)<jupyter_output><empty_output><jupyter_text>There seems great opportunity to tap the potetial Male as well Female count which could be brought under Credit Card Business<jupyter_code># Relation between Occupation and Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Occupation','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index().sort_values(by='Occupation',ascending=False)
display (b)
# Relation between Gender, Occupation with distribution against Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Occupation','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index().sort_values(by='Occupation',ascending=False)
display (b)
sns.catplot(x="Gender", col="Occupation", hue="Is_Lead", col_wrap=4, data=raw_Data_treat, kind="count", height=3.5, aspect=.6)
plt.show()<jupyter_output><empty_output><jupyter_text>Either Entreprenuer category is least reported in the data collected or the Happy Customer Bank is not tapping potential of the category. For rest other category, even though count reported is good in terms of customer base, its ratio of turning into Credit Card business does not seem to be great.<jupyter_code># Relation between Region_Code and Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Region_Code','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index().sort_values(by=['Is_Lead','count'],ascending=False)
display (b[b['Is_Lead']==1].head())
display (b[b['Is_Lead']==1].tail())
display (b[b['Is_Lead']==0].head())
display (b[b['Is_Lead']==0].tail())
# Relation between Gender, Region_Code with distribution against Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Region_Code','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index().sort_values(by=['Is_Lead','count'],ascending=False)
display (b[b['Is_Lead']==1].head())
display (b[b['Is_Lead']==1].tail())
display (b[b['Is_Lead']==0].head())
display (b[b['Is_Lead']==0].tail())
sns.catplot(x="Gender", col="Region_Code", hue="Is_Lead", col_wrap=9, data=raw_Data_treat, kind="count", height=3.5, aspect=.6)
plt.show()<jupyter_output><empty_output><jupyter_text>Region wise Happy Customer Bank need to target Region with low 'Is_Lead = 1' count. At the same time target also need to set to convert Region with high 'Is_Lead = 0'.Compared to Region_Code like RG268, RG283, RG254 rest all regions show poor customer base. A review of marketing campaign needs to be undertaken to tap the potential.<jupyter_code># Relation between Channel_Code and Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Channel_Code','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index().sort_values(by=['Channel_Code'],ascending=False)
display (b)
# Relation between Gender, Channel_Code with distribution against Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Channel_Code','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
#b = a.copy().reset_index().sort_values(by=['Channel_Code'],ascending=False)
display (a)
sns.catplot(x="Gender", col="Channel_Code", hue="Is_Lead", col_wrap=4, data=raw_Data_treat, kind="count", height=3.5, aspect=.6)
plt.show()<jupyter_output><empty_output><jupyter_text>The channel code X4 needs to be reviewed for better reach to customer base. Channel Code X1 even though high in numbers still conversion rate seems low both with Male and Female genders. Channel code X3 seems doing fairly in terms of making people interested in Credit Card business.<jupyter_code># Relation between Gender, Credit_Product with distribution against Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Credit_Product','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index()
display (b)
sns.catplot(x="Gender", col="Credit_Product", hue="Is_Lead", col_wrap=2, data=raw_Data_treat, kind="count", height=3.5, aspect=.8)
plt.show()<jupyter_output><empty_output><jupyter_text>Other than Credit Card, there is ample opportunity available where customers can be targeted for different credit products. Looking at Credit_Product entitlement there seems fairly equal chance that a customer is also interested in Credit Card.<jupyter_code># Relation between Gender, Is_Active with distribution against Is_Lead

a = pd.DataFrame(raw_Data_treat.groupby(['Gender','Is_Active','Is_Lead'])['Is_Lead'].count())
a.columns = ['count']
a['percent'] = round(a/(a.groupby(level=1).sum())*100,2)
b = a.copy().reset_index()
display (b)
sns.catplot(x="Gender", col="Is_Active", hue="Is_Lead", col_wrap=2, data=raw_Data_treat, kind="count", height=3.5, aspect=.8)
plt.show()<jupyter_output><empty_output><jupyter_text>Customer Activity seems to have some effect on balancing out the interest ratio for Credit Card business but there is a higher number of customer base which is inactive. The Happy Customer Bank need to take up engagement programs to ensure that such customer base does transact.<jupyter_code># Relation between Age and Is_Lead with respect to Gender

a = pd.DataFrame(raw_Data_treat.groupby(['Age','Is_Lead','Gender'])['Gender'].count())
a.columns = ['gender_count']
a.head()
plt.figure(figsize=(15,5)) 
sns.lineplot(data=a, x="Age", y="gender_count", hue="Is_Lead", style="Is_Lead", markers=True, dashes=False)
plt.show()
plt.figure(figsize=(15,5)) 
sns.lineplot(data=a, x="Age", y="gender_count", hue="Gender", style="Gender", markers=True, dashes=False)
plt.show()<jupyter_output><empty_output><jupyter_text>Compared to Male, Happy Customer Bank has Female customer base starting at an early age with more number of females in the Young age group of 23-33 years of age who are interested for credit cards. The overall trend for interest in credit card seems decreasing with Age. There seems a small hike in number of Male customers at Middle age group of 35-60 years of age. The Happy Customer Bank seems popular among Young age group in terms of credit card business.<jupyter_code># Relation between Vintage and Is_Lead with respect to Gender

a = pd.DataFrame(raw_Data_treat.groupby(['Vintage','Is_Lead','Gender'])['Gender'].count())
a.columns = ['gender_count']
a.head()
plt.figure(figsize=(15,5)) 
sns.lineplot(data=a, x="Vintage", y="gender_count", hue="Is_Lead", style="Is_Lead", markers=True, dashes=False)
plt.show()
plt.figure(figsize=(15,5)) 
sns.lineplot(data=a, x="Vintage", y="gender_count", hue="Gender", style="Gender", markers=True, dashes=False)
plt.show()<jupyter_output><empty_output><jupyter_text>Similar to Age feature lower the Vintage value greater is the interest shown in Credit Card. However, this may induce a risk. Financial Institutions rely on Vintage feature, for confidence in the business/individual as it  indicates the track-record of the business/individual and commitment of the business/individual.A suggestion would be to have detailed KYC before offering credit card.<jupyter_code># Relation between Avg_Account_Balance and Is_Lead with respect to Gender

a = pd.DataFrame(raw_Data_treat.groupby(['Avg_Account_Balance','Is_Lead','Gender'])['Gender'].count())
a.columns = ['gender_count']
a.head()
plt.figure(figsize=(20,10)) 
sns.histplot(data=a, x="Avg_Account_Balance", hue="Is_Lead", multiple="dodge", bins=range(20000,10352009,100000))
plt.show()
plt.figure(figsize=(20,10)) 
sns.histplot(data=a, x="Avg_Account_Balance", hue="Gender", multiple="dodge", bins=range(20000,10352009,50000))
plt.xscale('log')
plt.show()<jupyter_output><empty_output><jupyter_text>From above data we could see most of the customers are maintaining a good average balance, however when it comes to showing interest in Credit Cards, the number seems low.A suggestion would be to put efforts to tap the potential basis Avergae Account Balance as feature.  Important FeaturesAs per above exploratory data analysis the observed features seems to beAge, Gender, Channel Code, Occupation, Credit_Product. These might not work in standalone but in combination.  Model Building<jupyter_code>raw_Data_train_Model_lb = raw_Data_treat.drop('ID', axis=1) 
# Converting categorical data to numeric using Label Encoding

def label_Encode(column):
    raw_Data_train_Model_lb[column] = raw_Data_train_Model_lb[column].astype('category').cat.codes
for column in ['Gender','Region_Code','Occupation','Channel_Code','Credit_Product','Is_Active']:
    label_Encode(column)

raw_Data_train_Model_lb.head()
X = raw_Data_train_Model_lb.drop('Is_Lead', axis=1)
y = raw_Data_train_Model_lb['Is_Lead']

train_x_lb, valid_x_lb, train_y_lb, valid_y_lb = train_test_split(X, y, test_size=0.3, random_state=7)
raw_Data_train_Model_OHE = raw_Data_treat.drop('ID', axis=1)
# Converting categorical data to numeric using One Hot Encoding

raw_Data_train_Model_OHE = pd.get_dummies(raw_Data_train_Model_OHE, columns=['Gender','Region_Code','Occupation',
                                                                             'Channel_Code','Credit_Product',
                                                                             'Is_Active'], 
                                          drop_first=False)

raw_Data_train_Model_OHE.head()
X = raw_Data_train_Model_OHE.drop('Is_Lead', axis=1)
y = raw_Data_train_Model_OHE['Is_Lead']

train_x_OHE, valid_x_OHE, train_y_OHE, valid_y_OHE = train_test_split(X, y, test_size=0.3, random_state=7)<jupyter_output><empty_output><jupyter_text>Defining a Common Function to Train the model<jupyter_code>def train_model(classifier, feature_train, label, feature_valid, valid_y):
    # fit the training dataset on the classifier
    classifier.fit(feature_train, label)
    
    # predict the labels on validation dataset
    predictions = classifier.predict(feature_valid)
    
    # calculating accuracy score
    acc_Score = accuracy_score(predictions, valid_y)
    class_Report = classification_report(valid_y, predictions)
    auc_roc_score = roc_auc_score(valid_y, predictions)
    
    return (acc_Score, class_Report, auc_roc_score)<jupyter_output><empty_output><jupyter_text>Naive Bayes Model of classification<jupyter_code># Naive Bayes on Label Encoder
acc_Score, class_Report, auc_roc_score = train_model(GaussianNB(), train_x_lb, train_y_lb, valid_x_lb, valid_y_lb)
print ("\n NB, Label Encoder Accuracy: \n", acc_Score)
print ("\n NB, Label Encoder Classification Report: \n", class_Report)
print ("\n NB, Label Encoder AUC_ROC Accuracy: \n", auc_roc_score)

# Naive Bayes on OHE
acc_Score, class_Report, auc_roc_score = train_model(GaussianNB(), train_x_OHE, train_y_OHE, valid_x_OHE, valid_y_OHE)
print ("\n NB, OHE Accuracy: \n", acc_Score)
print ("\n NB, OHE Classification Report: \n", class_Report)
print ("\n NB, OHE AUC_ROC Accuracy: \n", auc_roc_score)<jupyter_output>NB, Label Encoder Accuracy: 
 0.7561111261835644

 NB, Label Encoder Classification Report: 
               precision    recall  f1-score   support

           0       0.77      0.98      0.86     56238
           1       0.36      0.04      0.07     17480

    accuracy                           0.76     73718
   macro avg       0.56      0.51      0.46     73718
weighted avg       0.67      0.76      0.67     73718


 NB, Label Encoder AUC_ROC Accuracy: 
 0.5081208913685975

 NB, OHE Accuracy: 
 0.7562060826392468

 NB, OHE Classification Report: 
               precision    recall  f1-score   support

           0       0.77      0.98      0.86     56238
           1       0.36      0.04      0.06     17480

    accuracy                           0.76     73718
   macro avg       0.56      0.51      0.46     73718
weighted avg       0.67      0.76      0.67     73718


 NB, OHE AUC_ROC Accuracy: 
 0.5078480001998698<jupyter_text>Model Building with Linear Model for Classification<jupyter_code># Logistic Regression on Label Encoder
acc_Score, class_Report, auc_roc_score = train_model(LogisticRegression(solver='lbfgs'), train_x_lb, train_y_lb, 
                                                     valid_x_lb, valid_y_lb)
print ("\n LR, Label Encoder Accuracy: \n", acc_Score)
print ("\n LR, Label Encoder Classification Report: \n", class_Report)
print ("\n LR, Label Encoder AUC_ROC Accuracy: \n", auc_roc_score)

# Logistic Regression on OHE
acc_Score, class_Report, auc_roc_score = train_model(LogisticRegression(solver='lbfgs'), train_x_OHE, train_y_OHE, 
                                                     valid_x_OHE, valid_y_OHE)
print ("\n LR, OHE Accuracy: \n", acc_Score)
print ("\n LR, OHE Classification Report: \n", class_Report)
print ("\n LR, OHE AUC_ROC Accuracy: \n", auc_roc_score)<jupyter_output>/Users/pritigirishvankudre/opt/anaconda3/lib/python3.7/site-packages/sklearn/metrics/classification.py:1437: UndefinedMetricWarning: Precision and F-score are ill-defined and being set to 0.0 in labels with no predicted samples.
  'precision', 'predicted', average, warn_for)<jupyter_text>Model Building with Ensemble Model for Classification<jupyter_code># Random Forest on Label Encoder
acc_Score, class_Report, auc_roc_score = train_model(RandomForestClassifier(n_estimators=100), train_x_lb, 
                                                     train_y_lb, valid_x_lb, valid_y_lb)
print ("\n RF, Label Encoder Accuracy: \n", acc_Score)
print ("\n RF, Label Encoder Classification Report: \n", class_Report)
print ("\n RF, Label Encoder AUC_ROC Accuracy: \n", auc_roc_score)

# Random Forest on OHE
acc_Score, class_Report, auc_roc_score = train_model(RandomForestClassifier(n_estimators=100), train_x_OHE, 
                                                     train_y_OHE, valid_x_OHE, valid_y_OHE)
print ("\n RF, OHE Accuracy: \n", acc_Score)
print ("\n RF, OHE Classification Report: \n", class_Report)
print ("\n RF, OHE AUC_ROC Accuracy: \n", auc_roc_score)<jupyter_output>RF, Label Encoder Accuracy: 
 0.810304131962343

 RF, Label Encoder Classification Report: 
               precision    recall  f1-score   support

           0       0.86      0.90      0.88     56238
           1       0.62      0.52      0.56     17480

    accuracy                           0.81     73718
   macro avg       0.74      0.71      0.72     73718
weighted avg       0.80      0.81      0.80     73718


 RF, Label Encoder AUC_ROC Accuracy: 
 0.7092907203880077

 RF, OHE Accuracy: 
 0.8081472638975555

 RF, OHE Classification Report: 
               precision    recall  f1-score   support

           0       0.86      0.90      0.88     56238
           1       0.61      0.51      0.56     17480

    accuracy                           0.81     73718
   macro avg       0.74      0.71      0.72     73718
weighted avg       0.80      0.81      0.80     73718


 RF, OHE AUC_ROC Accuracy: 
 0.7064774388075914<jupyter_text>Defining a Common Function for GridSearchCV(The configuration of parameters is invalid in some cases so to avoid exception/value error, we have introduced error_score parameter as 0.0, default value is 'raise')<jupyter_code>def train_model_GridSearchCV(classifier, feature_train, label, feature_valid, valid_y, search_param):
    # define search
    search = GridSearchCV(classifier, search_param, scoring='roc_auc', cv=3, error_score=0.0)
    
    # execute search
    search.fit(feature_train, label)
    
    # predict the labels on validation dataset
    predictions = search.best_estimator_.predict(feature_valid)
    
    # calculating accuracy score
    auc_roc_score = search.best_score_
    best_Params = search.best_params_
    class_Report = classification_report(valid_y, predictions)
    
    return (auc_roc_score, best_Params, class_Report)<jupyter_output><empty_output><jupyter_text>GridSearchCV with Logistic Regression<jupyter_code>import warnings
warnings.filterwarnings('ignore')

# Defining search parameters for Logistic Regression
search_param = dict()
search_param['solver'] = ['newton-cg', 'lbfgs', 'liblinear']
search_param['penalty'] = ['none', 'l1', 'l2', 'elasticnet']
search_param['C'] = [0.001, 0.01, 0.1, 1, 10, 100]

# Logistic Regression on Label Encoding
auc_roc_score, best_Params, class_Report = train_model_GridSearchCV(LogisticRegression(), train_x_lb, train_y_lb, 
                                                                    valid_x_lb, valid_y_lb, search_param)
print ("\n LR, Label Encoding ROC_AUC Accuracy: \n", auc_roc_score)
print ("\n LR, Label Encoding Best Hyperparameters: \n", best_Params)
print ("\n LR, Label Encoding Classification Report: \n", class_Report)

# Logistic Regression on OHE
auc_roc_score, best_Params, class_Report = train_model_GridSearchCV(LogisticRegression(), train_x_OHE, train_y_OHE, 
                                                                    valid_x_OHE, valid_y_OHE, search_param)
print ("\n LR, OHE ROC_AUC Accuracy: \n", auc_roc_score)
print ("\n LR, OHE Best Hyperparameters: \n", best_Params)
print ("\n LR, OHE Classification Report: \n", class_Report)<jupyter_output>LR, Label Encoding ROC_AUC Accuracy: 
 0.8256070269308537

 LR, Label Encoding Best Hyperparameters: 
 {'C': 10, 'penalty': 'l1', 'solver': 'liblinear'}

 LR, Label Encoding Classification Report: 
               precision    recall  f1-score   support

           0       0.84      0.91      0.88     56238
           1       0.62      0.45      0.52     17480

    accuracy                           0.80     73718
   macro avg       0.73      0.68      0.70     73718
weighted avg       0.79      0.80      0.79     73718


 LR, OHE ROC_AUC Accuracy: 
 0.8316056004440735

 LR, OHE Best Hyperparameters: 
 {'C': 0.01, 'penalty': 'l2', 'solver': 'newton-cg'}

 LR, OHE Classification Report: 
               precision    recall  f1-score   support

           0       0.85      0.91      0.88     56238
           1       0.62      0.49      0.55     17480

    accuracy                           0.81     73718
   macro avg       0.74      0.70      0.71     73718
weighted avg       0.80      0[...]<jupyter_text>GridSearchCV with Random Forest<jupyter_code>import warnings
warnings.filterwarnings('ignore')

# Defining search parameters for Random Forest Classifier
search_param = dict()
search_param['n_estimators'] = [10, 100, 1000]
search_param['max_features'] = ['sqrt', 'log2']

# Random Forest Classifier on Label Encoding
auc_roc_score, best_Params, class_Report = train_model_GridSearchCV(RandomForestClassifier(), train_x_lb, 
                                                                    train_y_lb, valid_x_lb, valid_y_lb, 
                                                                    search_param)
print ("\n RF, Label Encoding ROC_AUC Accuracy: \n", auc_roc_score)
print ("\n RF, Label Encoding Best Hyperparameters: \n", best_Params)
print ("\n RF, Label Encoding Classification Report: \n", class_Report)

# Random Forest Classifier on OHE
auc_roc_score, best_Params, class_Report = train_model_GridSearchCV(RandomForestClassifier(), train_x_OHE, 
                                                                    train_y_OHE, valid_x_OHE, valid_y_OHE, 
                                                                    search_param)
print ("\n RF, OHE ROC_AUC Accuracy: \n", auc_roc_score)
print ("\n RF, OHE Best Hyperparameters: \n", best_Params)
print ("\n RF, OHE Classification Report: \n", class_Report)<jupyter_output>RF, Label Encoding ROC_AUC Accuracy: 
 0.8326178572183556

 RF, Label Encoding Best Hyperparameters: 
 {'max_features': 'sqrt', 'n_estimators': 1000}

 RF, Label Encoding Classification Report: 
               precision    recall  f1-score   support

           0       0.86      0.90      0.88     56238
           1       0.62      0.52      0.57     17480

    accuracy                           0.81     73718
   macro avg       0.74      0.71      0.72     73718
weighted avg       0.80      0.81      0.81     73718


 RF, OHE ROC_AUC Accuracy: 
 0.8284118652838894

 RF, OHE Best Hyperparameters: 
 {'max_features': 'sqrt', 'n_estimators': 1000}

 RF, OHE Classification Report: 
               precision    recall  f1-score   support

           0       0.86      0.90      0.88     56238
           1       0.61      0.52      0.56     17480

    accuracy                           0.81     73718
   macro avg       0.74      0.71      0.72     73718
weighted avg       0.80      0.81     [...]<jupyter_text>Predicting Is_Lead for Test Data<jupyter_code>raw_Data_test = pd.read_csv('/Users/pritigirishvankudre/DayX_Lockdown Practice/CC_Lead_Pred/test.csv')
raw_Data_test.head()
raw_Data_test.info()
raw_Data_test['Credit_Product'].fillna('Yes', inplace=True)
raw_Data_test_lb = raw_Data_test.copy()
raw_Data_test_lb.drop('ID', axis=1, inplace=True)
# Converting categorical data to numeric using Label Encoding

def label_Encode(column):
    raw_Data_test_lb[column] = raw_Data_test_lb[column].astype('category').cat.codes
# Using Label Encoding

for column in ['Gender','Region_Code','Occupation','Channel_Code','Credit_Product','Is_Active']:
    label_Encode(column)

raw_Data_test_lb.head()
raw_Data_test_OHE = raw_Data_test.copy()
raw_Data_test_OHE.drop('ID', axis=1, inplace=True)
# Converting categorical data to numeric using One Hot Encoding

raw_Data_test_OHE = pd.get_dummies(raw_Data_test_OHE, columns=['Gender','Region_Code','Occupation','Channel_Code',
                                                               'Credit_Product','Is_Active'], drop_first=False)

raw_Data_test_OHE.head()<jupyter_output><empty_output><jupyter_text>Definfing a common function to test the model<jupyter_code>def test_model(feature_valid, classifier, feature_train, label):
    # fit the training dataset on the classifier
    classifier.fit(feature_train, label)
    
    # predict the labels on validation dataset
    predictions = classifier.predict(feature_valid)
    
    return (predictions)<jupyter_output><empty_output><jupyter_text>Logistic Regression with best parameters<jupyter_code>prediction_LR_lb = test_model(raw_Data_test_lb, 
                              LogisticRegression(C=10, penalty='l1', solver= 'liblinear'), 
                              train_x_lb, train_y_lb)
raw_Data_test['Is_Lead'] = pd.DataFrame(prediction_LR_lb)
raw_Data_test.to_csv('LR_LB_CV_Test_3005_00_2200.csv', columns=['ID','Is_Lead'], header=True, index=False)
raw_Data_test.drop('Is_Lead', axis=1, inplace=True)

prediction_LR_OHE = test_model(raw_Data_test_OHE, 
                               LogisticRegression(C=0.01, penalty='l2', solver='newton-cg'), 
                               train_x_OHE, train_y_OHE)
raw_Data_test['Is_Lead'] = pd.DataFrame(prediction_LR_OHE)
raw_Data_test.to_csv('LR_OHE_CV_Test_3005_01_2200.csv', columns=['ID','Is_Lead'], header=True, index=False)
raw_Data_test.drop('Is_Lead', axis=1, inplace=True)<jupyter_output><empty_output><jupyter_text>Random Forest with best parameters<jupyter_code>prediction_RF_lb = test_model(raw_Data_test_lb, 
                              RandomForestClassifier(max_features='sqrt', n_estimators=1000), 
                              train_x_lb, train_y_lb)
raw_Data_test['Is_Lead'] = pd.DataFrame(prediction_RF_lb)
raw_Data_test.to_csv('RF_LB_CV_Test_3005_00_2200.csv', columns=['ID','Is_Lead'], header=True, index=False)
raw_Data_test.drop('Is_Lead', axis=1, inplace=True)

prediction_RF_OHE = test_model(raw_Data_test_OHE, 
                              RandomForestClassifier(max_features='sqrt', n_estimators=1000), 
                              train_x_OHE, train_y_OHE)
raw_Data_test['Is_Lead'] = pd.DataFrame(prediction_RF_OHE)
raw_Data_test.to_csv('RF_OHE_CV_Test_3005_01_2200.csv', columns=['ID','Is_Lead'], header=True, index=False)
raw_Data_test.drop('Is_Lead', axis=1, inplace=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11069182389937107, 'fraction_numerical': 0.040819638871982145, 'mean_word_length': 3.6873335869151767, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '22', 'dir': 'jupyter-structured-clean-dedup', 'id': '275764', 'license': 'MIT', 'n_tokens_mistral': 8761, 'n_tokens_neox': 7910, 'n_words': 1961, 'path': 'Hackathon_ML Sample Problems/Credit Card Lead Predict/cc_lead_pred.ipynb', 'repo_name': 'girishvankudre/hackathon_ml_sample', 'size': '24645'}