Ninja Coding
Open in Telegram
Hey there! This is channel where I pick up hacks and tricks in the world of programming. Join me on this wild ride of skill-building! "A genius, huh? What does that mean?... I work hard and I never give up! That is my gift, that is my ninja way!"
Show moreThe country is not specifiedTechnologies & Applications49 115
262
Subscribers
No data24 hours
No data7 days
No data30 days
Posts Archive
262
Hey there, Ninjas π₯·!
I've just dropped a new video all about working with pictures using Python. We're starting off easy, talking about the basics of colorful images, so you can get the hang of using Python's visual tools.
I'd really appreciate it if you could swing by YouTube and give it a watch. Your support means a lot to me and keeps me fired up to make more cool stuff. And guess what? There's more cool stuff on the way!
In future videos, we're going to dive into some really neat tricks in data science, like clustering , dimensionality reduction techniques. Plus, we'll get into this whole world of neural networks, where we'll learn how to do image denoising, image segmentation, upscaling and a lot other different tricks.
So, stay tuned! We're just getting started on this awesome journey together. #ImageProcessing
https://youtu.be/wgdUA8cJY7U?feature=shared
262
Before you set off on your adventure, it's super helpful to have a clear path to follow. I've stumbled upon this fantastic roadmap for sharpening your skills in Machine Learning and Data Science. You can dive into the interactive version right through this link.
In my mind here are five most important components of becoming a machine learning specialist:
1. Foundational Knowledge: Understand math concepts like linear algebra, calculus, and statistics.
2. Programming Skills: Learn Python or R and popular ML libraries like TensorFlow and scikit-learn.
3. Algorithms: Master common ML algorithms and their applications.
4. Data Preprocessing: Know how to clean, preprocess, and engineer features in data.
5. Practical Experience: Gain hands-on experience through projects, Kaggle competitions, or open-source contributions.
Letβs start our journey
#ML #DataScience
262
Hey there! It seems like a lot of people are really into machine learning and data science. So, how about we steer our dojo to focus more in this exciting area?
262
Hey Ninjas π₯·! What are you most interested in learning about Programming?
If you are interested in something else let me know in the comments
262
+5
Hey there! Today, I wanted to chat a little bit about something I've noticed in Python. You see, I do a lot of my programming in Python and R. And there's this nifty package in R, ggplot2, which is just awesome for creating all sorts of plots. Now, Python has matplotlib, which is super powerful, but once I got a taste of ggplot2, it's been tough to go back. I've searched high and low for ggplot2 wrappers in Python, but they always seem to have a few drawbacks. Below, I've attached a few examples of plots that you can whip up with ease in R. I've even included the code in the comments so you can see just how neat and tidy ggplot2 makes things.
262
+4
Can we analyze text from the Dune book using Python?
Absolutely. Up next is an example of how I used the nltk package to identify the most frequent words in the Dune book, followed by a visualization of these words in a word cloud.
262
I want to tell you about one cool package which is called NLTK (stands for natural language toolkit). This is a powerful library in Python used for working with human language data (text). Here, we'll cover some basic text processing tasks such as tokenization, stemming, and removing stop words.
Installation:
pip install nltk
Tokenization:
Tokenization is the process of breaking down text into individual words or sentences.
import nltk
nltk.download('punkt')
from nltk.tokenize import word_tokenize, sent_tokenize
text = "NLTK is a leading platform for building Python programs to work with human language data."
# Tokenizing the text into sentences
sentences = sent_tokenize(text)
print("Sentences:", sentences)
# Tokenizing the text into words
words = word_tokenize(text)
print("Words:", words)
Removing Stop Words:
Stop words are common words that usually do not carry significant meaning and can be removed from the text.
nltk.download('stopwords')
from nltk.corpus import stopwords
stop_words = set(stopwords.words('english'))
filtered_words = [word for word in words if word.lower() not in stop_words and word.isalpha()]
print("Filtered Words:", filtered_words)
Stemming:
Stemming reduces words to their root form.
from nltk.stem import PorterStemmer
ps = PorterStemmer()
stemmed_words = [ps.stem(word) for word in filtered_words]
print("Stemmed Words:", stemmed_words)
With NLTK, you can perform these essential text processing tasks efficiently, paving the way for more advanced natural language processing projects.262
I excited to share my latest YouTube video: "Image Processing with Python: Basics about Images." If you've ever been curious about diving into data analysis, this is a perfect start! Image processing isn't just powerfulβit's a visually engaging way to see the results of your coding in real time, making learning so much smoother. Check it out and let's decode the magic behind images together! Don't forget to like and subscribe for more cool content like this. Catch you in the video!
https://youtu.be/LdPITDzeVgk?feature=shared
262
Hey, Coding Ninjas!
Weβve hit 128 subscribers! Your dedication and passion are truly inspiring. Letβs keep coding and conquering together!
Thank you, coding warriors! π₯π»
262
Hey Ninja Coders!
Letβs check today the powerful combination of list comprehensions and the
any and all functions in Python.
Reminder about list comprehensions.
List comprehensions provide a concise way to create lists. Here's a quick example:
# Create a list of squares
squares = [x**2 for x in range(10)]
print(squares)
# Output: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Using `any` with List Comprehensions
The `any` function checks if at least one element in an iterable is `True`. Let's see it in action with a list comprehension:
# Check if any number in the list is even
numbers = [1, 3, 5, 7, 8]
has_even = any(num % 2 == 0 for num in numbers)
print(has_even)
# Output: True
Using `all` with List Comprehensions
The `all` function checks if all elements in an iterable are `True`. Hereβs how you can use it with a list comprehension:
# Check if all numbers in the list are positive
numbers = [1, 2, 3, 4, 5]
all_positive = all(num > 0 for num in numbers)
print(all_positive)
# Output: True
Use `any` and `all` with list comprehensions to make your code more readable and expressive. Theyβre perfect for quick checks and validations.262
I'd like to share how I use Notion as a programmer. Occasionally, I encounter similar tasks that are not frequent enough for me to memorize their solutions. This is where Notion becomes extremely useful. I have specific pages with code snippets that I can easily find and reuse later. Notion provides excellent support for formatting code snippets in various programming languages. The screenshot I provided shows an example of how I parallelize tasks in the R programming language on a Windows system.
I also appreciate the straightforward process of sharing my Notion pages with others. For instance, I often share lectures with students using this tool. You can find an example of a Notion page I used for organizing lecture material in the attached link.
https://svitnote.notion.site/Short-introduction-to-K-means-and-NMF-06fe810971fa4d629fa0301c39128aec
262
+1
docstring + chat-gpt = β€οΈ
I typically avoid specifying docstrings for my functions. Fortunately, the team at OpenAI developed Chat-GPT, which simplifies the process substantially. The attached images illustrate a function I provided to Chat-GPT, followed by the automatically generated docstring for my function. I wrote the function for converting a Windows path to a WSL-Ubuntu style.
This is a basic example, and there may be mistakes that the programmer should check. However, this can serve as a good starting point that can be adjusted later to fit your preferences.262
+1
Let's discuss two tools that enable us to create virtual environments:
1. venv:
- Purpose: Built-in to Python (since Python 3.3), `venv` is used to create lightweight, isolated Python environments.
- Functionality: It creates a virtual environment within your project directory, allowing you to install packages without affecting the system-wide Python installation.
2. Conda:
- Purpose: Conda is a cross-platform package and environment manager, primarily used in data science and scientific computing.
- Functionality: It manages not only Python packages but also packages from other languages like R, C/C++, and Java. Conda environments are more heavyweight than venv as they include not only Python packages but also system-level dependencies.
262
I often try to draw analogies from real life to explain programming concepts. Occasionally, I see Airbnb advertisements, and one of their videos perfectly illustrates the concept of virtual environments. Here's how I interpret virtual environments in Python:
Imagine your computer as a big house, and each project or task you work on as a separate room within that house. Now, just like in a house, you wouldn't want to clutter one room with all kinds of stuff from different tasks. Similarly, in programming, you don't want to clutter your system-wide Python installation with all the libraries and dependencies from every project you work on.
Here's where Python virtual environments come into play. Think of a virtual environment as creating a separate, isolated room within your house for each project. In each room, you can have whatever furniture and decorations you need for that specific project, without affecting the other rooms.
So, when you create a virtual environment for a Python project, you're essentially creating a self-contained space where you can install the specific versions of libraries and dependencies that are required for that project, without worrying about conflicts with other projects.
This way, each project has its own space to work in, and you can keep everything organized and separate, just like having different rooms in a house for different tasks.
262
Here are 5 tricks that Iβm using all the time in my Python scripts:
1. List Comprehensions: There are concise ways to create lists.
2. Dictionary Comprehension: Similar to list comprehensions, but for dictionaries.
3. Using `zip`: Allows you to iterate over multiple iterables simultaneously.
4. Unpacking: You can unpack iterables into variables easily.
5. `enumerate`: It allows you to loop over an iterable while keeping track of the index.
262
I recently saw an instagram reel about color transferring in videos, where the major colors of one scene were transferred to another. It piqued my curiosity, so I explored it further. I came across a paper that presented the concept of color transferring, inspiring me to create a script for transferring colors between two frames. Here is the link to paper: https://www.cs.tau.ac.il/~turkel/imagepapers/ColorTransfer.pdf
In the attached image, the first frame is the source we want to adjust, and the second is the reference from which we want to transfer colors to our source. The final image shows the result after applying the color transfer method outlined in the paper. I'm quite pleased with the outcome.
Currently, I'm working on applying the same process to videos instead of static frames. I'll share the results soon. You can find my current code (which may contain bugs) in the comment section.
262
You can find the video with process of my programming here: https://youtu.be/J1132pW0obI?si=y0jFQZDmHg8EPj5a
262
+1
Lately, I gave a shot at turning images into ASCII art. The basic idea was pretty straightforward. I just needed three tools:
matplotlib, numpy, and scikit-image. But, I hit a few bumps along the way, especially when it came to showing the text. I ended up using the pycairo package for that. Here's a peek at what I finally came up with!262
Three main components of the algorithm:
1. Initial Centroids: Initially, the algorithm needs to determine the starting points for the clusters. These starting points are called centroids. The number of centroids is determined by the user-defined parameter 'k', which specifies the desired number of clusters.
2. Assignment Step: In this step, each data point is assigned to the nearest centroid based on a distance metric, commonly the Euclidean distance. This assignment step forms the clusters.
3. Update Step: After the assignment step, the centroids are updated to be the mean of all the data points assigned to each centroid. This process iterates until the centroids no longer change significantly or until a specified number of iterations is reached.
