Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
pycaret
提交
f4110d1f
pycaret
项目概览
OpenDocCN
/
pycaret
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
pycaret
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f4110d1f
编写于
1月 15, 2020
作者:
P
pycaret
提交者:
GitHub
1月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add files via upload
上级
ea33caa0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
11 deletion
+25
-11
anomaly.py
anomaly.py
+6
-4
clustering.py
clustering.py
+6
-4
nlp.py
nlp.py
+13
-3
未找到文件。
anomaly.py
浏览文件 @
f4110d1f
...
...
@@ -542,6 +542,7 @@ def assign_model(model,
return
data__
def
tune_model
(
model
=
None
,
supervised_target
=
None
,
method
=
'drop'
,
...
...
@@ -1126,7 +1127,7 @@ def tune_model(model=None,
monitor
.
iloc
[
1
,
1
:]
=
'Finalizing'
update_display
(
monitor
,
display_id
=
'monitor'
)
df
=
pd
.
DataFrame
({
'Fraction'
:
param_grid_with_zero
,
'Accuracy'
:
acc
,
'AUC'
:
auc
,
'Recall'
:
recall
,
df
=
pd
.
DataFrame
({
'Fraction
%
'
:
param_grid_with_zero
,
'Accuracy'
:
acc
,
'AUC'
:
auc
,
'Recall'
:
recall
,
'Precision'
:
prec
,
'F1'
:
f1
,
'Kappa'
:
kappa
})
sorted_df
=
df
.
sort_values
(
by
=
optimize
,
ascending
=
False
)
...
...
@@ -1135,10 +1136,10 @@ def tune_model(model=None,
best_model
=
master
[
ival
]
best_model_df
=
master_df
[
ival
]
progress
.
value
+=
1
sd
=
pd
.
melt
(
df
,
id_vars
=
[
'Fraction'
],
value_vars
=
[
'Accuracy'
,
'AUC'
,
'Recall'
,
'Precision'
,
'F1'
,
'Kappa'
],
sd
=
pd
.
melt
(
df
,
id_vars
=
[
'Fraction
%
'
],
value_vars
=
[
'Accuracy'
,
'AUC'
,
'Recall'
,
'Precision'
,
'F1'
,
'Kappa'
],
var_name
=
'Metric'
,
value_name
=
'Score'
)
fig
=
px
.
line
(
sd
,
x
=
'Fraction'
,
y
=
'Score'
,
color
=
'Metric'
,
line_shape
=
'linear'
,
range_y
=
[
0
,
1
])
fig
=
px
.
line
(
sd
,
x
=
'Fraction
%
'
,
y
=
'Score'
,
color
=
'Metric'
,
line_shape
=
'linear'
,
range_y
=
[
0
,
1
])
fig
.
update_layout
(
plot_bgcolor
=
'rgb(245,245,245)'
)
title
=
str
(
full_name
)
+
' Metrics and Fraction %'
fig
.
update_layout
(
title
=
{
'text'
:
title
,
'y'
:
0.95
,
'x'
:
0.45
,
'xanchor'
:
'center'
,
'yanchor'
:
'top'
})
...
...
@@ -1147,7 +1148,7 @@ def tune_model(model=None,
fig
.
show
()
best_k
=
np
.
array
(
sorted_df
.
head
(
1
)[
'Fraction'
])[
0
]
best_k
=
np
.
array
(
sorted_df
.
head
(
1
)[
'Fraction
%
'
])[
0
]
best_m
=
round
(
np
.
array
(
sorted_df
.
head
(
1
)[
optimize
])[
0
],
4
)
p
=
'Best Model: '
+
model_name
+
' |'
+
' Fraction %: '
+
str
(
best_k
)
+
' | '
+
str
(
optimize
)
+
' : '
+
str
(
best_m
)
print
(
p
)
...
...
@@ -1462,6 +1463,7 @@ def tune_model(model=None,
return
best_model
def
plot_model
(
model
,
plot
=
'tsne'
):
...
...
clustering.py
浏览文件 @
f4110d1f
...
...
@@ -546,6 +546,7 @@ def assign_model(model,
return
data__
def
tune_model
(
model
=
None
,
supervised_target
=
None
,
estimator
=
None
,
...
...
@@ -1102,7 +1103,7 @@ def tune_model(model=None,
monitor
.
iloc
[
1
,
1
:]
=
'Finalizing'
update_display
(
monitor
,
display_id
=
'monitor'
)
df
=
pd
.
DataFrame
({
'Clusters'
:
param_grid_with_zero
,
'Accuracy'
:
acc
,
'AUC'
:
auc
,
'Recall'
:
recall
,
df
=
pd
.
DataFrame
({
'
# of
Clusters'
:
param_grid_with_zero
,
'Accuracy'
:
acc
,
'AUC'
:
auc
,
'Recall'
:
recall
,
'Precision'
:
prec
,
'F1'
:
f1
,
'Kappa'
:
kappa
})
sorted_df
=
df
.
sort_values
(
by
=
optimize
,
ascending
=
False
)
...
...
@@ -1111,10 +1112,10 @@ def tune_model(model=None,
best_model
=
master
[
ival
]
best_model_df
=
master_df
[
ival
]
progress
.
value
+=
1
sd
=
pd
.
melt
(
df
,
id_vars
=
[
'Clusters'
],
value_vars
=
[
'Accuracy'
,
'AUC'
,
'Recall'
,
'Precision'
,
'F1'
,
'Kappa'
],
sd
=
pd
.
melt
(
df
,
id_vars
=
[
'
# of
Clusters'
],
value_vars
=
[
'Accuracy'
,
'AUC'
,
'Recall'
,
'Precision'
,
'F1'
,
'Kappa'
],
var_name
=
'Metric'
,
value_name
=
'Score'
)
fig
=
px
.
line
(
sd
,
x
=
'Clusters'
,
y
=
'Score'
,
color
=
'Metric'
,
line_shape
=
'linear'
,
range_y
=
[
0
,
1
])
fig
=
px
.
line
(
sd
,
x
=
'
# of
Clusters'
,
y
=
'Score'
,
color
=
'Metric'
,
line_shape
=
'linear'
,
range_y
=
[
0
,
1
])
fig
.
update_layout
(
plot_bgcolor
=
'rgb(245,245,245)'
)
title
=
str
(
full_name
)
+
' Metrics and Number of Clusters'
fig
.
update_layout
(
title
=
{
'text'
:
title
,
'y'
:
0.95
,
'x'
:
0.45
,
'xanchor'
:
'center'
,
'yanchor'
:
'top'
})
...
...
@@ -1123,7 +1124,7 @@ def tune_model(model=None,
fig
.
show
()
best_k
=
np
.
array
(
sorted_df
.
head
(
1
)[
'Clusters'
])[
0
]
best_k
=
np
.
array
(
sorted_df
.
head
(
1
)[
'
# of
Clusters'
])[
0
]
best_m
=
round
(
np
.
array
(
sorted_df
.
head
(
1
)[
optimize
])[
0
],
4
)
p
=
'Best Model: '
+
model_name
+
' |'
+
' Number of Clusters : '
+
str
(
best_k
)
+
' | '
+
str
(
optimize
)
+
' : '
+
str
(
best_m
)
print
(
p
)
...
...
@@ -1431,6 +1432,7 @@ def tune_model(model=None,
return
best_model
def
plot_model
(
model
,
plot
=
'cluster'
,
feature
=
None
):
...
...
nlp.py
浏览文件 @
f4110d1f
...
...
@@ -225,11 +225,21 @@ def setup(data,
try
:
import
nltk
nltk
.
download
(
'stopwords'
)
from
nltk.corpus
import
stopwords
stop_words
=
stopwords
.
words
(
'english'
)
except
:
pass
stop_words
=
[
'ourselves'
,
'hers'
,
'between'
,
'yourself'
,
'but'
,
'again'
,
'there'
,
'about'
,
'once'
,
'during'
,
'out'
,
'very'
,
'having'
,
'with'
,
'they'
,
'own'
,
'an'
,
'be'
,
'some'
,
'for'
,
'do'
,
'its'
,
'yours'
,
'such'
,
'into'
,
'of'
,
'most'
,
'itself'
,
'other'
,
'off'
,
'is'
,
's'
,
'am'
,
'or'
,
'who'
,
'as'
,
'from'
,
'him'
,
'each'
,
'the'
,
'themselves'
,
'until'
,
'below'
,
'are'
,
'we'
,
'these'
,
'your'
,
'his'
,
'through'
,
'don'
,
'nor'
,
'me'
,
'were'
,
'her'
,
'more'
,
'himself'
,
'this'
,
'down'
,
'should'
,
'our'
,
'their'
,
'while'
,
'above'
,
'both'
,
'up'
,
'to'
,
'ours'
,
'had'
,
'she'
,
'all'
,
'no'
,
'when'
,
'at'
,
'any'
,
'before'
,
'them'
,
'same'
,
'and'
,
'been'
,
'have'
,
'in'
,
'will'
,
'on'
,
'does'
,
'yourselves'
,
'then'
,
'that'
,
'because'
,
'what'
,
'over'
,
'why'
,
'so'
,
'can'
,
'did'
,
'not'
,
'now'
,
'under'
,
'he'
,
'you'
,
'herself'
,
'has'
,
'just'
,
'where'
,
'too'
,
'only'
,
'myself'
,
'which'
,
'those'
,
'i'
,
'after'
,
'few'
,
'whom'
,
't'
,
'being'
,
'if'
,
'theirs'
,
'my'
,
'against'
,
'a'
,
'by'
,
'doing'
,
'it'
,
'how'
,
'further'
,
'was'
,
'here'
,
'than'
]
from
nltk.corpus
import
stopwords
stop_words
=
stopwords
.
words
(
'english'
)
if
custom_stopwords
is
not
None
:
stop_words
=
stop_words
+
custom_stopwords
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录