1 Star 1 Fork 0

边沁 / reasonp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Reasonp: data analysis tool for finding reasons for changes in data

Reasonp is a data analysis tool for finding reasons for changes in data. You can use it to explore the reasons for the decline in metrics, and you can also use it to analyze the differences in metrics between different objects. With a simple operation, it can automatically search for potential causes and find inspiration for your analysis.

You need to provide a fine-grained data so that you can find the reasons for you through segmentation. For example, to analyze the fluctuation of traffic, data of various fields of each visit is required.

Example:

pip install reasonp
import reasonp as rp

traffic_data = [
    ("A", "P1", "2021-03-02", 1),
    ("B", "P1", "2021-03-02", 1),
    ("A", "P2", "2021-03-02", 1),
    ("B", "P2", "2021-03-02", 1),
    ("A", "P1", "2021-03-03", 3),
    ("B", "P1", "2021-03-03", 4),
    ("A", "P2", "2021-03-03", 1),
    ("B", "P2", "2021-03-03", 2),
    ("C", "P2", "2021-03-03", 1),
]


df = pd.DataFrame(traffic_data, columns=["source", "platform", "date", "orders"])

# You want to find the reason for the change in traffic between March 3rd and March 2nd
rdf = rp.find_reason(
        df,
        compare_column="date",
        compare_values=["2021-03-03","2021-03-02"],
        compare_metric=("orders", "sum"),
    )
print(rdf)

Check the result

search_column target_column_value compare_column_value target_metric_value compare_metric_value metric_change reason_coef
platform P1 P1 7 2 5 0.714286
source B B 6 2 4 0.571429
source A A 4 2 2 0.285714
platform P2 P2 4 2 2 0.285714
source C nan 1 0 1 0.142857

The traffic change of platform P1 may be the main reason.Because it had 5 more traffic on March 3rd than on March 2nd.

$$

reason_coef = metric_change / total_change

$$

Commands

Build

python -m build
twine upload dist/*
MIT License Copyright (c) [year] [fullname] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

分析数据变化原因的辅助工具 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/brendonlin/reasonp.git
git@gitee.com:brendonlin/reasonp.git
brendonlin
reasonp
reasonp
master

搜索帮助