<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 'Grouped' k-fold CV
A quick demo by Matt
In cross-validating, we'd like to drop out one well at a time. LeaveOneGroupOut is good for this
Step1:  Isolate X and y
Step2:  We want the well names to use as groups in the k-fold analysis, so we'll get those too
Step3:  Now we train as normal, but LeaveOneGroupOut gives us the approriate indices from X and y to test against one well at a time
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
training_data = pd.read_csv('../training_data.csv')
Explanation: 'Grouped' k-fold CV
A quick demo by Matt
In cross-validating, we'd like to drop out one well at a time. LeaveOneGroupOut is good for this:
End of explanation
X = training_data.drop(['Formation', 'Well Name', 'Depth','Facies'], axis=1).values
y = training_data['Facies'].values
Explanation: Isolate X and y:
End of explanation
wells = training_data["Well Name"].values
Explanation: We want the well names to use as groups in the k-fold analysis, so we'll get those too:
End of explanation
from sklearn.svm import SVC
from sklearn.model_selection import LeaveOneGroupOut
logo = LeaveOneGroupOut()
for train, test in logo.split(X, y, groups=wells):
    well_name = wells[test[0]]
    score = SVC().fit(X[train], y[train]).score(X[test], y[test])
    print("{:>20s}  {:.3f}".format(well_name, score))
Explanation: Now we train as normal, but LeaveOneGroupOut gives us the approriate indices from X and y to test against one well at a time:
End of explanation
<END_TASK>