<jupyter_start><jupyter_text>2 Ejemplo <NAME><jupyter_code>import pandas as pd
NominasList = ["nomina_0_3000.csv","nomina_10001_.csv","nomina_3001_4000.csv","nomina_4001_4500.csv","nomina_4901_4999.csv","nomina_5001_7000.csv","nomina_7000_10000.csv"]
names=["Nombre", "Dependencia", "Puesto","Percepciones", "Deducciones", "Neto"]

mi_df = lambda x: pd.read_csv(x,usecols = [1,2,3,6,7,8], names = names, header=None, skiprows=2)

df_from_each_file = (mi_df(f) for f in NominasList)
#df_from_each_file = (mi_df("Dataset/"+f) for f in NominasList) #está dentro de una carpeta
nomina = pd.concat(df_from_each_file, ignore_index = True)
nomina.dtypes
nomina.plot.scatter("Percepciones","Deducciones",figsize=(12,9))
X = nomina[ ["Percepciones", "Deducciones"]].values.reshape(-1,2)
k_means = KMeans(n_clusters=2).fit(X)

centroides = k_means.cluster_centers_
etiquetas = k_means.labels_
centroides, etiquetas
color = ['r' if x else 'g' for x in etiquetas]

nomina.plot.scatter("Percepciones", "Deducciones", figsize=(12,9),c = color )
distortions = []
K = range(1,10)
for k in K:
    kmeanModel = KMeans(n_clusters=k)
    kmeanModel.fit(X)
    distortions.append(kmeanModel.inertia_)
plt.figure(figsize=(16,8))
plt.plot(K, distortions, 'bx-')
plt.xlabel('k')
plt.ylabel('Distortion')
plt.title('The Elbow ;ethod showing the optimal k')
plt.show
from sklearn.linear_model import LogisticRegression
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10).reshape(-1,1)
y = np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1])
model = LogisticRegression(solver='liblinear',random_state = 0).fit(x,y)
model.fit(x, y)
model = LogisticRegression(solver='liblinear', random_state=0).fit(x,y)
model.classes_<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15990730011587487, 'fraction_numerical': 0.05214368482039398, 'mean_word_length': 7.184834123222749, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '502557', 'license': 'MIT', 'n_tokens_mistral': 768, 'n_tokens_neox': 715, 'n_words': 130, 'path': 'Untitled7.ipynb', 'repo_name': 'Brunemer/Grafica', 'size': '1735'}