Я пытаюсь использовать xgboost
на своем ноутбуке для простой задачи классификации в Spyder IDE
. Ниже приведен код:
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets import make_classification
# Creating data
X, y = make_classification(n_classes=2, class_sep=0,
weights=0.05,0.95],n_clusters_per_class=2, n_features=3,
n_samples=10000, n_informative=2, n_redundant=0, n_repeated=0)
# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X_1 = LabelEncoder()
X[:, 1] = labelencoder_X_1.fit_transform(X[:, 1])
labelencoder_X_2 = LabelEncoder()
X[:, 2] = labelencoder_X_2.fit_transform(X[:, 2])
onehotencoder = OneHotEncoder(categorical_features = [1])
X = onehotencoder.fit_transform(X).toarray()
X = X[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
# Fitting XGBoost to the Training set
from xgboost import XGBClassifier
classifier = XGBClassifier()
#HERE THE PROBLEM !!!
classifier.fit(X_train, y_train)
# Predicting the Test set results
y_pred = classifier.predict(X_test)
print("ok")
# Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
print(cm)
# Applying k-Fold Cross Validation
from sklearn.model_selection import cross_val_score
accuracies = cross_val_score(estimator = classifier, X = X_train, y = y_train, cv = 10)
accuracies.mean()
accuracies.std()
Проблема в подходящей части: kernel
всегда умирает, почему?
Я установил Xgboost
на Windows10
, используя pip install xgboost
из Anaconda prompt
. Что я могу сделать ?
Наконец, в виртуальной машине с Ubuntu 16.04 у меня нет такой проблемы.