from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeClassifier import pandas as pd import numpy as np pd.options.mode.chained_assignment = None path = "F1DriversDataset.csv" required = ['Pole_Positions', 'Race_Wins', 'Podiums'] target = 'Championships' data = pd.read_csv(path) X = data[required] y = data[target] X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size=0.1, random_state=42) classifier_tree = DecisionTreeClassifier(random_state=42) classifier_tree.fit(X_train, Y_train) feature_names = required embarked_score = classifier_tree.feature_importances_[-3:].sum() scores = np.append(classifier_tree.feature_importances_[:2], embarked_score) scores = map(lambda score: round(score, 2), scores) print(dict(zip(feature_names, scores))) print("Оценка качества: ", classifier_tree.score(X_test, Y_test))