GithubHelp home page GithubHelp logo

arielf / weight-loss Goto Github PK

View Code? Open in Web Editor NEW
3.3K 3.3K 153.0 1.11 MB

Machine Learning meets ketosis: how to effectively lose weight

License: Other

Makefile 15.08% R 21.83% Perl 17.84% Shell 2.91% HTML 2.16% Python 40.19%

weight-loss's People

Contributors

arielf avatar pgilad avatar piyush-555 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weight-loss's Issues

How-To Section

Hi there,

Great work, really admired what you've done here. But for the someone who doesn't know a thing about machine learning, it could be great to have step-by-step reproduction of this mechanism.

Thanks a lot

RE: Please Update with most recent data

While recently listening to a number of people give contradictory health information, I had a co-worker and friend tell me I should start performing my own measurements based on my intake and exercise and find out what does and doesn't work.

I thought about this and decided, after a recent conference, that I needed to apply machine learning to the problem. I'd like to hear more about your current progress or regressions, and see what updates you have in the way of insight you've gained since your last commit.

Relevant Issue

What is the cycling travel distance?

It should also be possible to cut fat and maintain carbs with adequate physical training. So I am curious, what is the cycling distance each day?

confidence levels

Given the size of the data set and the outputted attributions/predictions it would be helpful to know what the confidence levels are.

Request for details about the specific algorithm used

This is not an issue but a request to get details about what specific machine learning algorithm was used. This would help in cases where one would want to consider using a different ml package perhaps. Also it would be of great help to the uninitiated if details could be provided about what does the algorithm do.

Thanks

Age constant

I was thinking if age matters on output ? If yes, how do you suggest to age constant into formula ?

Coffee

Could you briefly explain why coffee is not in the graph? Do you entirely drink tea/no tea? If not, would you say anything significant about coffee vs tea?

It might not be a primary contributor to weight results, but as secondary I am interested to see if there are any possible conclusions to draw from.

my fitness pal as data store

Is there a way to use myfitnesspal as a data store as well?
I keep track there of what I eat and how much.
I have started to track my weight there as well.
I'd like to learn which foods are helping and which not so much.
Is there a different app which has a better API?

I am using google fit to automatically record my walking and cycling.
I use Sleep as Android to record my sleep.

I realize that to test some of the current hypotheses, I may have to keep track of additional data, such as the time I eat my meals.

Are there clear enough APIs to be able to do this kind of machine learning?

Breakfast

First - thanks a lot for sharing that! This is very inspiring :)

Question: many people (and research) say breakfast (breaking fasting :) ) is the most important meal of the day. What are you thoughts on that?

Making sense of the results

I think I must have collected the data wrong, but here's the SO question.

https://stats.stackexchange.com/questions/298151/making-sense-of-the-results-of-machine-learning-feature-selection

Here's an example of the data format I tried to mimic (ariel.csv)

Date,MorningWeight,YesterdayFactors
2012-06-01,186.8,
2012-06-10,185.9,
2012-06-11,182.6,salad sleep:0.15 cheese egg halfnhalf:1.5
2012-06-12,181.0,sleep:0.5 tea grape
2012-06-13,183.6,bagel bread date:1.5 dietsnapple splenda pizza nosleep:0.2
2012-06-14,183.7,coffeecandy cheese rice salmon peanut bread

Here's what my data looks like

date,trophies,characters
# NescalRdical UQP2UYLR
2017-07-26,0,
# friendly battle 3200 3200
# friendly battle 3200 3200
# friendly battle 3200 3200
# friendly battle 3200 3200
# friendly battle 3200 3200
2017-07-26,0,miner2 minion_horde12 electro_wizard2 the_log2 hog_rider8 snow_spirits9 princess2 zap11
# ARTURO QRPRCU2J
2017-07-26,-25,
# friendly battle 4025 4025
# friendly battle 4025 4025
2017-07-26,-25,goblin_gang12 barbarians12 minion_horde12 wizard9 miner2 giant9 zap12 mini_pekka9
2017-07-26,0,skeleton_horde4 goblin_gang11 rocket9 minion12 prince6 goblin_barrel5 princess1 zap12
2017-07-26,-25,goblin_gang11 archers12 rocket8 rage5 wizard9 chr_balloon6 angry_barbarian12 zap11
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
# friendly battle 3996 3996
2017-07-26,-50,fire_fireball9 baby_dragon6 rage5 minion_horde12 freeze6 angry_barbarian13 zap11 inferno_dragon2
# friendly battle 3966 3966
2017-07-26,-75,executioner5 rage6 tornado6 electro_wizard2 angry_barbarian13 hog_rider9 bomber13 the_log2
2017-07-26,-50,skeleton_horde6 valkyrie9 electro_wizard2 the_log2 hog_rider9 goblin_barrel6 ice_wizard2 princess2
2017-07-26,-25,goblin_gang12 firespirit_hut9 minion11 valkyrie8 musketeer9 lightning6 royal_giant12 zap12
# tilted23 289CVLCY9
2017-07-26,-50,
# friendly battle 3075 3075
# friendly battle 3075 3075
# friendly battle 3075 3075
# friendly battle 3075 3075
2017-07-26,-50,executioner4 fire_fireball9 giant9 goblin_archer9 angry_barbarian11 mega_minion8 princess2 zap11
# friendly battle 3046 3046
2017-07-26,-75,skeleton_horde3 fire_fireball8 baby_dragon5 valkyrie8 musketeer8 hog_rider8 zap10 inferno_dragon2

Edit: Do you think I should reset the counter to 0 (it increases or decreases by 25 for win or lose) with every new player?

Example:

# playerName playerID
arbitrary-date, 0, # NOTE Erased characters on every first game because they impact the score of a game before. Might be easier to explain with math. No n characters on the first line because n-1 game is missing.
same-date, 25, a b c d e f g h
same-date, 50, a b c d e f g h
# playerName playerID
same-date, 0, #??????? Go back to zero here?
same-date,- 25, a b c d e f g h
same-date, 0, a b c d e f g h

What does "nosleep" exactly mean?

What does "nosleep" exactly mean?
Haven't you slept in all continuous 24 hours?

And, how about record the sleep data in this pattern: "sleep:6.5" (sleep[:hours]) ?

Thank you!

Mac ggplot2 issue

Hi Ariel, thanks so much for your work on this.

I'm working on the Mac instructions for a pull request, and have gotten mostly everything working (it isn't intuitive or even all that Google-able) but for some reason, the chart it's printing out looks like this:

screen shot on 2016-09-25 at 19_17_47

For the record, I had to change the font from FreeSans, so that could be part of it. I switched to generic Helvetica.

Understanding the RelScore better

Hey, once I run the software with my csv, I get a chart along with some files.
one of those files is scroes file which is of following format

FeatureName,RelScore
1-3k_sleep_onset,-100.00
Turkey,-69.63
Boar's_Head,-69.63
Pepperoni,-69.63
Homemade,-64.10

What does RelScore mean here? One thing I understood is a negative score here means I lose weight but how does the number signify?

What does a unexpected "Constant" row mean in output file "scores.txt"?

Hi, Arielf, I got something like this(factors in chinese):

FeatureName HashVal MinVal MaxVal Weight RelScore
Constant 142054 1.00 1.00 -0.02 -100.00
花生 247270 1.00 10.00 -0.01 -73.55
素三鲜白菜 176662 1.00 20.00 -0.00 -23.43
韭菜鸡蛋饼 86006 1.00 20.00 -0.00 -22.81
......

I don't have any factor "Constant", is it a bug?

Selfies?

Really awesome job reading the data. I like that you were able to consider fasting time and how it relates to sleep. Question: Before and after pictures? Maybe you have a photo around the time of acceleration as well? Thanks

Tooth brushing

I know this sounds silly and can be considered as uninteresting as it does not focus on the primary source for weight results, but I am interested to hear if you did record and/or change your tooth brushing behaviour over these three(?) years (e.g. frequency, time of day, using gums, flossing, etc)?

I can see (and frequently experience this as an effect similar to sleep: it expands the fasting times. In times where I only brushed one time per day (before going to bed) I could imagine eating more and feeling more the lust to eat over the day vs brushing my teeth now three times per day, which takes away roughly 2hrs per day I just don't feel like eating. If that would be true (i.e. I don't overcompensate during meals) adding this alongside the "trick" of sleeping enough/long could reduce the potential times of "false decisions" during the day.

Neat analysis! How many days worth of data did you use?

Hi, I run the Quantified Self Forum and we'd love to learn more about your experiment. How many days were in the data-set that led to the variable-importance chart? The CSV in the repo only has 120 days worth of data vs. a weight variation from 186.8lbs to 182.8, which over 4 months seems too insignificant to draw conclusions from.

Perhaps you've only shared a sample/excerpt of the data? Anyway, would be great if you could update the README on that point. Thanks!

Deriving importance factors on a per-week basis

Daily weight changes are considered a very unreliable metric, prone to unpredictable fluctuations. Additionally, some factors may not be reflected immediately within 24h, but have a more long-term effect.

It would be great to take the same data and aggregate both factors and weight delta on a per-week basis, and then see whether the resulting factors are different from the existing daily results. Using the data you already have, it may give some new insights.

cc @arielf

Carbs and water fluctuations might confound results.

Awesome project, as a strength athlete and master in data science, this project includes my two biggest interests! I'm interested in collaborating with this project. Right of the bat I see one major flaw in the way to interpret the results:

Weight alone might not be sufficient to measure the important properties of your body composition. Aside from fat, your weight is also composed of muscle and water. Weight loss in the form of pure muscle would in general not be desired from an aesthetical or health standpoint. Water is an even bigger problem: as carbs are transformed to glycogen and stored in the muscles, for every glycogen particle, 4 water particle are stored around it. Weight spikes after a carb meal are normal and don't have much to do with fat loss. Over the long term water levels stay relatively stable, so comparing high carb weeks with low carb weeks might be a way to cancel this factor out.

Learning the policy which leads to balanced/healthy weight loss?

What if the problem losing weight could be cast as a problem of finding the best policy? Given the context (day eating habits, moving etc), the policy (to be learned) should output an action (what to do in that day). Am I correctly understanding the learning problem? This would be fun to explore.

How do you know you're in ketosis?

Thanks for sharing this.

Can you give me any idea of how much carbs is too much carbs in any single day? And how do you know you're in ketosis? (I know about keto sticks, but having tried this in the past it becomes sort of an obsession that I'd like to avoid)

Related: you mention you could get a way with having a pizza once a week -- wouldn't that kick you off ketosis? If so, how long does it take you to get back into ketosis?

Specify what "half-and-half" means

Specifically in the part: "I switched from milk to half-and-half". My initial reaction was "half and half" of what? But Googling "half-and-half" yields this wikipedia page, so from the context I assumed you meant half-and-half milk and cream, however even those can range in the fat percentage quite widely.
Could you specify what you meant so that it's clearer for those of us outside of the US?
Thanks. Awesome work, by the way!

How to do combinations?

Hey Ariel :) I saw that you're answering questions through issues. I hope this is the best way to reach you.

I love this project! I'm using it on Clash Royale like this

    2017-07-26,4600,goblin_archer13 fire_fireball9 goblins13 minion13 knight13 royal_giant13 hog_rider10 princess3
    2017-07-26,4628,giant10 firespirit_hut10 minion12 chr_witch7 barbarians12 miner3 ice_wizard3 zap12
    2017-07-26,4598,barbarians13 miner4 wizard10 chr_witch7 princess3 royal_giant13 the_log3 zap13

Everything's working great. I can generate a score chart and see the best cards overall. But what I noticed in username.train is something like this

    -1202.00 | giant10 valkyrie9 minion_horde12 rage_barbarian3 chr_witch7 lightning6 bomber12 zap12

I'm assuming those are the most commonly played cards? Or is that the best possible deck combination, because it has the greatest negative weight (-1202) meaning it wins against the player more frequently than any other combination?

I guess I'm asking the significance of the number on the left and how the features are chosen on the right side, and from there I can work toward finding the best 8 card combination. Thanks for any help you can provide!

OSError: No such file or directory

Hi there,

I'd followed your guides on executing the script, installed vw via brew but when I do make in the directory, I get the following error.

ekran resmi 2016-09-18 17 12 25

I looked it up on stackoverflow, someone says it's related to python subprocess.popen function that command (vw_cmd) should be in array of strings, actually it is in that form. I tried with shell=True option but then I get returncode=127.

The other thing I've tried is executing the command manually where the script breaks, vw-varinfo2 -k --loss_function squared --progress 1 -l 1.0 --l2 1.85201e-08 sercan.train | tee scores.txt it doesn't work but when it executed as ./vw-varinfo2, it works and creates score.txt.

I think it's related to my environment but a help could be great.

Thanks in advance

Ambiguity on Weight Quantity

I was wondering how one might deal with the differing type of quantities for items in the third column. For example, if I slept 8 hours and had 1 slice of pizza in a day, would it be best to put sleep:8 pizza:0.125 for example, or sleep pizza, etc... Looking more for your personal input on how to make the most of these weights.

Numerical-Weight

Can you please explain the (optional) numerical-weight? What is the unit?

For example from your journal:
bagel bread date:1.5 dietsnapple splenda pizza nosleep:0.2
cherry knish cheese salmon pistachio:0.7 peanut


Does this mean you ate 1.5 dates?

What does this "pistachio:0.7" represent? .7 of a cup?

Errors with Python

This is a great project. I experienced some errors getting it to run on my laptop, the worst of which were due to my version of Python. I'm running Mac OSX 10.11.6, with Anaconda installed so my default Python version is Python 3.5.1.

This produced a number of syntax errors. For example, line 418 of file vw-varinfo2 throws an invalid syntax error for the line that says:

sorted_tuples = sorted(F_WEIGHT.items(), key=lambda(k,v): v)
                                                   ^

It didn't like using a tuple as the lambda parameter. I fixed that but then ran into some other syntax errors, so rather than fix them I switched to the version of Python that ships as the default with OSX (Python 2.7.10), and everything ran except that "make sc" still throws the following errors:

/usr/local/Cellar/r/3.3.0_1/R.framework/Versions/3.3/Resources/bin/R: line 209: /usr/local/Library/ENV/4.3/sed: No such file or directory
/usr/local/Cellar/r/3.3.0_1/R.framework/Versions/3.3/Resources/bin/R: line 209: /usr/local/Library/ENV/4.3/sed: No such file or directory
Fatal error: cannot open file '': No such file or directory
make: *** [sc] Error 2

Extending the fasting time vs. eating fewer calories

In the docs, you mention

Extending the fasting time was one major accelerator of weight-loss rate.

You also state

Sleeping longer consistently appeared as the #1 factor in losing weight.…It took me a while to figure out the sleep part. When we sleep we don't eat. It is that simple.…Our sleeping time is our longest daily fasting time.

I was surprised by your conclusion and, after thinking about it, thought, "That makes sense."

After thinking about it some more, I'm curious how you determined longer fasting was a factor in and of itself. There is more than one variable there, it seems. If you skip breakfast, you're not just fasting longer; assuming you ate at roughly the same rate throughout the day on a day you didn't skip breakfast, you're also eating fewer calories. That is, if you normally ate 3 x 800 calorie meals, but then switched to sleeping longer and skipping breakfast, then ate 2 x 800 calorie meals, you're also cutting your calorie consumption by ~33%.

Did you eat an amount of calories equal to what you would've eaten during breakfast throughout the day to be more confident that it was fasting time alone that lead to the weight loss?

If so, that would be both a surprising and valuable insight, and worth mentioning!

semi-colon in Python

Hi,
First off thanks for the great initiative.

What is the purpose of the semi-colon in line 160 of vw-varinfo2 and in line 352 of same?

It's just that me and pylinter flag this as an error. But, I just wanted to make sure the semi-colon is not there for some higher purpose ;-)

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.