gpt4 book ai didi

wolfram-mathematica - 我可以使用 Stackoverflow API 检查哪些 SO 回答者 sleep 不足?

转载 作者:行者123 更新时间:2023-12-03 20:48:06 31 4
gpt4 key购买 nike

how-do-i-access-the-stackoverflow-api-from-mathematica我概述了如何使用 SO API 让 Mathematica 制作一些有趣的顶级回答者声誉图。这个 API 是否也可以用来提供一些关于回答者夜间习惯的侵犯隐私的见解?

最佳答案

当然,例如使用这个 MMA8 代码:

getActionDates[userID_Integer] :=
Module[{total},
total =
"total" /.
Import["http://api.stackoverflow.com/1.1/users/" <>
ToString[userID] <> "/timeline?pagesize=1&page=1", "JSON"];
DateList[# + AbsoluteTime["January 1, 1970"]] & /@ Join @@
Table[
"creation_date" /. ("user_timelines" /.
Import["http://api.stackoverflow.com/1.1/users/" <>
ToString[userID] <> "/timeline?pagesize=100&page=" <>
ToString[p], "JSON"])
, {p, Ceiling[total/100]}
]
]

makeWeekHistogram[userID_Integer] :=
Module[{dates2Positions},
dates2Positions =
ToExpression[
DateString[#, {"{", "DayNameShort", "+", "Hour", "+", "Minute",
"/60./.{Sun->0,Mon->24,Tue->2*24,Wed->3*24,Thu->4*24,Fri->5*\
24,Sat->6*24}}"}]] & /@ getActionDates[userID] // Flatten;
Histogram[dates2Positions, {1}, "Count",
GridLines -> {Table[24 i, {i, 1, 6}], None},
BaseStyle -> {FontFamily -> "Arial-Bold", FontSize -> 16},
FrameTicks -> {{Automatic,
None}, {{{12, "Sun"}, {24 + 12, "Mon"}, {2 24 + 12,
"Tue"}, {3 24 + 12, "Wed"}, {4 24 + 12, "Thu"}, {5 24 + 12,
"Fri"}, {6 24 + 12, "Sat"}}, None}},
FrameLabel -> {"Day of week", "Number of actions",
First["display_name" /. ("users" /.
Import["http://api.stackoverflow.com/1.1/users/" <>
ToString[userID], "JSON"])], ""}, Frame -> True,
PlotRangePadding -> 0]
]

makeDayHistogram[userID_Integer] :=
Module[{dates2Positions},
dates2Positions =
ToExpression[DateString[#, {"Hour", "+", "Minute", "/60."}]] & /@
getActionDates[userID] // Flatten;
Histogram[dates2Positions, {1}, "Count",
FrameTicks -> {{Automatic,
None}, {Table[{i + 0.5, i}, {i, 0, 20, 5}], None}},
BaseStyle -> {FontFamily -> "Arial-Bold", FontSize -> 16},
FrameLabel -> {"Hour", "Number of actions",
First["display_name" /. ("users" /.
Import["http://api.stackoverflow.com/1.1/users/" <>
ToString[userID], "JSON"])], ""}, Frame -> True,
PlotRangePadding -> 0]
]

当然,我们只有服务器时间和日期,但模式应该说明本地化,不是吗?虽然……巫师先生……你没有生命!
makeWeekHistogram[353410]

enter image description here

enter image description here

enter image description here

编辑
Mr.Wizard 请求的每小时直方图:

enter image description here

关于wolfram-mathematica - 我可以使用 Stackoverflow API 检查哪些 SO 回答者 sleep 不足?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5845436/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com