我无法理解scikit-learn 之间roc_auc_score()和之间的区别(如果有的话)auc().
我想用不平衡的类来预测二进制输出(Y = 1时约为1.5%).
model_logit = LogisticRegression(class_weight='auto')
model_logit.fit(X_train_ridge, Y_train)
Run Code Online (Sandbox Code Playgroud)
false_positive_rate, true_positive_rate, thresholds = roc_curve(Y_test, clf.predict_proba(xtest)[:,1])
Run Code Online (Sandbox Code Playgroud)
auc(false_positive_rate, true_positive_rate)
Out[490]: 0.82338034042531527
Run Code Online (Sandbox Code Playgroud)
和
roc_auc_score(Y_test, clf.predict(xtest))
Out[493]: 0.75944737191205602
Run Code Online (Sandbox Code Playgroud)
有人可以解释这个区别吗?我以为两者都只计算ROC曲线下的面积.可能是因为数据集不平衡但我无法弄清楚原因.
谢谢!
我df.hist(columns=, by=)想在GridSpec(2,2)中插入4种不同的东西.
他们每个人都是这样的:
这是代码:
stuff = [df1, df2, df4, df3]
col = ['blue', 'orange', 'grey', 'green']
fig = plt.figure(figsize=(10,10))
gs = gridspec.GridSpec(2, 2)
for i in range(0, len(stuff)):
ax = plt.subplot(gs[i])
stuff[i].hist(column='quanti_var', by=stuff[i].quali_var, alpha=.5, color=col[i], ax=ax)
Run Code Online (Sandbox Code Playgroud)
我有以下用户警告:
C:\Anaconda3\lib\site-packages\pandas\tools\plotting.py:3234: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
"is being cleared", UserWarning)
Run Code Online (Sandbox Code Playgroud)
而不是我要找的输出:
我尝试了几件事,包括使用SubplotSpec没有成功.任何的想法 ?
谢谢你们把你的神经元借给我!
我正在尝试使用大叶草做一个choropleth ,它在GeoJSON,Pandas和传单之间提供了一个很好的链接。
GeoJSON格式如下:
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":
{
"type":"Polygon",
"coordinates":[[[-1.6704591323124895,49.62681486270549], .....
{
"insee":"50173",
"nom":"Équeurdreville-Hainneville",
"wikipedia":"fr:Équeurdreville-Hainneville",
"surf_m2":12940306}},
Run Code Online (Sandbox Code Playgroud)
熊猫DataFrame:
postal_count.head(5)
Out[98]:
Code_commune_INSEE CP_count
0 75120 723
1 75115 698
2 75112 671
3 75118 627
4 75111 622
Run Code Online (Sandbox Code Playgroud)
“ Code_communes_INSEE”对应于GeoJSON中的属性“ insee”。我想在上面的DataFrame中使用变量“ CP_count”来做一个choropleth。
这是我的代码(此笔记本的摘录)
map_france = folium.Map(location=[47.000000, 2.000000], zoom_start=6)
map_france.choropleth(
geo_str=open(geo_path + 'simplified_communes100m.json').read(),
data=postal_count,
columns=['Code_commune_INSEE', 'CP_count'],
key_on='feature.geometry.properties.insee',
fill_color='YlGn',
)
map_france.save(table_path + 'choro_test1.html')
Run Code Online (Sandbox Code Playgroud)
我仍然一次又一次收到此错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-83-ea0fd2c1c207> in <module>()
8 fill_color='YlGn',
9 ) …Run Code Online (Sandbox Code Playgroud) 我想在一个seaborn FactorPlot中可视化存储为列的2个布尔信息.
这是我的df:
我想的都可视化actual_group,并adviced_group在同一FactorPlot.
现在我只能adviced_groups使用hue参数绘图:
使用以下代码:
_ = sns.factorplot(x='groups',
y='nb_opportunities',
hue='adviced_groups',
size=6,
kind='bar',
data=df)
Run Code Online (Sandbox Code Playgroud)
我尝试使用ax.annotate()from matplotlib但没有任何成功,因为 - 据我所知 - Axes不是由sns.FactorPlot()方法处理的.
它可以是一个注释,为矩形的一个边缘着色或任何可以帮助可视化实际组的东西.
结果可能是这样的事情:
我正在尝试将 PDF 导入到 .js 文件中,以便将其Click to open pdf放入我的渲染中。
输入
import myFile from './assets/files/myfile.pdf';
Run Code Online (Sandbox Code Playgroud)
渲染
render() {
return (
...
<a href={myFile}>
<span>Click to open PDF</span>
</a>
...
)}
Run Code Online (Sandbox Code Playgroud)
错误
myProject.bundle.js:88481 ./assets/files/myfile.pdf 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
Run Code Online (Sandbox Code Playgroud)
Webpack.config.js
我尝试了几个 PDF 加载器但没有成功,下面的 webpack 使用url-loader.
const path = require('path'),
webpack = require('webpack'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin …Run Code Online (Sandbox Code Playgroud) python ×4
pandas ×3
matplotlib ×2
scikit-learn ×2
choropleth ×1
folium ×1
geojson ×1
histogram ×1
html ×1
javascript ×1
leaflet ×1
pdf ×1
reactjs ×1
scoring ×1
seaborn ×1
subplot ×1
webpack ×1