日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

EL之Bagging:kaggle比赛之利用泰坦尼克号数据集建立Bagging模型对每个人进行获救是否预测

發(fā)布時間:2025/3/21 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 EL之Bagging:kaggle比赛之利用泰坦尼克号数据集建立Bagging模型对每个人进行获救是否预测 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

EL之Bagging:kaggle比賽之利用泰坦尼克號數(shù)據(jù)集建立Bagging模型對每個人進行獲救是否預測

?

?

目錄

輸出結(jié)果

設(shè)計思路

核心代碼


?

?

?

輸出結(jié)果

?

設(shè)計思路

?

核心代碼

bagging_clf = BaggingRegressor(clf_LoR, n_estimators=10, max_samples=0.8, max_features=1.0, bootstrap=True, bootstrap_features=False, n_jobs=-1)bagging_clf.fit(X, y)#BaggingRegressor class BaggingRegressor Found at: sklearn.ensemble.baggingclass BaggingRegressor(BaseBagging, RegressorMixin):"""A Bagging regressor.A Bagging regressor is an ensemble meta-estimator that fits baseregressors each on random subsets of the original dataset and thenaggregate their individual predictions (either by voting or by averaging)to form a final prediction. Such a meta-estimator can typically be used asa way to reduce the variance of a black-box estimator (e.g., a decisiontree), by introducing randomization into its construction procedure andthen making an ensemble out of it.This algorithm encompasses several works from the literature. When randomsubsets of the dataset are drawn as random subsets of the samples, thenthis algorithm is known as Pasting [1]_. If samples are drawn withreplacement, then the method is known as Bagging [2]_. When random subsetsof the dataset are drawn as random subsets of the features, then the methodis known as Random Subspaces [3]_. Finally, when base estimators are builton subsets of both samples and features, then the method is known asRandom Patches [4]_.Read more in the :ref:`User Guide <bagging>`.Parameters----------base_estimator : object or None, optional (default=None)The base estimator to fit on random subsets of the dataset.If None, then the base estimator is a decision tree.n_estimators : int, optional (default=10)The number of base estimators in the ensemble.max_samples : int or float, optional (default=1.0)The number of samples to draw from X to train each base estimator.- If int, then draw `max_samples` samples.- If float, then draw `max_samples * X.shape[0]` samples.max_features : int or float, optional (default=1.0)The number of features to draw from X to train each base estimator.- If int, then draw `max_features` features.- If float, then draw `max_features * X.shape[1]` features.bootstrap : boolean, optional (default=True)Whether samples are drawn with replacement.bootstrap_features : boolean, optional (default=False)Whether features are drawn with replacement.oob_score : boolWhether to use out-of-bag samples to estimatethe generalization error.warm_start : bool, optional (default=False)When set to True, reuse the solution of the previous call to fitand add more estimators to the ensemble, otherwise, just fita whole new ensemble.n_jobs : int, optional (default=1)The number of jobs to run in parallel for both `fit` and `predict`.If -1, then the number of jobs is set to the number of cores.random_state : int, RandomState instance or None, optional (default=None)If int, random_state is the seed used by the random number generator;If RandomState instance, random_state is the random number generator;If None, the random number generator is the RandomState instance usedby `np.random`.verbose : int, optional (default=0)Controls the verbosity of the building process.Attributes----------estimators_ : list of estimatorsThe collection of fitted sub-estimators.estimators_samples_ : list of arraysThe subset of drawn samples (i.e., the in-bag samples) for each baseestimator. Each subset is defined by a boolean mask.estimators_features_ : list of arraysThe subset of drawn features for each base estimator.oob_score_ : floatScore of the training dataset obtained using an out-of-bag estimate.oob_prediction_ : array of shape = [n_samples]Prediction computed with out-of-bag estimate on the trainingset. If n_estimators is small it might be possible that a data pointwas never left out during the bootstrap. In this case,`oob_prediction_` might contain NaN.References----------.. [1] L. Breiman, "Pasting small votes for classification in largedatabases and on-line", Machine Learning, 36(1), 85-103, 1999... [2] L. Breiman, "Bagging predictors", Machine Learning, 24(2), 123-140,1996... [3] T. Ho, "The random subspace method for constructing decisionforests", Pattern Analysis and Machine Intelligence, 20(8), 832-844,1998... [4] G. Louppe and P. Geurts, "Ensembles on Random Patches", MachineLearning and Knowledge Discovery in Databases, 346-361, 2012."""def __init__(self, base_estimator=None, n_estimators=10, max_samples=1.0, max_features=1.0, bootstrap=True, bootstrap_features=False, oob_score=False, warm_start=False, n_jobs=1, random_state=None, verbose=0):super(BaggingRegressor, self).__init__(base_estimator, n_estimators=n_estimators, max_samples=max_samples, max_features=max_features, bootstrap=bootstrap, bootstrap_features=bootstrap_features, oob_score=oob_score, warm_start=warm_start, n_jobs=n_jobs, random_state=random_state, verbose=verbose)def predict(self, X):"""Predict regression target for X.The predicted regression target of an input sample is computed as themean predicted regression targets of the estimators in the ensemble.Parameters----------X : {array-like, sparse matrix} of shape = [n_samples, n_features]The training input samples. Sparse matrices are accepted only ifthey are supported by the base estimator.Returns-------y : array of shape = [n_samples]The predicted values."""check_is_fitted(self, "estimators_features_")# Check dataX = check_array(X, accept_sparse=['csr', 'csc'])# Parallel loopn_jobs, n_estimators, starts = _partition_estimators(self.n_estimators, self.n_jobs)all_y_hat = Parallel(n_jobs=n_jobs, verbose=self.verbose)(delayed(_parallel_predict_regression)(self.estimators_[starts[i]:starts[i + 1]], self.estimators_features_[starts[i]:starts[i + 1]], X) for i in range(n_jobs))# Reducey_hat = sum(all_y_hat) / self.n_estimatorsreturn y_hatdef _validate_estimator(self):"""Check the estimator and set the base_estimator_ attribute."""super(BaggingRegressor, self)._validate_estimator(default=DecisionTreeRegressor())def _set_oob_score(self, X, y):n_samples = y.shape[0]predictions = np.zeros((n_samples, ))n_predictions = np.zeros((n_samples, ))for estimator, samples, features in zip(self.estimators_, self.estimators_samples_, self.estimators_features_):# Create mask for OOB samplesmask = ~samplespredictions[mask] += estimator.predict(mask:])[(X[:features])n_predictions[mask] += 1if (n_predictions == 0).any():warn("Some inputs do not have OOB scores. ""This probably means too few estimators were used ""to compute any reliable oob estimates.")n_predictions[n_predictions == 0] = 1predictions /= n_predictionsself.oob_prediction_ = predictionsself.oob_score_ = r2_score(y, predictions)

?

?

?

?

?

總結(jié)

以上是生活随笔為你收集整理的EL之Bagging:kaggle比赛之利用泰坦尼克号数据集建立Bagging模型对每个人进行获救是否预测的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 性色欲情网站iwww九文堂 | 四虎精品欧美一区二区免费 | 中国av片 | 欧美在线一| 国产精品久久无码 | 欧美黄色一级大片 | 成人免费在线视频 | 国产免费无码一区二区视频 | 久久99成人 | 精品成人av一区二区在线播放 | 在线免费观看国产视频 | 精品欧美一区二区久久久久 | 国产三级国产精品国产专区50 | 日韩不卡一区二区 | 别揉我奶头一区二区三区 | 欧美美女在线 | 韩国性猛交╳xxx乱大交 | 中文久久久 | 久久永久免费 | 久久精品久久99 | 久久受 | 最全aⅴ番号库网 | 久草视频在线资源站 | 国产91成人 | 激情五月婷婷在线 | 一级全黄色片 | 欧美成人一二区 | 亚洲视频黄色 | 国产高清免费 | 九九九九久久久久 | 成人免费公开视频 | 国产午夜一区 | 欧美黑人粗大 | 久久精品一级片 | 国产午夜精品一区二区三区 | 久久女人网 | 经典三级av在线 | 特级西西444www大精品视频 | 免费中文字幕视频 | 五月天在线 | 欧美黑人性猛交xxxx | 奇米网久久| 国产精品扒开腿做爽爽爽视频 | a久久久久久 | 久久久久久久久国产精品一区 | 日韩高清一级片 | 中文字幕福利 | 欧美一区二区激情视频 | 91网站免费在线观看 | va视频在线观看 | 欧美一级色 | 三级福利视频 | 一本色道久久综合亚洲精品按摩 | 亚洲色图.com | 一二级毛片 | 亚洲免费久久 | 亚洲激情自拍偷拍 | 国产簧片| 性xxxx搡xxxxx搡欧美 | 国产91网址 | jzjzjzjzj亚洲成熟少妇 | 黄色大片视频网站 | 色婷婷狠 | 伊人国产视频 | 国产在线一区视频 | 日日爽天天 | 亚洲午夜精品久久久 | 天天躁狠狠躁 | 91成人黄色 | 中文字幕在线免费观看视频 | 人人人超碰 | 视频区图片区小说区 | 俄罗斯厕所偷拍 | 国产一级黄色 | 亚洲影院一区二区三区 | 少妇视频一区 | 很黄很黄的网站 | 免费网站看av | 国产精品乱码久久久久 | 综合久久中文字幕 | 2017日日夜夜 | 午夜精品网 | 亚洲区一 | 日本一区二区三区成人 | 国产精品美女久久久久久 | 久久不卡av | 日韩1区2区3区 | 国产原创中文av | 午夜日韩电影 | 亚洲妇熟xx妇色黄蜜桃 | 久久久久不卡 | 蜜桃成人在线 | 又大又长粗又爽又黄少妇视频 | 少妇性l交大片免潘金莲 | 99精品视频在线观看 | 欧美午夜精品久久久久免费视 | 性巴克成人免费网站 | 国产精选毛片 | 欧美乱大交xxxxx潮喷 |