<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Neeraj jain on Medium]]></title>
        <description><![CDATA[Stories by Neeraj jain on Medium]]></description>
        <link>https://medium.com/@nee-neer?source=rss-97014f1e61d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*2q7LcOWRH1NJfoCGwWZh_A.jpeg</url>
            <title>Stories by Neeraj jain on Medium</title>
            <link>https://medium.com/@nee-neer?source=rss-97014f1e61d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:17:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nee-neer/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Predicting Human Behavior using Artificial Intelligence]]></title>
            <link>https://nee-neer.medium.com/predicting-human-behavior-using-artificial-intelligence-902360fbf39d?source=rss-97014f1e61d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/902360fbf39d</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[psychiatry]]></category>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[behavioral-science]]></category>
            <dc:creator><![CDATA[Neeraj jain]]></dc:creator>
            <pubDate>Wed, 28 Apr 2021 05:52:55 GMT</pubDate>
            <atom:updated>2021-04-28T05:59:53.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-wjOHyYRk9eBDLz-0joOg.jpeg" /><figcaption>Photo by: Neeraj Jain</figcaption></figure><p>This article is an effort to show how democratization of Artificial Intelligence (AI) and information have lead to ease of doing research on any topic. Research, that was reserved for academicians can now be performed by anyone. You can replace the AI models used in this articles with the current state of art models. Details on any statement made in this article can be found in reference section.</p><h3><strong>Abstract</strong></h3><p>This study is an attempt to find concomitant effects of genetic factors on individual’s physical and behavioral traits, using artificial intelligence (AI). The study was performed with 111 subjects and shows how AI can be used to read a palm image to find correlations between various physical attributes of the palm and behavioral attributes.</p><p>The study aimed to present a method that is fast and accurate in predicting behavior, and build an AI model that can self-evolve by learning from new data. The model was built by integrating multiple deep convolutional neural network architectures. The results indicated significant correlations between certain palm attributes and the impulsive-thrill-seeking behavioral trait (p &lt;0.0001).</p><h3><strong>Introduction</strong></h3><p>Study of human behavior is an area of interest within many fields including finance, economics, marketing and so on. These fields require an understanding of generalized or collective behavior. Methods used to study behavior in these areas are robust to outliers and response-bias errors. Clinical and organizational psychology on the other hand deal with individual behavior. Methods used to study behavior in these areas are very sensitive to outliers and any bias.</p><p>I combined personality psychology and behavioral genetics, two major fields to study behavioral traits of an individual, with Artificial Intelligence to create a predictive system that is resistant to biases and outliers.</p><p>The choice of correlating the shape of the palm and behavior was influenced by the following conclusions derived from multiple studies related to genetics and behavior (Ref: Reference section).</p><ul><li>Genes are a major factor in determining human behavior</li><li>Genes affect multiple behavioral and physical traits in a concomitant fashion</li></ul><p>I tested this hypothesis by extracting various palm attributes from images using AI to find correlations between these palm attributes and various behavioral traits.</p><p>Subsequent sections will describe how an AI model was built to combine findings from behavioral genetics with psychological methods of behavioral assessment to directly correlate a behavioral trait with the shape and structure of the palm.</p><h3><strong>Method</strong></h3><p>This study involved four steps. The first step was to build an AI Model consisting of multiple stages to extract palm attributes from images. The second was to prepare a questionnaire to assess the subjects’ behavioral traits. The third was to administer the questionnaire and collect palm prints from the subjects (test data). Finally, behavioral traits were identified using the questionnaire and correlated with palm attribute. Figure 1 shows components of dataflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*5C86PfFIw-PDir3F6z9xdw.png" /><figcaption>Figure 1. Dataflow</figcaption></figure><h4><strong>AI Model</strong></h4><p>The objective for this model was to extract certain palm attributes from images without human intervention and the accuracy of every stage of this model should be greater than 0.95.</p><p>The AI model development cycle consisted of four stages: training data (gathering and annotation), model design, training, and testing. Model design and training were iterative processes wherein multiple convolutional neural network (CNN) architectures were trained, and the best architecture was selected based on its performance on validation data.</p><p><strong>Training Data</strong></p><p>The model was trained and validated using the “<a href="https://sites.google.com/view/11khands">11K Hands</a>” dataset. This dataset consists of 11,076 palm images from 190 subjects of varying ages between 18–75 years old.</p><p>Testing of models was done using the <a href="https://www.coep.org.in/resources/coeppalmprintdatabase">COEP Palm Print</a> Database. This dataset consists of total 1344 images pertaining to 168 subjects. Each subject has multiple images of the right hand, with the palmar side and fingers in an open position on a black background.</p><p>Custom built tools and <a href="https://github.com/tzutalin/labelImg">LabelImg</a> were used to annotate palm images. Since LabelImg is a general-purpose tool, some modifications were performed to make it more adaptable to the study task. Source code can be found at <a href="https://github.com/neeraj-j/maskImg.git">https://github.com/neeraj-j/maskImg.git</a></p><p><strong>Pre-process</strong></p><p>In this stage, the image was classified as a combination of the four types: left vs. right and palmar vs. dorsal. Various deep CNN architectures including MobileNetV2, ResNet, NASNet, DenseNet, and their ensemble were trained and tested. Finally, MobileNetV2 was selected for the best accuracy. This method reached accuracy of 0.9846 on validation data and accuracy of 1.00 on test data.</p><p><strong>Feature Extraction</strong></p><p>Feature extraction was done using <a href="https://github.com/facebookresearch/Detectron">Detectron</a>. Multiple instances of Detectron were created to extract features from the palmar and dorsal sides of the palm. Table 1 shows the average precision. Figure 2 shows the output of this stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*EqjrMc-Nrp2FQTeT09chzg.png" /><figcaption>Table 1: AP Values as Calculated by Detectron on Validation Data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*kkTGHQnDMxIz-AZRVlofBA.png" /><figcaption>Figure2: Feature Extraction</figcaption></figure><p><strong>Post-process</strong></p><p>The purpose of this stage was to compute various ratios and angles from the features extracted. This stage did not use any CNN architecture. The attributes computed in this stage are shown in Table 2. These attributes were used to find correlations with the behavioral trait. Figure 3 shows the attributes used in Table 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*pBCJ899bV2008bXva2q7tg.png" /><figcaption>Table 2: Attributes Computed by Post-process Stage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*H2hjwo0lkuWesUhTUzcMGg.png" /><figcaption>Figure 3: Palm Attributes</figcaption></figure><h4><strong>2. Questionnaire Preparation</strong></h4><p>The questionnaire was prepared using a Google form for online administration. The questionnaire consisted of four <a href="https://ipip.ori.org/">IPIP scale</a> constructs: planfulness, emotion-based decision-making, impulsive thrill-seeking, and sociability. Every construct was assessed with 10 questions, comprising five positively worded items and five negatively worded items. The purpose of selecting these was to include constructs that are significantly correlated so that an individual’s dominant behavior can be identified by comparing his or her own responses rather than comparing responses across the group. These constructs were selected intuitively based on the questions presented for each construct.</p><h4><strong>3. Test Data Collection</strong></h4><p>Participation in this survey was optional and none of the personal information of the participants was shared in this article. Data was collected from Feb 17, 2019 to Mar 3, 2019. A total of 124 samples (questionnaire and palm prints) were collected from two crowd-sourcing sites (Microworkers and Amazon Mechanical Turk) using the Google form. Each form was associated with the worker ID of the site for traceability. This method of data collection is completely tamper-proof. The survey was open only to residents of English-speaking countries who were over 18 years of age. English speaking workers were chosen to ensure correct understanding of the instructions and questionnaire.</p><p>However, it was later determined that, due to immigration and the very nature of the internet, individuals who are not native English speakers might also have participated in the survey. No demographic details of the subjects were collected.</p><h4>Test Data Processing</h4><p><strong>Questionnaire Processing</strong></p><p>Once the data were collected, questionnaires were processed to filter random and pattern responses and to identify the subjects’ behavioral traits. To filter out random responses, means and variance were calculated per person and per construct. If three out of four constructs had variance greater than three or means between 3.1 and 2.9 (inclusive), then the response was discarded. This fulfilled two exclusion conditions, in which a subject had selected responses randomly or selected the same response for all questions. After this filtration, nine responses were discarded, leaving 115 responses.</p><p>To identify the subjects’ behavioral traits, correlations were calculated among the four IPIP constructs. Table 3 shows that the constructs impulsive thrill-seeking and emotion-based decision making were positively correlated, and that both were negatively correlated to planfulness, significantly at p &lt;0.00001. Therefore, any response whose mean value of “emotion-based decision making” or “impulsive thrill-seeking” was greater than the mean of planfulness was classified as emotion-based decision-making and impulsive thrill-seeking respectively. Sociability was not used as it was not correlated with the other three at significant levels. The output of this step was a csv file consisting of subjects’ identifiers and behavioral traits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*hG2YNhcqHLknT04iOMw_UQ.png" /><figcaption>Table 3: Correlation Matrix of the IPIP scale constructs</figcaption></figure><p>Table 4 presents Cronbach’s alpha for the constructs, before and after filtration. In the study data sample, the alpha coefficient remained above 0.70 for all traits even before filtration. After filtering the data, Cronbach’s alpha improved for all variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*SA7drDH78uLEA3xA4yAwDw.png" /><figcaption>Table 4: Cronbach’s Alpha for the Variables</figcaption></figure><p><strong>Palm Image Processing</strong></p><p>Every subject was asked to submit six palm images in the Google form, along with the questionnaire. Images of the left and right hand with fingers in open and closed positions from the palmar side and fingers in an open position from the dorsal side on a uniform white or black background were to be submitted. The position of the camera had to be above the joint of the fingers and palm to avoid optical distortion. Not everybody followed the instructions. This resulted in either optical distortion or the AI Model not able to process some images correctly. Invalid images were removed manually. Still, distortion in some images induced errors in the finger to palm ratio (sfbratio) and angle between fingers. Four responses were dropped at this stage, leaving 111 responses to process. A camera tool was developed as part of this study to capture palm images in the specified format. However, due to the internet-based nature of data collection it could not be used. Manual selection of images can be superseded by using a tool to capture palm images and training an AI module to filter out anomalies.</p><p>The correct images were fed to the AI model for processing. The output of the model was a csv file that consisted of subject identifiers along with palm attributes in numerical format.</p><p>Primarily, right hand images were used, unless they were not available or usable. In that case, images from the left hand were used.</p><h3>Results</h3><p>Once the palm attributes and behavioral trait were identified for all the subjects, Pearson’s correlation analysis was applied to this data. The purpose of this study was to determine if palm attributes and the behavioral trait were significantly correlated. Table 5 shows that, with a valid sample size of 111 subjects, correlations between the impulsive thrill-seeking behavioral trait and ratio of thumb’s first and second phalanges length were significant at levels of p &lt; 0.00001. This trait is also significantly correlated with the angle between middle finger and ring finger (p&lt;0.10).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*yI7QexQ2eExQjOvyjx8z-g.png" /><figcaption>Table 5: Top Correlation Values Between Palm Attributes and IPIP scale constructs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*iXQkvXr_vXxDMrxhPxIjeQ.png" /><figcaption>Figure 5: Correlation between impulsive thrill-seeking construct and palm attributes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*oFcbPChc6ewJkFh0kRrePw.png" /><figcaption>Figure 6: Correlation between Emotion-based decision-making and Palm attributes</figcaption></figure><p>The correlations between emotion-based decision-making and the angle between middle finger and ring finger were also significant (p&lt;0.10). To verify the uniformity of the results, the data were randomized and divided into halves a few times and the same correlations were calculated. The results were identical. Figure 5 shows the correlation values for impulsive thrill-seeking and Figure 6 shows correlation values for emotion-based-decision-making in a graphical format.</p><p>The results clearly show that there are significant correlations between certain palm attributes and the impulsive thrill-seeking construct. It is interesting to note that impulsive thrill-seeking and emotion-based decision-making are significantly correlated and both the constructs are correlated with the angle between middle finger and ring finger (p&lt;0.10).</p><p>This study had limited scope, despite limitations, it is an important step in proposing a new method that can be used to build an AI model in the near future to accurately predict an individual’s behavior in milliseconds using nothing but physical attributes derived from an image.</p><h4>References</h4><p>Blanchard A, Lyons M (2010). “An investigation into the relationship between digit length ratio(2D: 4D) and psychopathy”. <a href="https://www.academia.edu/343750/An_Investigation_Into_the_Relationship_Between_Digit_Lengt">https://www.academia.edu/343750/An_Investigation_Into_the_Relationship_Between_Digit_Lengt</a>h_Ratio_2D_4D_and_Psychopathy</p><p>Cho KJ, Kim S (1 December 2017). “Utilization of Second Digit to Fourth Digit Ratio (2D : 4D) as One of Physical Markers to Evaluate Aggression in Elementary School Students”. <a href="https://synapse.koreamed.org/search.php?where=aview&amp;id=10.11637/kjpa.2017.30.4.153&amp;code=0">https://synapse.koreamed.org/search.php where=aview&amp;id=10.11637/kjpa.2017.30.4.153&amp;code=0</a>107KJPA&amp;vmode=PUBREADER</p><p>Deemyad, T., Metzen, M. G., Pan, Y., &amp; Chacron, M. J. (2013). Serotonin selectively enhances perception and sensory neural responses to stimuli generated by same-sex conspecifics. <a href="https://www.pnas.org/content/110/48/19609">https://www.pnas.org/content/110/48/19609</a></p><p>Eichler A, Heinrich H, Moll GH, Beckmann MW, Goecke TW, Fasching PA, Muschler MR, Bouna-Pyrrou P, Lenz B, Kornhuber J (April 2018). “Digit ratio (2D:4D) and behavioral symptoms in primary-school aged boys”. <a href="https://www.ncbi.nlm.nih.gov/pubmed/29486372">https://www.ncbi.nlm.nih.gov/pubmed/29486372</a></p><p>Ellis L, Hoskin AW (March 2015). “Criminality and the 2D:4D ratio: testing the prenatal androgen hypothesis”. <a href="https://www.researchgate.net/publication/289518395_Criminality_and_the_2D4D_Ratio_Testing_t">https://www.researchgate.net/publication/289518395_Criminality_and_the_2D4D_Ratio_Testing_t</a>he_Prenatal_Androgen_Hypothesis</p><p>Evardone M, Alexander GM (June 2009). “Anxiety, sex-linked behaviors, and digit ratios (2D:4D)”. <a href="https://www.researchgate.net/publication/5903034_Anxiety_Sex-">https://www.researchgate.net/publication/5903034_Anxiety_Sex-</a>Linked_Behaviors_and_Digit_Ratios_2D4D</p><p>Explorable.com. (2015). Human Genome Project — Mapping the DNA. https://explorable.com/human-genome-project</p><p>Galuska, L., Garai, I., Csiki, Z., Varga, J., Bodolay, E., &amp; Bajnok, L. (2000). The clinical usefulness of the fingers-to-palm ratio in different hand microcirculatory abnormalities. https://<a href="http://www.ncbi.nlm.nih.gov/pubmed/10994670">www.ncbi.nlm.nih.gov/pubmed/10994670</a></p><p>Glimcher, P. W. (2011). Understanding dopamine and reinforcement learning: The dopamine reward prediction error hypothesis. <a href="https://www.pnas.org/content/108/Supplement_3/15647">https://www.pnas.org/content/108/Supplement_3/15647</a></p><p>Gove, W. R., &amp; Geerken, M. R. (1977). Response Bias in Surveys of Mental Health: An Empirical Investigation. <a href="https://www.jstor.org/stable/2777936?seq=1#page_scan_tab_contents">https://www.jstor.org/stable/2777936?seq=1#page_scan_tab_contents</a></p><p>Gutterman, D. D., Chabowski, D. S., Kadlec, A. O., Durand, M. J., Freed, J. K., Ait-Aissa, K., &amp; Beyer, A. M. (2016). The Human Microcirculation. <a href="https://www.ahajournals.org/doi/10.1161/CIRCRESAHA.115.305364">https://www.ahajournals.org/doi/10.1161/CIRCRESAHA.115.305364</a></p><p>Hasan, K. R., Ara, S., &amp; Banna, F. A. (2017). Correlation of Index Finger Length (2D) with Height, Weight and BMI in Adult Bangladeshi Male. <a href="https://www.researchgate.net/publication/317341752_Correlation_of_Index_Finger_Length_2D_wi">https://www.researchgate.net/publication/317341752_Correlation_of_Index_Finger_Length_2D_wi</a>th_Height_Weight_and_BMI_in_Adult_Bangladeshi_Male</p><p>Honk, J. V., Montoya, E. R., Bos, P. A., Vugt, M. V., &amp; Terburg, D. (2012). New evidence on testosterone and cooperation. Nature, 485(7399). doi:10.1038/nature11136. https://<a href="http://www.psychologie.uni-freiburg.de/abteilungen/psychobio/aktuell/Nature-">www.psychologie.uni-freiburg.de/abteilungen/psychobio/aktuell/Nature</a>-TestosteroneAndCooperation%28Communication%2912.pdf</p><p>(2013). “Low 2D:4D values are associated with video game addiction”. <a href="https://www.researchgate.net/publication/258531037_Low_2D4D_Values_Are_Associated_with_V">https://www.researchgate.net/publication/258531037_Low_2D4D_Values_Are_Associated_with_V</a>ideo_Game_Addiction</p><p>Lenz B, Bouna-Pyrrou P, Mühle C, Kornhuber J (August 2018). “Low digit ratio (2D:4D) and late pubertal onset indicate prenatal hyperandrogenziation in alcohol binge drinking”. h<a href="https://www.sciencedirect.com/science/article/pii/">ttps://www.sciencedirect.com/science/article/pii/</a>S0278584617310461</p><p>Macdonell, W. R. (1902). On Criminal Anthropometry and the Identification of Criminals. <a href="https://www.jstor.org/stable/2331487?seq=1#page_scan_tab_contents">https://www.jstor.org/stable/2331487?seq=1#page_scan_tab_contents</a></p><p>Manning, J. T., Scutt, D., Wilson, J., &amp; Lewis-Jones, D. I. (1998). The ratio of 2nd to 4th digit length: A predictor of sperm numbers and concentrations of testosterone, luteinizing hormone and oestrogen. <a href="https://pdfs.semanticscholar.org/53c6/d37581853c1b6136808f0e39cbb1270ab258.pdf">https://pdfs.semanticscholar.org/53c6/d37581853c1b6136808f0e39cbb1270ab258.pdf</a></p><p>Meij, L. V., Almela, M., Buunk, A. P., Dubbs, S., &amp; Salvador, A. (2012). 2D:4D in Men Is Related to Aggressive Dominance but Not to Sociable Dominance. Aggressive Behavior, <a href="https://www.researchgate.net/publication/224835683_2D4D_in_Men_Is_Related_to_Aggressive_D">https://www.researchgate.net/publication/224835683_2D4D_in_Men_Is_Related_to_Aggressive_D</a>ominance_but_Not_to_Sociable_Dominance</p><p>Mitchell, J., Weinstein, D., &amp; Kayser, A. (2015). Dopamine, time perception, and future time perspective. Drug and Alcohol Dependence, <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6182591/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6182591/</a></p><p>Nordborg, M. (2010). Faculty of 1000 evaluation for Hundreds of variants clustered in genomic loci and biological pathways affect human height. <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2955183/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2955183/</a></p><p>Paulhus, D.L, Vazire, S. (2007). Self-Report Method in Robins, R.W., Fraley, R. C. &amp; Krueger, R.F., Handbook of research methods in personality psychology(pp.224–239). <a href="https://www.researchgate.net/publication/257492171_Sex_hormones_and_finger_length_What_doe">https://www.researchgate.net/publication/257492171_Sex_hormones_and_finger_length_What_doe</a>s_2D4D_indicate_Evolution_and_Human_Behavior_25_182–199</p><p>Redgrave, P., Gurney, K., &amp; Reynolds, J. (2008). What is reinforced by phasic dopamine signals? Brain Research Reviews, <a href="https://www.researchgate.net/publication/5793147_What_is_reinforced_by_phasic_dopamine_sign">https://www.researchgate.net/publication/5793147_What_is_reinforced_by_phasic_dopamine_sign</a>als</p><p>Schultz, W. (2013). Updating dopamine reward signals. Current Opinion in Neurobiology, <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3866681/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3866681/</a></p><p>Vukasović, T., &amp; Bratko, D. (2015). Heritability of personality: A meta-analysis of behavior genetic studies. <a href="https://pdfs.semanticscholar.org/8faa/f538ad7f21f084b9535cdb31824c11cc2a1d.pdf">https://pdfs.semanticscholar.org/8faa/f538ad7f21f084b9535cdb31824c11cc2a1d.pdf</a></p><p>Wilson, G. D. (1983). Finger-length as an index of assertiveness in women. Personality and Individual Differences, <a href="https://www.sciencedirect.com/science/article/abs/pii/0191886983900612">https://www.sciencedirect.com/science/article/abs/pii/0191886983900612</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=902360fbf39d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Molecule synthesis using AI]]></title>
            <link>https://medium.com/data-science/molecule-synthesis-using-ai-10e0e1f89568?source=rss-97014f1e61d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/10e0e1f89568</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[molecule-synthesis]]></category>
            <category><![CDATA[gans]]></category>
            <dc:creator><![CDATA[Neeraj jain]]></dc:creator>
            <pubDate>Wed, 25 Sep 2019 12:39:21 GMT</pubDate>
            <atom:updated>2019-09-25T12:39:21.511Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>Step by step guide to use GAN in search for new drugs and materials</h4><figure><img alt="Progressive GAN generated molecule structures" src="https://cdn-images-1.medium.com/max/1024/1*KVzXxbPQUNMqpXPDTpYbZw.png" /><figcaption>Progressive GAN generated molecule structures (Three molecules are real)</figcaption></figure><p>Molecule synthesis is a process of constructing complex chemical molecules from simple precursors. This is the key to the development of next generation medicines, smart materials, pesticides and electronics. Hitherto molecule synthesis is a manual, costly, time consuming, multi-step process. It is guided mainly by chemical intuition and a sound knowledge of chemical reactions. Artificial Intelligence (AI) has potential to make any molecule at will, inexpensively and on a meaningful timescale that will unlock unimagined opportunities for future scientific advancement.</p><p>Generative adversarial nets (GAN) is an AI model that consists of a ‘Generator’ and a ‘Discriminator’. Generator captures the training data distribution and generates samples from it. Discriminator estimates the probability of sample coming from the Generator rather than training data. This two-player game is played till the probability of discriminator making error is maximized.</p><p>In this article, I will demonstrate how a GAN can be trained to generate molecular structures. This is the first step in automating molecule syntheses. Similar work is being done by <a href="https://mlpds.mit.edu/">Machine Learning for Pharmaceutical Discovery and Synthesis Consortium</a> (<a href="https://medium.com/@MITIBMLab/can-ai-create-molecules-324c140981e6">Can AI Create molecules?</a> by <a href="https://medium.com/u/a0a8fdb128d4">MIT-IBM Watson AI Lab</a>). I am taking this example to accentuate the ease with which any individual can use AI to perform cutting edge research. The only limiting factor is imagination.</p><h3><strong>Data</strong></h3><p>The first step in any artificial intelligence (AI) project is data. There are multiple websites containing chemical database in various formats. <a href="https://pubchem.ncbi.nlm.nih.gov/">PubChem</a> contains a list of ~96M chemical compounds in SMILES notation. SMILES notation can be classified into functional groups and converted into molecular structure images using python rdkit library. Out of 52 functional groups, only Alcohol Aliphatic functional group was used to limit the scope of this work. First 50,000 compounds from Alcohol Aliphatic group were converted into images of size 128x128. The code to categorize and convert SMILES entries into images is available at <a href="https://github.com/neeraj-j/molecules">github</a>.</p><h3>Training</h3><p>Next step was to select the GAN model. After a few failed attempts, I selected Progressive GAN’s (<a href="https://arxiv.org/abs/1710.10196">PGAN</a>) pytorch implementation by facebook research (<a href="https://github.com/facebookresearch/pytorch_GAN_zoo">pytorch_GAN_zoo</a>). Novelty of Progressive GAN is that it starts training with images at low resolution and add new layers that introduce higher-resolution details as the training progresses. According to its authors, these characteristics of PGAN makes it more stable and faster to train.</p><p>First step in training was to clone the pytorch_GAN_zoo:</p><pre>git clone <a href="https://github.com/facebookresearch/pytorch_GAN_zoo.git">https://github.com/facebookresearch/pytorch_GAN_zoo.git</a></pre><p>The training process for PGAN is slightly different than other GANs. Before starting the training, data has to be resized into low resolution images. This is done by giving the following command:</p><pre>python datasets.py celeba $PATH_TO_IMAGES -o $OUTPUT_DIR -f</pre><p>In this command, “celeba” is the name of pre-trainned dataset. pytorch_GAN_zoo has multiple dataset pre-trainned on this model. “celeba” dataset corresponds to images of 128x128 pixel, which is same as size of images used in this project. Unless user is a hyper-parameter wizard, it is advisable to adapt data to the hyper-parameters of the pre-trainned model rather than tuning hyper parameters according to data. After first run, hyper-parameters can be changed to fine tune the model. Following Table contains the pre-trainned model names and supported image sizes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*b-vOLwJXYhctA7FzpzYpCw.png" /><figcaption>Dataset name and image size</figcaption></figure><p>Datasets.py will also generate a config file. This config file will contain 1) path to the resized images and the original images. 2) number of iterations per scale. ‘Scale’ is a concept that is unique to PGAN. Every scale is associated with number of layers in the model, iterations and image resolution. Max scale is calculated using following formula.</p><pre>image_size = 2**(2+max_scale)</pre><p>In this formula constant 2 is added to max scale because the training layers start from resolution of 4x4. Datasets.py will resize images in steps of (64, 128, 512, 1024) until the image size of the data. “$PATH_TO_IMAGES” is the location of the training images. “OUTPUT_DIR” this is the location where resized images will be saved. “-f” option is to generate resized images before training starts. Once the resize images and config file is created, next step was to start training by giving the following command:</p><pre>python train.py PGAN -c $CONFIG_FILE -n $DATASET_NAME -d $WEIGHTS_DIR</pre><p>In this command, “PGAN” refers to Progressive GAN. pytorch_GAN_zoo also support DCGAN. ”CONFIG_FILE” is the path to config file generated by datasets.py. “DATASET_NAME” is the name of custom dataset. “WEIGHTS_DIR” is the location where weights will be stored. More options are defined in train.py. I had used “ — np_vis” option to use numpy based visualization instead of installing “visdom” package. I had also set “-e” and “-s” option to 2000.</p><h3>Training Analysis</h3><p>This training went on for 9 days on Tesla K80 based server. I stopped the training after 62000 iterations on last scale. Weights of the trained model can be downloaded using this <a href="https://drive.google.com/drive/folders/16Fetqo9rbWu_vKy6Tqy-Zmxpb_AKYbTy?usp=sharing">link</a>. One of the main reason GAN training takes long time is due to lack of transfer learning in generative models. Transfer learning reduces the data requirement and convergence time in discriminative models. There is a recent <a href="https://arxiv.org/abs/1906.11613v1">paper</a> that propose to address this issue in GANs. One way of reducing training time is to use minimum sized images relevant to data.</p><p>In PGAN, training layer starts from 4x4 resolution and goes up to image size of the dataset. For image size of 128, layers were added in the scale of 4,8,16,32,64,128. Plotting training time vs iterations clearly show how addition of new layer increased the training time exponentially at every scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*AbM-S4z_uN--e6-nBKrYiw.png" /><figcaption>Training time vs iterations</figcaption></figure><p>The video below shows training progress. Most of the refinement in generated images happened during last scale. This video was created by stitching evaluation images that were saved after every 2000 iterations.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUdLSreisgVA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUdLSreisgVA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUdLSreisgVA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e69227982f6a44de207037b815b70e4/href">https://medium.com/media/1e69227982f6a44de207037b815b70e4/href</a></iframe><p>pytorch_GAN_zoo provides tools to evaluate the performance of the model on generated images. Most popular one is inception score. Inception score of generated images was calculated by giving following command.</p><pre>python eval.py inception -c $CONFIGURATION_FILE -n $modelName -m $modelType -d $WEIGHTS_DIR</pre><p>Sliced Wasserstein distance (SWD) is another method used to evaluate high-resolution GANs. laplacian SWD score was calculated by giving following command. More information about evaluating GAN performance is given in this <a href="https://hal.inria.fr/hal-01850447/document">paper</a>.</p><pre>python eval.py laplacian_SWD -c $CONFIGURATION_FILE -n $modelName -m $modelType -d $WEIGHTS_DIR</pre><p>pytorch_GAN_zoo implements another tool, “<a href="https://arxiv.org/abs/1906.11661">Inspirational Adverserial Image generation</a>”. This tool takes an image as input and extracts an input vector using gradient decent. This input vector is used to generate new images that share characteristics of the input image. Inspirational generation is a two step process.</p><pre>python save_feature_extractor.py {vgg16, vgg19}\   $PATH_TO_THE_OUTPUT_FEATURE_EXTRACTOR --layers 3 4 5</pre><p>In this command vgg16/vgg19 specify model to be used for input vector generation. Once the feature extractor was downloaded, following command was used to generate molecule structure based on</p><pre>python eval.py inspirational_generation -n $modelName -m $modelType\ --inputImage $pathTotheInputImage -f \ $PATH_TO_THE_OUTPUT_FEATURE_EXTRACTOR -d $WEIGHTS_DIR</pre><p>Image below shows input and generated molecule structures. It is admirable how well ProGAN had learned input vector and generated pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*pmMiDJgH7wfFvrn3MCszdw.png" /><figcaption>Inspiration Generation</figcaption></figure><h3>Future Work</h3><p>The model trained above will generate random molecular structures. This work can be easily extended by using <a href="https://arxiv.org/abs/1711.05772">LC GAN</a> to generate molecules with certain attributes by constraining the latent space of a Variational Autoencoder (VAE) with a separate GAN trained in latent space. This model can also be trained on 3D molecular structures. Output of this model can be fed to another model that can validate and predict the properties of the generated molecular structures. All these methods are currently being pursued by <a href="https://medium.com/u/a0a8fdb128d4">MIT-IBM Watson AI Lab</a>.</p><p>Due to open accessibility to information, data and resources any individual can pursue the research for new technologies.</p><h3>Acknowledgement</h3><p>I am indebted to open source communities on whose work and knowledge this article depend. I thank Preeti Gupta, professor of Chemistry, for giving me crash course in functional group classification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10e0e1f89568" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/molecule-synthesis-using-ai-10e0e1f89568">Molecule synthesis using AI</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>