text_plain_output_1.png
from sklearn.metrics import accuracy_score

from sklearn.model_selection import KFold

from sklearn.model_selection import cross_val_score

from sklearn.model_selection import train_test_split

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import xgboost as xgb

nRowsRead = 1000
df1 = pd.read_csv('/kaggle/input/column_2C.csv', delimiter=',', nrows=nRowsRead)
df1.dataframeName = 'column_2C.csv'
nRow, nCol = df1.shape

from sklearn.model_selection import train_test_split
from sklearn import model_selection
from sklearn.metrics import accuracy_score
X = df1[['pelvic_incidence', 'pelvic_tilt', 'lumbar_lordosis_angle', 'sacral_slope', 'pelvic_radius', 'degree_spondylolisthesis']]
Y = df1['class']
seed = 2020
test_size = 0.33
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=test_size, random_state=seed)

import xgboost as xgb
model = xgb.XGBClassifier()
model.fit(X_train, y_train)
model.save_model('model.bst')

y_pred = model.predict(X_test)
predictions = [round(value) for value in y_pred]
accuracy = accuracy_score(y_test, predictions)

from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
model = xgb.XGBClassifier()
kfold = KFold(n_splits=10, random_state=2020)
results = cross_val_score(model, X, Y, cv=kfold)
print('Accuracy: %.2f%% (%.2f%%)' % (results.mean() * 100, results.std() * 100))