Jekyll2023-08-28T07:54:33+00:00https://suatatan.github.io/feed.xml😈Satan’s BlogNot a Satanic Blog. Just abbreviation of my name! Ideas, insights and notes. Dr. Suat ATANExploring SymPy: Your Gateway to Mathematical Formulas and Interactive Graphs2023-08-28T00:00:00+00:002023-08-28T00:00:00+00:00https://suatatan.github.io/2023/08/28/sympy<p>Mathematics is a language that describes the fundamental principles of the universe. It’s the key to unlocking the mysteries of our world, from understanding the motion of planets to predicting the behavior of financial markets. For mathematicians, scientists, engineers, and students alike, having a tool that can help with symbolic mathematics and visualization is invaluable. SymPy is one such tool, and it excels at showcasing pure mathematical formulas and interactively displaying their graphs.</p>
<h2 id="what-is-sympy">What is SymPy?</h2>
<p>SymPy, short for “Symbolic Python,” is an open-source Python library for symbolic mathematics. Unlike numerical computing libraries, like NumPy or SciPy, which deal with numerical approximations, SymPy focuses on symbolic computations. This means that it can represent mathematical expressions exactly as they are, without approximations. SymPy can handle a wide range of mathematical operations, including algebraic manipulations, calculus, solving equations, and more.</p>
<h2 id="showcasing-pure-mathematical-formulas">Showcasing Pure Mathematical Formulas</h2>
<p>SymPy makes it easy to work with mathematical expressions in their purest form. You can create symbols to represent variables, constants, and functions, and then manipulate these symbols symbolically. Here’s a simple example in Python:</p>
<pre><code class="language-python">from sympy import symbols, Eq, solve
# Define symbols
x, y = symbols('x y')
# Define an equation
eq = Eq(x**2 + y**2, 1)
# Solve the equation symbolically
solutions = solve(eq, y)
print(solutions)
</code></pre>
<p>In this example, we define two symbols, <code>x</code> and <code>y</code>, and create an equation <code>x**2 + y**2 = 1</code>. SymPy can solve this equation symbolically, giving us an expression for <code>y</code> in terms of <code>x</code>. This is just a glimpse of what SymPy can do; it can handle much more complex equations and expressions with ease.</p>
<p>To solve the equation (x^2 + y^2 = 1) symbolically using Python’s Sympy library, you can use the following code and result will be:</p>
<pre><code class="language-python">-sqrt(1 - x**2)
sqrt(1 - x**2)
</code></pre>
<h2 id="interacting-with-formulas">Interacting with Formulas</h2>
<p>SymPy’s interactive capabilities are a game-changer for anyone who wants to explore mathematical concepts dynamically. Jupyter notebooks, for instance, provide an excellent environment for this kind of exploration.</p>
<p>In a Jupyter notebook, you can evaluate and manipulate mathematical expressions step by step, seeing the intermediate results. This is incredibly useful for learning and experimentation. Here’s a quick example:</p>
<pre><code class="language-python">from sympy import symbols, expand, factor, simplify
from sympy.plotting import plot
# Define a symbol
x = symbols('x')
# Create a symbolic expression
expression = (x + 1)**2
# Expand the expression
expanded_expression = expand(expression)
# Factor the expanded expression
factored_expression = factor(expanded_expression)
# Simplify the factored expression
simplified_expression = simplify(factored_expression)
# Display the results
expanded_expression, factored_expression, simplified_expression
</code></pre>
<p>In this example, we start with a simple expression <code>(x + 1)^2</code> and perform step-by-step operations on it using SymPy. You can see the intermediate results as you go along.</p>
<h2 id="visualizing-mathematical-concepts">Visualizing Mathematical Concepts</h2>
<p>Besides manipulating and solving equations, SymPy can also help you visualize mathematical concepts through graphs and plots. The <code>sympy.plotting</code> module provides a simple and flexible way to create various types of plots.</p>
<pre><code class="language-python">from sympy.plotting import plot
from sympy.abc import x
# Create a basic plot
p1 = plot(x**2, show=False)
# Customize the plot
p1.title = 'Parabolic Curve'
p1.xlabel = 'x-axis'
p1.ylabel = 'y-axis'
# Show the plot
p1.show()
</code></pre>
<p>In this example, we use SymPy to create a plot of the function <code>x^2</code>. You can easily customize the plot’s appearance and add labels to make it more informative.</p>
<h2 id="conclusion">Conclusion</h2>
<p>SymPy is a powerful tool for mathematicians, scientists, engineers, and students who want to work with pure mathematical formulas and explore them interactively. Its ability to handle symbolic mathematics, solve equations, and create dynamic plots makes it an invaluable asset for anyone working in a mathematical or scientific field. Whether you’re a seasoned mathematician or just starting your mathematical journey, SymPy can be your trusted companion for exploring and understanding the beautiful world of mathematics.</p>Dr. Suat ATANMathematics is a language that describes the fundamental principles of the universe. It’s the key to unlocking the mysteries of our world, from understanding the motion of planets to predicting the behavior of financial markets. For mathematicians, scientists, engineers, and students alike, having a tool that can help with symbolic mathematics and visualization is invaluable. SymPy is one such tool, and it excels at showcasing pure mathematical formulas and interactively displaying their graphs.Using VertexAI Instead of OpenAI in LangChain2023-08-18T00:00:00+00:002023-08-18T00:00:00+00:00https://suatatan.github.io/2023/08/18/vertex-ai-langchain<p>So far, using VertexAI was nightmare for me due to setting the credientals. Finally, I found how it works. Just to remember and help users who are in the same situation.</p>
<p>As you see in the Section A in the code, only thing you need to set the path of your credientals JSON file. To access the file (in windows) you need to install gcloud.</p>
<p>Once you installed file you can open Windows explorer and set this code to there: <code>%APPDATA%\gcloud\</code> It will open the your path. You should see <code>application_default_credentials.json</code> file there. Then you can copy path and set in the section A</p>
<p>Once you did you’ll be able to access VertexAI and use as backend LLM.</p>
<pre><code class="language-python"># %%
from langchain.llms import VertexAI
from langchain import PromptTemplate, LLMChain
import os
# Section A
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = r"C:\Users\suat.atan\AppData\Roaming\gcloud\application_default_credentials.json"
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm = VertexAI()
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"
llm_chain.run(question)
# %%
</code></pre>Dr. Suat ATANSo far, using VertexAI was nightmare for me due to setting the credientals. Finally, I found how it works. Just to remember and help users who are in the same situation.Mastering Productivity and Self-Reflection: A Guide to Effective Daily Journaling2023-08-17T00:00:00+00:002023-08-17T00:00:00+00:00https://suatatan.github.io/2023/08/17/effective-journaling<p>In the fast-paced world we live in, finding ways to stay productive and maintain a sense of self-awareness can be a challenging task. One powerful technique that combines both aspects is daily journaling. In this blog post, we’ll delve into a comprehensive template that can transform your daily journaling practice into a powerhouse of productivity and self-reflection.</p>
<p>Actually, I developed this tecnique after being fatigue by the todo apps, project management tools etc. This approach is very powerful because I know that</p>
<blockquote>
<p>Writing is way of thinking.</p>
</blockquote>
<h2 id="the-daily-journaling-template">The Daily Journaling Template:</h2>
<p>The provided template serves as a roadmap to structure your day while keeping a record of your thoughts and activities. Let’s break down each component and understand its significa</p>
<p>🌄Date and location:
Today’s date: [Date]
Location: [Location]</p>
<p>☀️Daily Plan:
Today, I’m planning to focus on the following tasks and activities:</p>
<ol>
<li>[Task 1]</li>
<li>[Task 2]</li>
<li>[Task 3]</li>
</ol>
<p>🗝️Targeted Pomodoro Sessions:
I aim to complete [X] Pomodoro sessions today. Each session will be around 25 minutes of focused work followed by a 5-minute break.</p>
<p>🛑Pomodoro Planning and Tracking:
To stay on track with my Pomodoro sessions, I’ll use a timer and track completed sessions in my journal.</p>
<p>🚥Pause Note:
Remember to take short breaks to stretch, relax, and recharge throughout the day.</p>
<p>🌿Daily Notes:
Throughout the day, I’ll jot down important thoughts, insights, or observations that come up.</p>
<p>💡Ideas:
I’ll use this space to capture any creative ideas that emerge during the day.</p>
<p>📖Reading Recommendations:
For today’s reading, I have [Book Title] on my list. I aim to read [X] pages/chapters.</p>
<p>💎5-Minute Journal:
Taking just 5 minutes in the morning and evening, I’ll reflect on what I’m grateful for, what would make today great, and any affirmations.</p>
<p>☎️Contact:
I’ll make a call to [Person’s Name] to catch up and connect.</p>
<p>🌟Creative Journaling:
I’ll experiment with some creative journaling techniques to express my thoughts and feelings visually.</p>
<p>🎯Goal Journaling:
In a separate section, I’ll reaffirm my short-term and long-term goals, visualizing my progress.</p>
<p>🤗 What to do wrong today:
I learned this from the Maria Sharapova’s explanations. It is very interesting practice to practice. accept your wrongs before to do.</p>
<p>😬Accepted Stress Journal:
If stress arises, I’ll acknowledge and jot it down in my stress journal, focusing on accepting and managing it.</p>
<p>Remember, this template is designed to help structure my day and maintain a record of my thoughts and activities. It’s a tool to enhance productivity, self-awareness, and personal growth.</p>Dr. Suat ATANIn the fast-paced world we live in, finding ways to stay productive and maintain a sense of self-awareness can be a challenging task. One powerful technique that combines both aspects is daily journaling. In this blog post, we’ll delve into a comprehensive template that can transform your daily journaling practice into a powerhouse of productivity and self-reflection.Text Summarization with LangChain2023-08-17T00:00:00+00:002023-08-17T00:00:00+00:00https://suatatan.github.io/2023/08/17/summarization-with-llm<p>So far I have used the HuggingFace models to summarize long text. But after discovering LangChain’s extraction capabilities I tried to do an pipeline to summarize long text.</p>
<p>In this example my pipeline will summarize this paper: https://journals.sagepub.com/doi/epub/10.1177/23409444231185790
<em>Sensing, seizing, and reconfiguring dynamic capabilities in innovative firms: Why does strategic leadership make a difference?</em> is a academic paper and I don’t want read it at all. I’ll decide after the reading AI generated summary.</p>
<p>🤖 <strong>Unlocking the Magic of Document Summarization with Python!</strong> 📚🔍</p>
<p>Hey there, code wizards! 👋 Are you ready to dive into a world where your Python spells can turn lengthy documents into bite-sized nuggets of wisdom? 🧙♂️ Today, we’re going to unravel the mysteries of document summarization using a pinch of code and a sprinkle of AI fairy dust! ✨</p>
<p>🔮 <strong>The Quest for Knowledge</strong></p>
<p>Imagine you’ve stumbled upon a mystical text known as “sample-paper.pdf”. 📜 But, oh dear adventurer, it’s as thick as an ancient tome! Fear not, for we have a spell to split these pages into manageable chunks using the mighty PyPDFLoader! 📚✂️</p>
<pre><code class="language-python"># %% MR Read PDF
loader = PyPDFLoader("sample-paper.pdf")
pages = loader.load_and_split()
</code></pre>
<p>🌟 <strong>Forging the Index of Power</strong></p>
<p>Now that our pages are in hand, let’s forge an index that’ll make finding knowledge a breeze! Meet FAISS, a trusty tool that creates an index using the power of OpenAIEmbeddings! 🔍🔗</p>
<pre><code class="language-python"># %% MR Make Index
faiss_index = FAISS.from_documents(pages, OpenAIEmbeddings())
</code></pre>
<p>🔍 <strong>Seeking the Golden Nuggets</strong></p>
<p>Ever wished for a magical magnifying glass that finds the juiciest bits of information in the blink of an eye? Our FAISS index can do just that! 🕵️♀️ Let’s summon it to search for a specific incantation, “What about CEOs?”, and retrieve the top 5 results!</p>
<pre><code class="language-python"># %% MR Search
docs = faiss_index.similarity_search("What about CEOs?", k=5)
for doc in docs:
print(str(doc.metadata["page"]) + ":", doc.page_content[:300])
print("----")
</code></pre>
<p>📝 <strong>Summoning the Summary Sorcery</strong></p>
<p>But wait, there’s more! 🎩✨ Our enchanted code can also summarize these findings into beautiful, concise gems. With the power of OpenAI’s language model, we can create both regular summaries and bullet-point wonders! Let’s weave the magic:</p>
<pre><code class="language-python"># %% MR
llm = OpenAI(temperature=0)
map_prompt = """
Write a concise summary of the following:
"{text}"
CONCISE SUMMARY:
"""
map_prompt_template = PromptTemplate(template=map_prompt, input_variables=["text"])
combine_prompt = """
Write a concise summary of the following text delimited by triple backquotes.
Return your response in bullet points which covers the key points of the text.
```{text}```
BULLET POINT SUMMARY:
"""
combine_prompt_template = PromptTemplate(template=combine_prompt, input_variables=["text"])
summary_chain = load_summarize_chain(llm=llm,
chain_type='map_reduce',
map_prompt=map_prompt_template,
combine_prompt=combine_prompt_template,
)
mapreduce_output = summary_chain.run(docs)
</code></pre>
<p>🎉 <strong>Unveiling the Treasures</strong></p>
<p>And there you have it, fellow explorers! With a wave of your coding wand, you’ve tamed the wild words and unleashed their essence. From splitting ancient texts to summoning concise summaries, your journey has been nothing short of magical! 🌟✨</p>
<p>So go forth, brave coders! May your code be bug-free and your summaries be succinct. Remember, the world of AI and coding is as enchanting as the stories it unveils. Until next time, happy coding! 🚀🔥</p>
<hr />
<p>There you go! A playful and informative blog post that introduces the provided code in a whimsical manner. Feel free to customize and adjust the text as needed to match your style and preferences.</p>
<p>🎉 <strong>Bonus</strong></p>
<p>The AI gives me this result:</p>
<ul>
<li>This study examined the exploratory and exploitative learning, as well as the transactional and transformational leadership styles of CEOs in two departments (marketing and production).</li>
<li>Cronbach’s alpha coefficients were found to be .86, .71, and .84 for sensing, seizing, and reconfiguration capabilities respectively.</li>
<li>Exploratory and exploitative learning are related to sensing and seizing capabilities in both marketing and production departments.</li>
<li>Transformational leadership style was found to reinforce the relationship between exploratory learning and sensing capability in both departments.</li>
<li>Correlation and descriptive analyses showed positive relationships between OL, leadership style, and the DCs of the firm.</li>
<li>Multiple and hierarchical regression analysis was used to test hypotheses, and results showed a statistically significant relationship between exploratory learning and sensing capability for production departments, and a positive and statistically significant relationship between exploitative learning and sensing capability for marketing departments.</li>
</ul>Dr. Suat ATANSo far I have used the HuggingFace models to summarize long text. But after discovering LangChain’s extraction capabilities I tried to do an pipeline to summarize long text.Satan’s favorite NLP Packages List2023-08-15T00:00:00+00:002023-08-15T00:00:00+00:00https://suatatan.github.io/2023/08/15/nlp-packages-list<h3 id="spacy">SpaCy</h3>
<p>It is a natural language processing library in an industry setting. So much so that there are other subprojects written with it.</p>
<h3 id="lingfeat">lingFeat</h3>
<p>Written in space. For extracting information from text, including grammatical elements: https://spacy.io/universe/project/lingfeat</p>
<h3 id="neattext">NeatText</h3>
<p>A simple NLP package to clean up text data and text preprocessing. Simplifying Text Cleanup for NLP and ML https://pypi.org/project/neattext/</p>
<h3 id="lexrank">LexRank</h3>
<p>A network analysis-based algorithm: https://github.com/crabcamp/lexrank</p>
<p>Article: Güneş Erkan and Dragomir R. Radev: LexRank: Graph-based Lexical Centrality as Salience in Text Summarization.</p>
<h3 id="text2text">Text2Text</h3>
<p>A powerful algorithm that uses Facebook transformers but runs quite slowly, apart from text summarization, BM25 also includes a TF.IDF calculator. It also does translation and question creation. https://pypi.org/project/text2text/</p>
<p>A simple algorithm</p>
<p>For those who say it’s enough to do my job: https://towardsdatascience.com/simple-text-summarization-in-python-bdf58bfee77f</p>
<h3 id="textcaret">TextCaret</h3>
<p>It also includes a sentiment tool, visualization and text creation tool: https://pypi.org/project/textcaret/</p>
<h3 id="sumy">Sumy</h3>
<p>It’s a nice package that summarizes with algorithms like LexRank and TextRank: https://pypi.org/project/sumy/</p>
<h3 id="textnet">TextNet</h3>
<p>It is a package for extracting semantic networks: https://spacy.io/universe/project/textnets/</p>
<h3 id="negspace">Negspace</h3>
<p>Package for extracting negation elements https://github.com/jenojp/negspace</p>
<h3 id="mordecai">Mordecai</h3>
<p>Extraction location names from the text</p>Dr. Suat ATANSpaCyMy Time Management Tools and Resources2023-08-15T00:00:00+00:002023-08-15T00:00:00+00:00https://suatatan.github.io/2023/08/15/time-management-list<ul>
<li>yearcompass.com: New Year’s Plan Website</li>
<li>Sankalpa discovery: Yoga Nidra</li>
<li>Habit Tracker: Habit tracking (AppStore, Playstore)</li>
<li>The book called The Power of Habits; Charles Duhigg</li>
<li>Pomodoro Technique Theory: https://suatatan.wordpress.com/2020/01/07/pomodoro-teknigi-nedir</li>
<li>Pomodoro Technique Application: Productivity Challenge Timer (PlayStore, AppStore)</li>
<li>Getting Things Done by David Alen: Purge Day practice book</li>
<li>18 Minutes, Peter Bregman: Applying the 18-minute rule</li>
<li>Stayfocusd Chrome Explorer: Don’t block yourself</li>
<li>Concentration mode: Android settings</li>
<li>Digital balance: Android settings</li>
<li>Clickup: Planning software (Complex advanced)</li>
<li>Asana: Planning software (Intermediate)</li>
<li>Trello: Planning software (basic level)</li>
<li>Microsoft Todo: Planning software (Daily tasks)</li>
<li>Insight Timer: Meditation and work efficiency lessons</li>
<li>Any.do: Realistic and simple todo app</li>
</ul>Dr. Suat ATANyearcompass.com: New Year’s Plan Website Sankalpa discovery: Yoga Nidra Habit Tracker: Habit tracking (AppStore, Playstore) The book called The Power of Habits; Charles Duhigg Pomodoro Technique Theory: https://suatatan.wordpress.com/2020/01/07/pomodoro-teknigi-nedir Pomodoro Technique Application: Productivity Challenge Timer (PlayStore, AppStore) Getting Things Done by David Alen: Purge Day practice book 18 Minutes, Peter Bregman: Applying the 18-minute rule Stayfocusd Chrome Explorer: Don’t block yourself Concentration mode: Android settings Digital balance: Android settings Clickup: Planning software (Complex advanced) Asana: Planning software (Intermediate) Trello: Planning software (basic level) Microsoft Todo: Planning software (Daily tasks) Insight Timer: Meditation and work efficiency lessons Any.do: Realistic and simple todo app