Git:https://github.com/linyi0604/machinelearning
I downloaded the dataset locally, and I can go to my git to get the dataset.
Xgboost
Lift classifier
belong to the integrated learning model
Combine hundreds of tree models with lower classification accuracy rates
Continually iterate, generating a new tree each iteration
Below is a prediction of the death of the Titanic.
Using the Xgboost model and other classifier performance comparisons
1 ImportPandas as PD2 fromSklearn.cross_validationImportTrain_test_split3 fromSklearn.feature_extractionImportDictvectorizer4 fromSklearn.ensembleImportRandomforestclassifier5 fromXgboostImportXgbclassifier6 7 " "8 Xgboost9 Lift ClassifierTen belong to the integrated learning model One combine hundreds of tree models with lower classification accuracy rates A continually iterate, generating a new tree each iteration - - the under the face of Titanic 's death forecast - using the Xgboost model and other classifier performance comparisons - - " " + -Titanic = Pd.read_csv (".. /data/titanic/titanic.txt") + #extract Pclass age and sex as a training sample Ax = titanic[["Pclass"," Age","Sex"]] aty = titanic["survived"] - #The average complement of the acquired age space -x[" Age"].fillna (x[" Age"].mean (), inplace=True) - - #split training data and test data -X_train, X_test, y_train, y_test =train_test_split (x, in y, -test_size=0.25, toRandom_state=33) + #extracting dictionary features for vectorization -VEC =Dictvectorizer () theX_train = Vec.fit_transform (X_train.to_dict (orient="Record")) *X_test = Vec.transform (X_test.to_dict (orient="Record")) $ Panax Notoginseng #predict with a random forest with default configuration -RFC =Randomforestclassifier () the Rfc.fit (X_train, Y_train) + Print("Stochastic forest prediction accuracy rate:", Rfc.score (X_test, Y_test))#0.7811550151975684 A the #using Xgboost model to predict +XGBC =Xgbclassifier () - Xgbc.fit (X_train, Y_train) $ Print("xgboost Forecast accuracy rate:", Xgbc.score (X_test, Y_test))#0.7872340425531915
Machine learning Path: Python practice lifting Tree xgboost classifier