text_plain_output_1.png
from sklearn.metrics import accuracy_score

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import LabelEncoder, StandardScaler

from xgboost import XGBClassifier

import matplotlib.pyplot as plt

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

import seaborn as sns

star_data = pd.read_csv('../input/star-dataset/6 class csv.csv')

star_data.isnull().sum()

x = star_data.select_dtypes(exclude='object').drop('Star type', axis=1)
y = star_data['Star type']
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42, stratify=star_data['Star type'])
scaler = StandardScaler()
x_train_sc = scaler.fit_transform(x_train)
x_test_sc = scaler.transform(x_test)
x_train = pd.DataFrame(x_train_sc, index=x_train.index, columns=x_train.columns)
x_test = pd.DataFrame(x_test_sc, index=x_test.index, columns=x_test.columns)

xgb = XGBClassifier(n_estimators=1000, n_jobs=-1, random_state=42)
xgb.fit(x_train, y_train)
y_pred = xgb.predict(x_test)
predictions = [round(value) for value in y_pred]
accuracy = accuracy_score(y_test, predictions)
print('Accuracy: %.2f%%' % (accuracy * 100.0))