# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import errno
import pandas as pd
import glob
import csv
import numpy as np 
import os.path
from pathlib import Path
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

print("getting ready to work with the dataset")
# get names of all csv files in this folder
csvFile = pd.read_csv("./petrophysics.csv")


# train = data[row]
# test = data[-r?ow]

# +

csvFile.drop(["latitude", "longitude", "UWI"], axis = 1, inplace = True)

# -

member = csvFile.iloc[:,-2]
csvFile.drop("member", axis = 1, inplace = True)

# +
# print(member)
dict_map = {}
count = 1
for x in member:
    if x not in dict_map:
        dict_map[x] = count
        count += 1
# print(dict_map)

i = 0
temp = []
for x in member:
    temp.append(dict_map[x])
#     i += 1

# print(temp)
csvFile["member"] = temp
pd.set_option('display.max_rows', None) 
csvFile.head()
# -

csvFile.drop("formation", axis = 1, inplace = True)


csvFile.head()

sns.pairplot(data=csvFile, hue='member')

X_train, X_test, y_train, y_test = train_test_split(csvFile.iloc[:, 0:-1], csvFile.iloc[:,-1], test_size=0.25, random_state=42)

knn = KNeighborsClassifier(n_neighbors=5, metric='euclidean')
knn.fit(X_train, y_train)


y_pred = knn.predict(X_test)





StarcoderdataJupyterScriptsDedupFiltered