{"id":22702387,"url":"https://github.com/phughesmcr/predictage","last_synced_at":"2025-04-13T08:03:43.463Z","repository":{"id":57329693,"uuid":"89090007","full_name":"phughesmcr/predictage","owner":"phughesmcr","description":"Predict the age of a string's author","archived":false,"fork":false,"pushed_at":"2018-10-03T19:44:31.000Z","size":306,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-29T08:51:57.368Z","etag":null,"topics":["age","age-classification","age-detection","age-estimation","age-prediction","age-recognition"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phughesmcr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-22T18:15:21.000Z","updated_at":"2020-08-22T06:52:13.000Z","dependencies_parsed_at":"2022-09-16T17:40:21.379Z","dependency_job_id":null,"html_url":"https://github.com/phughesmcr/predictage","commit_stats":null,"previous_names":["phugh/predictage"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phughesmcr%2Fpredictage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phughesmcr%2Fpredictage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phughesmcr%2Fpredictage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phughesmcr%2Fpredictage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phughesmcr","download_url":"https://codeload.github.com/phughesmcr/predictage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229019441,"owners_count":18007169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["age","age-classification","age-detection","age-estimation","age-prediction","age-recognition"],"created_at":"2024-12-10T07:13:17.708Z","updated_at":"2024-12-10T07:13:18.392Z","avatar_url":"https://github.com/phughesmcr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# predictAge - Node.js based age prediction!\n\nPredict the age of a string's author.\n\nWhen used to analyse social media posts (i.e Facebook posts, Tweets), using just 20 posts predictAge has an ~70% accuracy rate. Using 50+ posts yields ~83% accuracy.\n\n## Usage\n```javascript\nconst age = require('predictage')\nconst text = 'A long string of text....'\nconst output = age(text)\nconsole.log(output) // { AGE: 23.175817246 }\n```\n\n## Default Output\nUsing the default options (i.e. {output: 'lex'}), predictAge will output an object with an 'AGE' key:\n```javascript\n{ AGE: 23.175817246 }\n```\n\n## The Options Object\n\nThe options object is optional and provides a number of controls to allow you to tailor the output to your needs. However, for general use it is recommended that all options are left to their defaults.\n\n```javascript\nconst age = require('predictage')\n// These are the default and recommended options\nconst opts = {  \n  'encoding': 'freq',\n  'locale': 'US',\n  'logs': 3,\n  'max': Number.POSITIVE_INFINITY,\n  'min': Number.NEGATIVE_INFINITY,\n  'noInt': false,\n  'output': 'lex',\n  'places': undefined,\n  'sortBy': 'lex',\n}\nconst text = 'A long string of text....'\nconst output = age(text, opts)\nconsole.log(output) // { AGE: 23.175817246 }\n```\n\n### 'encoding'\n\n**String - valid options: 'freq' (default), 'binary', or 'percent'**\n\n*N.B - You probably don't want to change this, ever.*\n\nControls how the lexical value is calculated.\n\n__Binary__ is simply the addition of lexical weights, i.e. word1 + word2 + word3.\n\n__Frequency__ encoding takes the overall wordcount and word frequency into account, i.e. (word frequency / word count) * weight. Note that the encoding option accepts either 'freq' or 'frequency' to enable this option.\n\nAnother way to think of binary and frequency encoding is that 'binary' essentially sets all weights to '1', whereas frequency will generate a group norm. This is useful for predictive lexica, for example, when predicting age we want to use frequency encoding because we care about the actual number generated - i.e. the lexical value *is* the predicted age. Whereas, when predicting gender (see [predictGender](https://github.com/phugh/predictgender)) 'binary' encoding is used because we don't care about the value, only whether it is above or below 0.\n\n__Percent__ returns the percentage of total (non-unique) tokens matched against the lexicon in each category as a decimal, i.e. 0.48 = 48%.\n\n### 'locale'\n**String - valid options: 'US' (default), 'GB'**\nThe lexicon data is in American English (US), if the string(s) you want to analyse are in British English set the locale option to 'GB'.\n\n### 'logs'\n**Number - valid options: 0, 1, 2, 3 (default)**\nUsed to control console.log, console.warn, and console.error outputs.\n* 0 = suppress all logs\n* 1 = print errors only\n* 2 = print errors and warnings\n* 3 = print all console logs\n\n### 'max' and 'min'\n\n**Number - accepts floats**\n\nExclude words that have weights above the max threshold or below the min threshold.\n\nBy default these are set to positive and negative infinity respectively, ensuring that no words from the lexicon are excluded.\n\n### 'noInt'\n\n**Boolean - valid options: true or false (default)**\n\nThe lexica contain intercept values, set noInt to true to ignore these values.\n\nUnless you have a specific need to ignore the intercepts, it is recommended you leave this set to false.\n\n### 'output'\n\n**String - valid options: 'lex' (default), 'matches', or 'full'**\n\n'lex' (default) returns the lexical value, which is the predicted age.\n\n'matches' returns an array of matched words along with the number of times each word appears, its weight, and its final lexical value (i.e. (appearances / word count) * weight). See the output section below for an example.\n\n'full' returns an object containing the predicted age and the matches array. The keys are \"age\" and \"matches\".\n\n### 'places'\n\n**Number - valid options between 0 and 20 inclusive.**\n\nNumber of decimal places to limit outputted values to.\n\nThe default is \"undefined\" which will simply return the value unchanged.\n\n### 'sortBy'\n\n**String - valid options: 'lex' (default)', 'weight', or 'freq'**\n\nIf 'output' = 'matches', this option can be used to control how the outputted array is sorted.\n\n'lex' (default) sorts by final lexical value, i.e. (word frequency * word count) / word weight.\n\n'weight' sorts the array by the matched words initial weight.\n\n'freq' sorts by word frequency, i.e. the most used words appear first.\n\nBy default the array is sorted by final lexical value, this is so you can see which words had the greatest impact on the prediction - i.e. the words which lower the age the most appear at the beginning of the array, the words which increase the age the most appear at the end.\n\n## {'output': 'matches'} output example\nSetting \"output\" to \"matches\" in the options object makes predictAge output an array containing information about the lexical matches in your query.\n\nEach match between the lexicon and your input is pushed into an array which contains: the term, the number of times that term appears in the text (its frequency), its weight in the lexicon, and its lexical value (i.e. (word freq / total word count) * weight) when 'freq' encoding is used).\n\nBy default the matches output array is sorted ascending by lexical value. This can be controlled using the \"sortBy\" option.\n\n```javascript\n{\n  AGE: {\n    matches: [ \n      [ 'magnificent', 1, -192.0206116, -1.3914537072463768 ],\n      [ 'capital', 1, -133.9311307, -0.9705154398550726 ],\n      [ 'note', 3, -34.83417005, -0.7572645663043478 ],\n      [ 'america', 2, -49.21227355, -0.7132213557971014 ],\n      [ 'republic', 1, -75.5720402, -0.5476234797101449 ]\n    ],\n    info: {\n      total_matches: 100,\n      total_unique_matches: 63,\n      total_tokens: 200,\n      percent_matches: 50,\n    },\n  }\n}\n```\n\n| Term          | Frequency | Weight (value)| Lexical Value (group norm) |\n| ------------- | --------- | ------------- | ------------------- |\n| 'magnificent' | 1         | -192.0206116  | -1.3914537072463768 |\n| 'capital'     | 1         | -133.9311307  | -0.9705154398550726 |\n| 'note'        | 3         | -34.83417005  | -0.7572645663043478 |\n| 'america'     | 2         | -49.21227355  | -0.7132213557971014 |\n| 'republic'    | 1         | -75.5720402   | -0.5476234797101449 |\n\n\n## Acknowledgements\n\n### References\nBased on [Schwartz, H. A., Eichstaedt, J. C., Kern, M. L., Dziurzynski, L., Ramones, S. M., Agrawal, M., Shah, A., Kosinski, M., Stillwell, D., Seligman, M. E., \u0026 Ungar, L. H. (2013). Personality, Gender, and Age in the Language of Social Media: The Open-Vocabulary Approach. PLOS ONE, 8(9), e73791.](http://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0073791\u0026type=printable)\n\n### Lexicon\nUsing the gender lexicon data from [WWBP](http://www.wwbp.org/lexica.html) under the [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported](http://creativecommons.org/licenses/by-nc-sa/3.0/) license.\n\n## License\n(C) 2017-18 [P. Hughes](https://www.phugh.es). All rights reserved.\n\nShared under the [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported](http://creativecommons.org/licenses/by-nc-sa/3.0/) license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphughesmcr%2Fpredictage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphughesmcr%2Fpredictage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphughesmcr%2Fpredictage/lists"}