<jupyter_start><jupyter_text>**Data Overview**<jupyter_code>display(rawData.shape)
display(rawData.head())
rawData.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 6362620 entries, 0 to 6362619
Data columns (total 6 columns):
 #   Column          Dtype  
---  ------          -----  
 0   amount          float64
 1   isFraud         bool   
 2   oldbalanceDest  float64
 3   oldbalanceOrg   float64
 4   step            object 
 5   type            object 
dtypes: bool(1), float64(3), object(2)
memory usage: 297.3+ MB<jupyter_text>**Preprocess Data**<jupyter_code>#Create ColumnTransformer Preprocessor for training data
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer

numeric_features= list(X.select_dtypes(include='float64').columns)
num_transformer= StandardScaler()

cat_features= list(X.select_dtypes(exclude='float64').columns)
cat_transformer= OneHotEncoder(handle_unknown= 'ignore')

preprocessor= ColumnTransformer(transformers=[('num', num_transformer, numeric_features),
                                             ('cat', cat_transformer, cat_features)])
#Split data into X and y
X= rawData.drop(columns= 'isFraud', axis= 1)
y= rawData.loc[:, 'isFraud']

#Initialize Data object
from src.models.modeling import Data
baseData= Data(X, y)

#Take sample that mirrors target distribution


from sklearn.model_selection import train_test_split

train_test_split()
#Init base models for evaluation
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, AdaBoostClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB

baseModels= [LogisticRegression(),
            RandomForestClassifier(),
            KNeighborsClassifier(),
            GaussianNB(),
            GradientBoostingClassifier(),
            AdaBoostClassifier()]
#Init scoring for ml models
from sklearn.metrics import confusion_matrix, fbeta_score, make_scorer

scoring= {'Recall':'recall', 'F2': make_scorer(fbeta_score, beta= 2)}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09273640931932389, 'fraction_numerical': 0.021014161717679305, 'mean_word_length': 4.354523227383863, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '500097', 'license': 'MIT', 'n_tokens_mistral': 699, 'n_tokens_neox': 651, 'n_words': 161, 'path': 'notebooks/Modeling/06042021_Model_Testing_Sandbox.ipynb', 'repo_name': 'KishenSharma6/CreditFraudAnalysis', 'size': '2189'}