GithubHelp home page GithubHelp logo

misken / hillmaker Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 4.0 37.94 MB

Occupancy analysis by time of day and day of week, with Python

License: MIT License

Python 59.84% Jupyter Notebook 38.05% Shell 0.27% TeX 1.84%

hillmaker's People

Contributors

hlasse avatar jwnorm avatar misken avatar mstimberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hillmaker's Issues

Add version info function

Something like the one in pydantic which can be used like this:

python -c "import pydantic.utils; print(pydantic.utils.version_info())":

Plot export fails if no category field specified

If the optional category field is not specified, then the plots fail with:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[11], line 1
----> 1 results_ex1 = hm.make_hills(scenario, stops_df, in_field, out_field,
      2                             start_date, end_date,
      3                             bin_size_minutes=bin_size_mins,
      4                             output_path=output_path,
      5                             export_dow_png=True,
      6                             export_week_png=True,
      7                             xlabel='xlabel',
      8                             ylabel='ylabel')

File ~\Anaconda3\envs\aap\Lib\site-packages\hillmaker\hills.py:252, in make_hills(scenario_name, stops_df, in_field, out_field, start_analysis_dt, end_analysis_dt, cat_field, bin_size_minutes, percentiles, cats_to_exclude, occ_weight_field, totals, cap, nonstationary_stats, stationary_stats, no_censored_departures, export_bydatetime_csv, export_summaries_csv, export_dow_png, export_week_png, xlabel, ylabel, output_path, edge_bins, verbosity)
    250 if export_week_png:
    251     with HillTimer() as t:
--> 252         for metric in summary_dfs['nonstationary']['dow_binofday']:
    253             fullwk_df = summary_dfs['nonstationary']['dow_binofday'][metric]
    254             fullwk_df = fullwk_df.reset_index()

KeyError: 'dow_binofday'

Add CLI

Only key parameters should be included in CLI.

use pathlib

Check all path related stuff and convert to using pathlib

Add alpha as a parameter for plotting API

As I am working through some plots today, the full opacity of the bar color clashes with the ggplot plot style. Realized that there is not many bar kwargs exposed, so feel that adding alpha as a param is necessary.

Add option to add categories to plotting API

I did something like this already in a Jupyter Notebook, just need to decide the best way to integrate it into the package. Ideally, I would like it to be something as simple as by_category=True in the existing functions/methods (like in the other OO functions), but the code may be too verbose and might require a separate, make_stacked_hills function or something.

Add plots and/or plot templates

Create some combination of plots that can automatically be generated and also some sort of "plot template" (i.e. Python code) that makes it easy to create customized plots.

Could also explore the broader landscape of data viz tools to see how they might be used with hillmaker outputs.

Efficient updating of bydatetime table

Current looping-centric approach with repeated use of .ix is order of magnitude slower than VBA version. Looking into new multi-index slicers added in pandas 0.14.0.

Add GUI

This is related to PR #39, but retroactively adding an issue for documentation purposes. The current PR will likely need heavy refactoring based on all of the API changes made recently.

Warmup and horizon effects validation

Does it make sense to add a validation check to make_hills that determines the length of warmup and horizon effects based on a rule?

The rule could be based on some combination of LOS and the number of days in the supplied date range. As an example, I am imagining it would compute the 75th percentile of LOS and then automatically adjust the start and end date based on this number. If the date range is quite large, the adjustment can be multiplied by a factor of 5 or something.

The main driver behind this is that casual users of the application might not fully grasp the implication of these effects and providing that adjustment for them could avoid misleading data. Of course, users who fully understand the concepts of these effects could opt to adjust the date range manually and could turn off this functionality with a simple validate_warmup_horizon_effects=False.

datetime input and argument passing

Datetimes in csv are text. Conversion to appropriate data type (pandas Timestamp) should happen at read time. However, what to do about the start and end analysis values used in arguments to hillmaker() main function? They need to be converted to pandas Timestamps before use in comparisons with other Timestamps. Do we force arguments to be Timestamps or try to convert them?

Should we flatten multi-index of results dataframes?

Right now, the summary dataframe has a multi-index:

day_of_week | dow_name | bin_of_day | bin_of_day_str | ย 

This makes it painful to select specific rows (e.g. Monday). If we flatten the index and stick the levels as regular columns, it will be much easier to select some subset of rows. In the plotting code, we flatten the index to make it easy to make the plot.

What do you think @jwnorm ?

Add input validation

Check if:

  • in and out cols are part of df
  • end analysis date is after start analysis date
  • cat field is part of df

Create general data parameter to handle both csv and DataFrame inputs

By replacing the stops_df and stop_data_csv parameters with a single data parameter, we can move towards more general handling of different kinds of data inputs. Also makes it easier to process inputs since won't have to worry about what to do in case both parameters are used simultaneous (i.e. who gets precedence?).

Application settings file?

It might make sense to store application settings such as some of the key parameter defaults in a file instead of them being scattered throughout the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.