Package: anomeda
Introduction to Anomedaanomeda package helps you analyze non-aggregated time-series data with Python and quickly indentify important changes of your metric.Here is a brief example of howanomedacan work for you."Why has the number of our website visits decreased a week ago? What kind of users caused that?" - anomeda will answer such questions quickly by processingnon-aggregatedvisits of your website.It will show you, for instance, that users from the X country using the Y device suddenly stopped visiting your website. Not only that, even if you are not aware of any significant change of the number of visits, anomeda will highlight the cluster of events where it happened.Is it fraudulent activity, a paused marketing campaign or technical issues? It's up to you to investigate.The package is easy-to-use and adjustable enough to meet a wide range of real scenarios. The basic object,anomeda.DataFrame, inheritspandas.DataFrame, so you will find the API familiar. In addition, there are different options for fine-tuning alghorithms used under the hood.Some of whatanomedacan do for yournon-aggregated data:Highlight time points and clusters when the trend, mean or variance changedFit trends for any cluster considering the points where trends changeHighlight time points and clusters if the anomalies were observed, considering trend at that momentCompare time periods and find clusters changing the metricFind the project in itsGitHub repo.Explore theDocumentation of anomeda.Quick startLet's imagine you oversee the number of visits of a website.You have a table with visits. Typically you just aggregate them by a datetime column and monitor from 3 to 5 dashboards with overall number of visits, as well as visits of important pages, visits from specific systems, visits of specific users clustes, etc. Here is what you would do withanomeda.Let's define an anomeda object.importanomedaanomeda_df=anomeda.DataFrame(df,# pandas.DataFramemeasures_names=['country','system','url','duration'],# columns represending measures or characteristics of your eventsmeasures_types={'categorical':[;'country','system','url'],'continuous':['duration']# measures can also be continuous -  anomeda will take care of clustering them properly},index_name='date',metric_name='visit',# dummy metric, always 1agg_func='sum'# function that is used to aggregate metric)anomeda.DataFrameinheritspandas.DataFrame, so you can treat them similarly.NOTESomepandasmethods are not yet adapted foranomeda. They return a newpandas.DataFrameinstead of aanomeda.DataFrame. You just need to initialize ananomedaobject with a returned object in that case.Let's try to extract trends for important clusters from the data.trends=anomeda.fit_trends(anomeda_df,trend_fitting_conf={'max_trends':'auto','min_var_reduction':0.75},# set the number of trends automatically,# try to reduce error variance compared to error of estimating values by 1-line trend by 75%breakdown='all-clusters',# fit trends for clusters extracted from all possible sets of measuresmettic_propagte='zeros',# if some index values are missed after aggregation for a cluster, fill them with zerosmin_cluster_size=3# skip small clusters, they all will be combined into 'skipped' cluster)Typically you will see something like this:You can then plot the trends using theplot_trendsmethod. You can choose a specific cluster or plot them all together.anomeda.plot_trends(anomeda_df,clusters=['`country`=="Germany"'])The output will look like this:Of course, you may have no idea which cluster caused the problem and what to plot. Almost always you know only that there is a decrease of an overall metric and you need to find the culprits. Let's utilize another method --anomeda.compare_clusters.anomeda.compare_clusters(anomeda_df,period1='date < "2024-01-30"',period2='date >= "2024-01-30"')You see the clusters you fitted before and comparison between their characteristics. The result is quite hefty, but you can easily add your own metrics and sort clusters so that the cluster you are looking for will be on top. For example, look at how different means in the second cluster are. The second cluster corresponds to Germany (the first cluster consists of all events, so we are not interested in it now).Finally, you can check if there are any point anomalies present in any of your clusters.anomeda.find_anomalies(anomeda_df,anomalies_conf:{'p_large':1,'p_low':1,'n_neighbors':3})The output will look like this:If you plot the metric with its clusters, it would look quite reasonable.There are some nuances of how to useanomedawisely and powerfully. For example, you may use same anomeda methods simply with numpy arrays, without creating DataFrame's! See fullDocumentationfor more details and hints.Installinganomedais availale from PyPI. You may run apip installcommand:pip install anomedaAlso, theGitHub repocontains the source and built distribution files indistfolder.You must have such packages be installed:pandasnumpysklearnscipymatplotlibContributionYou are very welcome to participate in developing to the project. You may solve the current issues or add new functionality - it is up for you to decide.Here is how your flow may look like:Preparing your ForkClick ‘Fork’ on Github, creating e.g. yourname/theproject.Clone your project: git clonegit@github.com:yourname/theproject.cd theprojectCreate and activate a virtual environment.Install the development requirements: pip install -r dev-requirements.txt.Create a branch: git checkout -b my_branchMaking your ChangesMake the changesWrite tests checking your code works for different scenariousRun tests, make sure they pass.Commit your changes: git commit -m "Foo the bars"Creating Pull RequestsPush your commit to get it back up to your fork: git push origin HEADVisit Github, click handy “Pull request” button that it will make upon noticing your new branch.In the description field, write down issue number (if submitting code fixing an existing issue) or describe the issue + your fix (if submitting a wholly new bugfix).Hit ‘submit’!Reporting issuesTo report an issue, you should useIssues sectionof the project's page on Github. We will try to solve the issue as soon as possible.ContactsIf you have any questions related toanomedaproject, feel free reaching out to the author.