{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":102335,"databundleVersionId":12518947,"sourceType":"competition"},{"sourceId":12017771,"sourceType":"datasetVersion","datasetId":7560889}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Published on May 31, 2025. By Prata, Marília. (mpwolke)","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-05-31T15:10:53.499565Z","iopub.execute_input":"2025-05-31T15:10:53.499820Z","iopub.status.idle":"2025-05-31T15:10:55.778378Z","shell.execute_reply.started":"2025-05-31T15:10:53.499796Z","shell.execute_reply":"2025-05-31T15:10:55.777287Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"_kg_hide-input":true,"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"![](https://www.lawsonpsychology.com.au/wp-content/uploads/2022/06/Lawson_Blog_078.png)Lawson Clinical Psychology","metadata":{}},{"cell_type":"markdown","source":"## Articles:\n\n**SKIN PICKING**\n\nGarey, J. (2025). What Is Excoriation, or Skin-Picking? Child Mind Institute. https://childmind.org/article/excoriation-or-skin-picking/\n\n**TRICHOTILLOMANIA**\n\nMartinelli, K. (2025). What is Trichotillomania? Child Mind Institute. https://childmind.org/article/what-is-trichotillomania/\n\n**HYPERLEXIA AIR WRITING**\n\nhttps://www.andnextcomesl.com/2020/10/hyperlexia-air-writing.html","metadata":{}},{"cell_type":"markdown","source":"## Competition Citation\n\n@misc{cmi-detect-behavior-with-sensor-data,\n\n    author = {Laura Newman, David LoBue, Arianna Zuanazzi, Florian Rupprecht, Luke Mears, Roxanne McAdams, Erin Brown, Yanyi Wang, Camilla Strauss, Arno Klein, Lauren Hendrix, Maki Koyama, Josh To, Curt White, Yuki Kotani, Michelle Freund, Michael Milham, Gregory Kiar, Martyna Plomecka, Sohier Dane, and Maggie Demkin},\n    \n    title = {CMI - Detect Behavior with Sensor Data},\n    \n    year = {2025},\n    \n    howpublished = {\\url{https://kaggle.com/competitions/cmi-detect-behavior-with-sensor-data}},\n    note = {Kaggle}\n}","metadata":{}},{"cell_type":"markdown","source":"## Import Packages","metadata":{}},{"cell_type":"code","source":"import os\nimport time\nimport google.generativeai as genai\nfrom kaggle_secrets import UserSecretsClient","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Authenticate Gemini with Google Generative AI\n\nGemini Model is NOT attached directly to your Notebook. You should generate an API-Key and also add your Kaggle secret.","metadata":{}},{"cell_type":"code","source":"#By Paul Mooney https://www.kaggle.com/code/paultimothymooney/how-to-upload-large-files-to-gemini-1-5/notebook\n\nfrom kaggle_secrets import UserSecretsClient\nuser_secrets = UserSecretsClient()\nGEMINI_API_KEY = user_secrets.get_secret(\"GEMINI_API_KEY\")\ngenai.configure(api_key=GEMINI_API_KEY)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"generation_config = {\n  \"temperature\": 1,\n  \"top_p\": 0.95,\n  \"top_k\": 64,\n  \"max_output_tokens\": 8192,\n  \"response_mime_type\": \"text/plain\",\n}\n\nmodel = genai.GenerativeModel(\n  model_name=\"gemini-1.5-flash\",\n  generation_config=generation_config,\n  system_instruction=\"#System Prompt:You are an AI Research Assistance designed to analyse psychiatry concepts of some body-focused repetitive behaviors (BFRBs). Answer briefly, some questions referring only to the context.\\\"\\n\",\n)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Load text file","metadata":{}},{"cell_type":"code","source":"ex_d = genai.upload_file(\"/kaggle/input/anxiety-disorders/anxiety_disorders.txt\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"chat_session = model.start_chat(\nhistory =[\n    {\n        'role':'user',\n        'parts': [\n            ex_d,\n        ]\n    }\n])\n\ndef chatI(prompt):\n    response = chat_session.send_message(prompt)\n    print(response.text)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Anxiety disorders: body-focused repetitive behaviors (BFRBs)\nbfrb = open(\"../input/anxiety-disorders/anxiety_disorders.txt\", \"r\").read()\nprint (bfrb[:])","metadata":{"trusted":true,"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Body-focused repetitive behaviors (BFRBs)","metadata":{}},{"cell_type":"code","source":"Prompt=\"Cite some body-focused repetitive behaviors (BFRBs)?\"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"chatI(Prompt)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Excoriation disorders symptons","metadata":{}},{"cell_type":"code","source":"chatI(\"What are the symptoms of excoriation disorders?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"chatI(\"When skin picking is considered a disorder?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Types of skin-picking","metadata":{}},{"cell_type":"code","source":"chatI(\"What are the types of skin picking?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Treatments for excoriation disorder","metadata":{}},{"cell_type":"code","source":"chatI(\"What are the treatments for excoriation disorder?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Hyperlexia Air Writing","metadata":{}},{"cell_type":"code","source":"chatI(\"What is Air Writing?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Oops, that's Air Guitar not Air writing\n\n## Could you believe that there is a competition for that?!!!\n\n![](https://eastbayexpress.com/wp-content/uploads/sites/15/2021/02/https3A2F2Fmedia2.fdncms.com2Feastbayexpress2Fimager2Fus-air-guitar-championships-present-men-in-tights2Fu2Foriginal2F28180562Fmg_cover_3337.jpg)https://eastbayexpress.com/us-air-guitar-championships-present-men-in-tights-1/","metadata":{}},{"cell_type":"code","source":"chatI(\"Why do hyperlexic learners do air writing?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Hypernumeracy: Air writing numbers and math problems instead of letters and words.","metadata":{}},{"cell_type":"code","source":"chatI(\"What is hypernumeracy?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#chatI(\"Should Air writing be discouraged?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Gemini answer\n\n\"No, the text explicitly advises against discouraging air writing in hyperlexic children, as it serves as a helpful tool for self-regulation, language processing, and comprehension.\"","metadata":{}},{"cell_type":"markdown","source":"### How Air writing can be used","metadata":{}},{"cell_type":"code","source":"chatI(\"How Air writing can be used?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"chatI(\"What is trichotillomania?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Trichotillomania, aka Hair pulling","metadata":{}},{"cell_type":"code","source":"chatI(\"What are the types of hair pulling?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"chatI(\"What people do with their pulled hair?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### What they do with the pulled hair and its importance","metadata":{}},{"cell_type":"code","source":"#chatI(\"Why is important to know what they do with the pulled hair?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Gemini answer:\n\n\"Knowing what individuals do with their pulled hair is important because eating the hair (trichophagia) can lead to serious medical complications.  Understanding the full range of behaviors associated with trichotillomania is crucial for effective treatment.\"","metadata":{}},{"cell_type":"code","source":"chatI(\"How is trichotillomania treatment?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Tricotillomania and related disorders.","metadata":{}},{"cell_type":"code","source":"#chatI(\"What are the related disorders of people with trichotillomania?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Gemini ResourceExhausted\n\nHere, I got: ResourceExhausted: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: https://ai.google.dev/gemini-api/docs/rate-limits. [violations {\n  quota_metric: \"generativelanguage.googleapis.com/generate_content_free_tier_requests\"\n  quota_id: \"GenerateRequestsPerMinutePerProjectPerModel-FreeTier\"\n  quota_dimensions {\n    key: \"location\"\n    value: \"global\"\n  }\n  quota_dimensions {\n    key: \"model\"\n    value: \"gemini-1.5-flash\"\n  }\n  quota_value: 15\n}\n, links {\n  description: \"Learn more about Gemini API quotas\"\n  url: \"https://ai.google.dev/gemini-api/docs/rate-limits\"\n}\n, retry_delay {\n  seconds: 10\n}\n]","metadata":{}},{"cell_type":"markdown","source":"### Since my Gemini quota is exhausted I quit.\n\nHow to distinguish BFRB-like and non-BFRB_like activity?","metadata":{}},{"cell_type":"code","source":"#chatI(\"How can we distinguish BFRB-like and non-BFRB-like activity?\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#Acknowledgements:\n\nPaul Mooney https://www.kaggle.com/code/paultimothymooney/how-to-upload-large-files-to-gemini-1-5/notebook\n\nMarília Prata https://www.kaggle.com/code/mpwolke/gemini-is-magic-n-ever-believe-in-my-code","metadata":{}}]}