I'm a beginner in Machine Learning and I'm learning through the Kaggle competitions. I've started off with the Titanic competition and now I'm trying to measure the accuracy of my prediction with the scikit-learn accuracy_score
function but the output does not really make sense. Here is the output I am getting:
[1. 0. 1. 0. 1. 0. 0. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
1. 0. 1. 1. 0. 0. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 0. 1. 0. 1.]
<function accuracy_score at 0x000001AA46EFBD90>
And here is my code:
*imports have been omitted to avoid crowding
train_path = "C:\\Users\\Omar\\Downloads\\Titanic Data\\train.csv"
train_data = pd.read_csv(train_path)
train_data['Sex'] = pd.factorize(train_data.Sex)[0]
columns_of_interest = ['Survived','Pclass', 'Sex', 'Age']
filtered_titanic_data = train_data.dropna(axis=0)
x = filtered_titanic_data[columns_of_interest]
y = filtered_titanic_data.Survived
train_x, val_x, train_y, val_y = train_test_split(x, y, random_state=0)
titanic_model = DecisionTreeRegressor()
titanic_model.fit(train_x, train_y)
val_predictions = titanic_model.predict(val_x)
accuracy_score(val_y, val_predictions)
print(val_predictions)
print(accuracy_score)
You need to print the results of the accuracy_score(val_y, val_predictions)
line.
e.g. print(accuracy_score(val_y, val_predictions))