Last active
November 2, 2022 14:39
-
-
Save SULAIMAN-5-AHMED/9c78ebb837082d1901bfdd58a1df3299 to your computer and use it in GitHub Desktop.
ML_FOR RECOMMENDER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.tree import DecisionTreeClassifier | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import accuracy_score | |
import matplotlib.pyplot as plt | |
data = pd.read_csv('music.csv') #THIS WORKS FOR SMALL DATA | |
X = data.drop(columns=['genre']) | |
y = data['genre'] | |
X_train,X_test,y_train,y_test = train_test_split(X, y, test_size=0.2) | |
model = DecisionTreeClassifier() | |
model.fit(X,y) | |
predictions = model.predict(X_test) | |
score = accuracy_score(y_test, predictions) # Accuracy of 1.0 | |
# IF THE DATA IS BIG THE SCORE MIGHT CHANGE | |
pred = model.predict([[21,1]]) | |
print(pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment