小编mam*_*oku的帖子

张量流模型的超参数调整

我之前使用过Scikit-learn的GridSearchCV来优化我的模型的超参数,但只是想知道是否存在类似的工具来优化Tensorflow的超参数(例如,时期数,学习率,滑动窗口大小等)

如果没有,我如何实现一个有效运行所有不同组合的片段?

python convolution hyperparameters tensorflow

15
推荐指数
2
解决办法
1万
查看次数

使用不平衡学习库的特征重要性

imblearn库一个用于不平衡分类的库。它允许您使用scikit-learn估计器,同时使用各种方法(从欠采样到过采样到集成)平衡类。

BalancedBaggingClassifier然而,我的问题是,在使用imblearn 或任何其他采样方法后,如何获得估计器的特征重要性?

from collections import Counter
from sklearn.datasets import make_classification
from sklearn.cross_validation import train_test_split
from sklearn.metrics import confusion_matrix
from imblearn.ensemble import BalancedBaggingClassifier 
from sklearn.tree import DecisionTreeClassifier
X, y = make_classification(n_classes=2, class_sep=2,weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0, n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10)
print('Original dataset shape {}'.format(Counter(y)))
X_train, X_test, y_train, y_test = train_test_split(X, y,random_state=0)
bbc = BalancedBaggingClassifier(random_state=42,base_estimator=DecisionTreeClassifier(criterion=criteria_,max_features='sqrt',random_state=1),n_estimators=2000)
bbc.fit(X_train,y_train) 
Run Code Online (Sandbox Code Playgroud)

python classification random-forest scikit-learn imblearn

5
推荐指数
1
解决办法
3203
查看次数

Pandas DataFrame 的三次根

我了解如何计算正数和负数的立方根。但是,当尝试使用apply-lambda方法有效处理数据帧的所有元素时,我遇到了歧义问题。有趣的是,这个错误不会因相等而出现,所以我想知道代码可能有什么问题:

sample[columns]=sample[columns].apply(lambda x: (-1)*np.power(-x,1./3) if x<0 else np.power(x,1./3))
Run Code Online (Sandbox Code Playgroud)

python numpy dataframe python-3.x pandas

4
推荐指数
1
解决办法
4930
查看次数

XGBOOST:sample_Weights与scale_pos_weight

我有一个非常不平衡的数据集,我想知道在哪里可以占的权重,因此,我试图理解之间的差别scale_pos_weight在参数XGBClassifiersample_weight该参数fit的方法。如果可以同时使用它们,或者如何选择两种方法,则将对它们之间的区别提供直观的解释。

该文档表明scale_pos_weight

控制正负权重的平衡。.&典型值要考虑:和(负例)/和(正例)

例:

from xgboost import XGBClassifier
import xgboost as xgb
LR=0.1
NumTrees=1000
xgbmodel=XGBClassifier(booster='gbtree',seed=0,nthread=-1,
                       gamma=0,scale_pos_weight=14,learning_rate=LR,n_estimators=NumTrees,
                      max_depth=5,objective='binary:logistic',subsample=1)
xgbmodel.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)

要么

from xgboost import XGBClassifier
import xgboost as xgb
LR=0.1
NumTrees=1000
xgbmodel=XGBClassifier(booster='gbtree',seed=0,nthread=-1,
                       gamma=0,learning_rate=LR,n_estimators=NumTrees,
                      max_depth=5,objective='binary:logistic',subsample=1)
xgbmodel.fit(X_train, y_train,sample_weight=weights_train)
Run Code Online (Sandbox Code Playgroud)

python scikit-learn xgboost

2
推荐指数
1
解决办法
3862
查看次数

在python中指定热图的颜色增量

有没有办法在 Seaborn 或 Matplotlib 中指定热图色标的颜色增量。例如,对于包含 0-1 之间的归一化值的数据帧,要指定 100,离散的颜色增量,以便将每个值与其他值区分开来?

先感谢您

matplotlib heatmap python-3.x seaborn

1
推荐指数
1
解决办法
3185
查看次数