当前位置: 首页>>代码示例>>Python>>正文


Python CatBoostClassifier.predict_proba方法代码示例

本文整理汇总了Python中catboost.CatBoostClassifier.predict_proba方法的典型用法代码示例。如果您正苦于以下问题:Python CatBoostClassifier.predict_proba方法的具体用法?Python CatBoostClassifier.predict_proba怎么用?Python CatBoostClassifier.predict_proba使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在catboost.CatBoostClassifier的用法示例。


在下文中一共展示了CatBoostClassifier.predict_proba方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_model

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
    def create_model(self, kfold_X_train, y_train, kfold_X_valid, y_test, test):


        best = CatBoostClassifier(loss_function='MultiClassOneVsAll', learning_rate=0.07940735491731761, depth=8)
        best.fit(kfold_X_train, y_train)

        # 对验证集predict
        pred = best.predict_proba(kfold_X_valid)
        results = best.predict_proba(test)

        return pred, results, best
开发者ID:ansvver,项目名称:SOHU_competition,代码行数:13,代码来源:catboost_model.py

示例2: cleaning_comments

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
def cleaning_comments(raw_comments, path='.') -> str:
    print('start cleaning of comments...')

    raw = pd.read_csv(raw_comments)
    cleaned_comments = os.path.join(path, 'cleaned_comments.csv')
    bad_comments = os.path.join(path, 'bad_comments.csv')
    model = CatBoostClassifier().load_model(os.path.join(path, 'trash_model'))
    vectorizer = joblib.load(os.path.join(path, 'trash_vectorizer'))

    hyp = model.predict_proba(vectorizer.transform(raw.text).toarray())
    with open(cleaned_comments, 'w') as cleaned, open(bad_comments, 'w') as bad:
        bad_file = 'likes,status,text\n'
        cleaned_file = 'likes,status,text\n'
        for i in range(len(hyp)):
            if hyp[i][0] < 0.6:
                bad_file += str(raw.likes[i]) + ',1,"' + raw.text[i] + '"\n'
            else:
                cleaned_file += str(raw.likes[i]) + ',0,"' + raw.text[i] + '"\n'
        cleaned.write(cleaned_file)
        bad.write(bad_file)

    os.remove(raw_comments)

    print('end cleaning of comments...')
    return cleaned_comments
开发者ID:AnastasiaProk,项目名称:ws2018_forum_analyzer,代码行数:27,代码来源:trash_preprocessing.py

示例3: test_ntree_limit

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
def test_ntree_limit():
    train_pool = Pool(TRAIN_FILE, column_description=CD_FILE)
    test_pool = Pool(TEST_FILE, column_description=CD_FILE)
    model = CatBoostClassifier(iterations=100, random_seed=0)
    model.fit(train_pool)
    pred = model.predict_proba(test_pool, ntree_end=10)
    np.save(PREDS_PATH, np.array(pred))
    return local_canonical_file(PREDS_PATH)
开发者ID:iamnik13,项目名称:catboost,代码行数:10,代码来源:test.py

示例4: test_multiclass

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
def test_multiclass():
    pool = Pool(CLOUDNESS_TRAIN_FILE, column_description=CLOUDNESS_CD_FILE)
    classifier = CatBoostClassifier(iterations=2, random_seed=0, loss_function='MultiClass', thread_count=8)
    classifier.fit(pool)
    classifier.save_model(OUTPUT_MODEL_PATH)
    new_classifier = CatBoostClassifier()
    new_classifier.load_model(OUTPUT_MODEL_PATH)
    pred = new_classifier.predict_proba(pool)
    np.save(PREDS_PATH, np.array(pred))
    return local_canonical_file(PREDS_PATH)
开发者ID:iamnik13,项目名称:catboost,代码行数:12,代码来源:test.py

示例5: model_1

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
def model_1(X,y,test):
	'''
	This is a catBoost model where we need not to encode categorical variables.
	It automatically takes care of them.
	'''
	categorical_features_indices = np.where(X.dtypes != np.float)[0]
	X_train, X_validation, y_train, y_validation = train_test_split(X, y, train_size=0.7, random_state=1234)
	#importing library and building model
	cboost=CatBoostClassifier(iterations=500,learning=0.01,depth=6,loss_function='MultiClass',eval_metric='Accuracy')
	cboost.fit(X_train, y_train,cat_features=categorical_features_indices,eval_set=(X_validation, y_validation),plot=True)
	#calculating the class wise prediction probability of cboost model
	pred_prob=cboost.predict_proba(test)
	return pred_prob
开发者ID:99sbr,项目名称:Machine-Learning,代码行数:15,代码来源:Model.py

示例6: __init__

# 需要导入模块: from catboost import CatBoostClassifier [as 别名]
# 或者: from catboost.CatBoostClassifier import predict_proba [as 别名]
class BesCatBoost:
    """
    catboost_params = {
            'iterations': 500,
            'depth': 3,
            'learning_rate': 0.1,
            'eval_metric': 'AUC',
            'random_seed': 42,
            'logging_level': 'Verbose',
            'l2_leaf_reg': 15.0,
            'bagging_temperature': 0.75,
            'allow_writing_files': False,
            'metric_period': 50
        }
        """

    def __init__(self, params, metric='AUC', maximize=True, verbose=True, model=None):
        self.params = params
        self.metric = metric
        self.maximize = maximize
        self.verbose = verbose
        self.model = model

    def fit(self, X_train, y_train):

        bst = cv(
            Pool(X_train, y_train),
            self.params
        )

        best_rounds = int(bst['test-{}-mean'.format(self.metric)].idxmax() * 1.5) + 1
        print('Best Iteration: {}'.format(best_rounds))

        self.params['iterations'] = best_rounds
        self.model = CatBoostClassifier(**self.params)

        self.model.fit(
            X_train, y_train
        )

    def predict(self, X_test):
        pred_prob = self.model.predict_proba(X_test)[:, -1]
        return pred_prob

    def feature_importance(self):
        pass

    @staticmethod
    def find_best_params(kag):
        pass
开发者ID:Diyago,项目名称:Machine-Learning-scripts,代码行数:52,代码来源:models_zoo.py


注:本文中的catboost.CatBoostClassifier.predict_proba方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。