<jupyter_start><jupyter_text>Vamos a probar con la matriz a la que le aplicamos reducción de dimensionalidad. Arrancamos con LDA<jupyter_code># Importo paquetes

import numpy as np
import pandas as pd
import seaborn as sn
import matplotlib.pyplot as plt
%matplotlib inline

from scipy import sparse
from sklearn.preprocessing import StandardScaler
X_train = pd.read_csv("./Data/X_train_LDA.csv")
X_test = pd.read_csv("./Data/X_test_LDA.csv")
y_train = pd.read_csv("./Data/y_train.csv", header=None)
y_test = pd.read_csv("./Data/y_test.csv", header=None)
X_train.size / 1024 /1024 /1024
y_train = y_train[0]
y_test = y_test[0]
se = StandardScaler()
X_train = se.fit_transform(X_train)
X_test = se.transform(X_test)
X_train.size / 1024 /1024 /1024<jupyter_output><empty_output><jupyter_text>Modelado<jupyter_code>from sklearn.naive_bayes import BernoulliNB
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score, GridSearchCV, RandomizedSearchCV
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier, BaggingClassifier, AdaBoostClassifier
from sklearn.metrics import confusion_matrix, recall_score, accuracy_score, precision_score, roc_curve, roc_auc_score, auc
from xgboost.sklearn import XGBClassifier
import lightgbm as lgb
import scipy.stats as st
from sklearn.externals import joblib<jupyter_output><empty_output><jupyter_text>1. Naive Bayes + Regresión Logística<jupyter_code>models = [BernoulliNB(), LogisticRegression()]
params = [{},
          {'C': np.random.normal(1, 0.2, 10).astype(float) }]
grids = []
i = 0
for i in range(len(models)):
    gs = RandomizedSearchCV(models[i], params[i], n_iter = 10, scoring='roc_auc', verbose= 10, n_jobs=-1, cv=3)
    print (gs)
    fit = gs.fit(X_train, y_train)
    grids.append(fit)<jupyter_output>RandomizedSearchCV(cv=3, error_score='raise-deprecating',
          estimator=BernoulliNB(alpha=1.0, binarize=0.0, class_prior=None, fit_prior=True),
          fit_params=None, iid='warn', n_iter=10, n_jobs=-1,
          param_distributions={}, pre_dispatch='2*n_jobs',
          random_state=None, refit=True, return_train_score='warn',
          scoring='roc_auc', verbose=10)
Fitting 3 folds for each of 1 candidates, totalling 3 fits
{'fraction_non_alphanumeric': 0.10642919200695047, 'fraction_numerical': 0.023023457862728063, 'mean_word_length': 5.813609467455621, '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': '424105', 'license': 'MIT', 'n_tokens_mistral': 870, 'n_tokens_neox': 818, 'n_words': 184, 'path': '3.1.3. Modelado con LDA.ipynb', 'repo_name': 'JuanFerraro/deteccionpredadores', 'size': '2302'}