<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: yuval mehta</title>
    <description>The latest articles on Forem by yuval mehta (@yuval728).</description>
    <link>https://forem.com/yuval728</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1520449%2F2e1dc912-4ea1-4527-a261-d27dd995c7df.jpg</url>
      <title>Forem: yuval mehta</title>
      <link>https://forem.com/yuval728</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yuval728"/>
    <language>en</language>
    <item>
      <title>I Built a Free Web App with Tools Students Actually Need</title>
      <dc:creator>yuval mehta</dc:creator>
      <pubDate>Thu, 29 May 2025 13:01:49 +0000</pubDate>
      <link>https://forem.com/yuval728/i-built-a-free-web-app-with-tools-students-actually-need-4nf2</link>
      <guid>https://forem.com/yuval728/i-built-a-free-web-app-with-tools-students-actually-need-4nf2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As a developer and student, I constantly found myself searching for simple online tools like paraphrasers, calculators, or essay expanders. Most of what I found was either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Overcomplicated
&lt;/li&gt;
&lt;li&gt;Hidden behind paywalls
&lt;/li&gt;
&lt;li&gt;Required sign-up just to access basic features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This made me realize there’s room for a better solution—something clean, fast, and genuinely useful. That’s what inspired &lt;strong&gt;Tools for Students&lt;/strong&gt;: a no-login suite of web tools designed to help students be more productive.&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://toolsforstudents.netlify.app" rel="noopener noreferrer"&gt;https://toolsforstudents.netlify.app&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is “Tools for Students”?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tools for Students&lt;/strong&gt; is a growing collection of browser-based utilities tailored to academic needs. These tools are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instant-use: No login or registration required
&lt;/li&gt;
&lt;li&gt;Lightweight and mobile-friendly
&lt;/li&gt;
&lt;li&gt;Designed with performance and usability in mind&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Tools Available
&lt;/h2&gt;

&lt;p&gt;Here are some of the tools currently live:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Paraphrasing Tool&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Helps reword text for essays and assignments while preserving meaning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Essay Expander&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Adds depth and elaboration to brief essay content, useful for drafts and brainstorming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GPA Calculator&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Calculates weighted or unweighted GPA quickly and accurately.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Basic Calculator&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Simple math operations, always one click away.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Upcoming tools include a text summarizer, citation builder, and grammar checker.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Project Matters
&lt;/h2&gt;

&lt;p&gt;Most online tools either overcomplicate the experience or gatekeep basic functionality behind accounts or paywalls. This project takes a different approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Everything runs in the browser
&lt;/li&gt;
&lt;li&gt;No accounts or personal data needed
&lt;/li&gt;
&lt;li&gt;Designed specifically for student workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s built with simplicity and speed at the core.&lt;/p&gt;




&lt;h2&gt;
  
  
  Technical Overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend Only&lt;/strong&gt;: HTML, Tailwind CSS, and lightweight JS Framework&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting&lt;/strong&gt;: Deployed on Netlify as a static site
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Optimized for fast loading and minimal page weight
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Backend&lt;/strong&gt;: Tools operate entirely in-browser, which also makes maintenance easier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This architecture keeps hosting costs low while ensuring high availability.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Expanding the number of tools
&lt;/li&gt;
&lt;li&gt;Adding keyboard shortcuts and UI refinements
&lt;/li&gt;
&lt;li&gt;Integrating more educational utilities based on feedback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're a student or educator, give it a try and let me know what else you'd like to see.&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://toolsforstudents.netlify.app" rel="noopener noreferrer"&gt;Visit Tools for Students&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Evolve Your Machine Learning: Automate the Process of Model Selection through TPOT.</title>
      <dc:creator>yuval mehta</dc:creator>
      <pubDate>Sat, 06 Jul 2024 18:45:10 +0000</pubDate>
      <link>https://forem.com/yuval728/evolve-your-machine-learning-automate-the-process-of-model-selection-through-tpot-4445</link>
      <guid>https://forem.com/yuval728/evolve-your-machine-learning-automate-the-process-of-model-selection-through-tpot-4445</guid>
      <description>&lt;p&gt;One day, I google for optimizing my machine learning projects and I came across the TPOT library. Based on the genetic algorithms, TPOT stands for Tree-based Pipeline Optimization Tool, is an automatic way to select the model and tune hyperparameters. More information regarding TPOT, its features and a step by step guide on how to use TPOT to automate your machine learning process shall be discussed in this blog.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk8ixmi6d5bc23jp3ffq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk8ixmi6d5bc23jp3ffq.png" alt="Tpot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is TPOT?&lt;/strong&gt;&lt;br&gt;
TPOT is a Python library that utilizes genetic programming to optimize the pipeline of machine learning. It deals with two problems that are otherwise time-consuming, that is; model selection and hyperparameter tuning so that the data scientists can find better solutions to ostensibly problematic tasks. TPOT has several models to choose from and the hyperparameters of the models are dynamically optimised with new best pipelines being incorporated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of TPOT&lt;/strong&gt;&lt;br&gt;
Automation: TPOT optimizes the selection of models and the tuning of the hyperparameters of the chosen models themselves.&lt;br&gt;
Genetic Programming: Uses genetic algorithms to solve the problem of the evolution of machine learning pipelines.&lt;br&gt;
Scikit-Learn Compatibility: TPOT is designed to be highly flexible, is implemented in Python, and leverages scikit-learn which should integrate well into most pipelines.&lt;br&gt;
Customizability: Users can can also set their personalized operators and pipeline settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F299mlr7qlru1pg5xehua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F299mlr7qlru1pg5xehua.png" alt="example Machine Learning pipeline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How TPOT Works&lt;/strong&gt;&lt;br&gt;
In the case of TPOT, it applies genetic programming so as to evolve the machine learning pipelines. Starting with a set of random pipelines and then using selection, crossover, and mutation, it improves the pipelines. The fitness function is a key element of the process since it provides assessment of the pipelines’ performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89m9yg6dbwbps31ho69u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89m9yg6dbwbps31ho69u.png" alt="workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started with TPOT&lt;/strong&gt;&lt;br&gt;
Now let us consider the steps of setting up TPOT as the tool to automate the most of the ML processes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Installing TPOT&lt;br&gt;
You can install TPOT using pip:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

pip install tpot


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Importing Necessary Libraries&lt;br&gt;
Once installed, you can import TPOT and other necessary libraries.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from tpot import TPOTClassifier


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Loading and Preparing Data&lt;br&gt;
I am using gamma-telescope data which I found in Kaggle datasets&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

telescope=pd.read_csv('/kaggle/input/magic-gamma-telescope-dataset/telescope_data.csv')
telescope.drop(telescope.columns[0],axis=1,inplace=True)
telescope.head()


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

telescope_shuffle=telescope.iloc[np.random.permutation(len(telescope))]
telescope=telescope_shuffle.reset_index(drop=True)
telescope['class']=telescope['class'].map({'g':0,'h':1})


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsehqunmvjiewcb657bb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsehqunmvjiewcb657bb8.png" alt="Data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Configuring and Running TPOT&lt;br&gt;
Configure the TPOT classifier and fit it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

tele_class = telescope['class'].values
tele_features = telescope.drop('class',axis=1).values
training_data, testing_data, training_classes, testing_classes = train_test_split(tele_features, tele_class, test_size=0.25, random_state=42, stratify=tele_class)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

tpot = TPOTClassifier(generations=5,verbosity=2)
tpot.fit(training_data, training_classes)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx77kqulql3fhsl5kachb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx77kqulql3fhsl5kachb.png" alt="Output of tpot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;: Evaluating the Best Pipeline&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

tpot.score(testing_data, testing_classes)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryjvpg9xf0pvbdvid18h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fryjvpg9xf0pvbdvid18h.png" alt="score"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;: Understanding the Output&lt;br&gt;
The export function saves the best pipeline as a Python script&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import os
os.makedirs('Output',exist_ok=True)
tpot.export('Output/tpot_pipeline.py')


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Output file (tpot_pipeline.py):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import RobustScaler
from tpot.builtins import ZeroCount

# NOTE: Make sure that the outcome column is labeled 'target' in the data file
tpot_data = pd.read_csv('PATH/TO/DATA/FILE', sep='COLUMN_SEPARATOR', dtype=np.float64)
features = tpot_data.drop('target', axis=1)
training_features, testing_features, training_target, testing_target = \
            train_test_split(features, tpot_data['target'], random_state=None)

# Average CV score on the training set was: 0.8779530318962496
exported_pipeline = make_pipeline(
    ZeroCount(),
    RobustScaler(),
    MLPClassifier(alpha=0.001, learning_rate_init=0.01)
)

exported_pipeline.fit(training_features, training_target)
results = exported_pipeline.predict(testing_features)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
TPOT is a significant tool based on the application of genetic algorithms, which helps to solve the task of automatic finding of the optimal structure of the machine learning pipeline. Therefore, by automating the process by bringing TPOT into your development environment, you can cut out the time devoted to model selection or fine-tuning of hyperparameters in favor of more intricate operations of your tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/EpistasisLab/tpot" rel="noopener noreferrer"&gt;TPOT Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Genetic_programming" rel="noopener noreferrer"&gt;Genetic Programming&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>ai</category>
    </item>
    <item>
      <title>Unleashing GPU Power: Supercharge Your Data Processing with cuDF</title>
      <dc:creator>yuval mehta</dc:creator>
      <pubDate>Fri, 21 Jun 2024 11:12:49 +0000</pubDate>
      <link>https://forem.com/yuval728/unleashing-gpu-power-supercharge-your-data-processing-with-cudf-2232</link>
      <guid>https://forem.com/yuval728/unleashing-gpu-power-supercharge-your-data-processing-with-cudf-2232</guid>
      <description>&lt;p&gt;This time, while randomly scrolling through some blog post about the latest AI advancement and its capabilities, I found out about cuDF , which is part of the family of software libraries and APIs called RAPIDS for accelerating data operations and Machine Learning on GPUs. During data feeding, cuDF allows for the parallel processing on NVIDIA GPUs which, in turn, may be effective in large data operations. The next blog will give an overview as what cuDF is, major current functionalities related to cuDF and how to perform data manipulation using cuDF.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj5fftqdnihtzbn54857.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdj5fftqdnihtzbn54857.png" alt="Rapids cuDF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is cuDF?
&lt;/h2&gt;

&lt;p&gt;cuDF is a GPU DataFrame library which is pandas like for handling data on GPU. It enables data scientists and engineers to work with large amounts of data and carry out in-memory processing, thus it is ideal for pre-processing steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of cuDF
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;High Performance: Due to the use of the GPUs, the cuDF is able to perform data operations faster than that of the other CPU based libraries.&lt;/li&gt;
&lt;li&gt;Pandas Compatibility: cuDF is built to have a similar interface to pandas so that users of pandas do not have to learn how to use a new system but can transfer over to using the GPU-based system instead.&lt;/li&gt;
&lt;li&gt;Seamless Integration: cuDF is interoperable with other tensor libraries in the RAPIDS ecosystem such as cuML for machine learning and cuGraph for graph analytics.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Getting Started with cuDF
&lt;/h2&gt;

&lt;p&gt;Now, without further ado, let’s go over the basic setup and how to use cuDF for data manipulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Installing cuDF&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First of all, it is necessary to mention that the use of cuDF is possible in case if the user has a proper NVIDIA GPU, as well as the suitable version of CUDA toolkit. Accordingly, you can download it from &lt;a href="https://docs.rapids.ai/install" rel="noopener noreferrer"&gt;Rapids AI &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the command which I got from Rapids AI installation guide for my system&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

conda create -n rapids-24.06 -c rapidsai -c conda-forge -c nvidia  \
    rapids=24.06 python=3.11 cuda-version=12.2


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Importing cuDF&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import cudf
import numpy as np
import pandas as pd


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Creating a cuDF DataFrame&lt;/strong&gt;&lt;br&gt;
You can create a cuDF DataFrame from various data sources, including pandas DataFrames, CSV files, and more.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# Create a cuDF DataFrame from a pandas DataFrame
pdf = pd.DataFrame({
    'a': np.random.randint(0, 100, size=10),
    'b': np.random.random(size=10)
})
gdf = cudf.DataFrame.from_pandas(pdf)
print(gdf)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Data Manipulation with cuDF&lt;/strong&gt;&lt;br&gt;
cuDF provides a rich set of functions for data manipulation, similar to pandas.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# Adding a new column
gdf['c'] = gdf['a'] + gdf['b']

# Filtering data
filtered_gdf = gdf[gdf['a'] &amp;gt; 50]

# Grouping and aggregation
grouped_gdf = gdf.groupby('a').mean()
print(grouped_gdf)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Reading and Writing Data&lt;/strong&gt;&lt;br&gt;
cuDF supports reading from and writing to various file formats, such as CSV, Parquet, and ORC.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# Reading from a CSV file
gdf = cudf.read_csv('data.csv')

# Writing to a Parquet file
gdf.to_parquet('output.parquet')


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Performance Comparison with Pandas&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import time

# Create a large pandas DataFrame
pdf = pd.DataFrame({
    'a': np.random.randint(0, 100, size=100000000),
    'b': np.random.random(size=100000000)
})

# Create a cuDF DataFrame from the pandas DataFrame
gdf = cudf.DataFrame.from_pandas(pdf)

# Timing the pandas operation
start = time.time()
pdf['c'] = pdf['a'] + pdf['b']
end = time.time()
print(f"Pandas operation took {end - start} seconds")

# Timing the cuDF operation
start = time.time()
gdf['c'] = gdf['a'] + gdf['b']
end = time.time()
print(f"cuDF operation took {end - start} seconds")


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyp2p2r94eou7gwfzg2ji.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyp2p2r94eou7gwfzg2ji.png" alt="Comparison output"&gt;&lt;/a&gt;&lt;br&gt;
From the image we can see that cuDF is 40 times more faster than pandas&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Using cuDF as a no-code-change accelerator for pandas&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

%load_ext cudf.pandas 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# Pandas operations now use the GPU!
import pandas as pd
import time

# Create a large pandas DataFrame
pdf = pd.DataFrame({
    'a': np.random.randint(0, 100, size=100000000),
    'b': np.random.random(size=100000000)
})

# Timing the pandas operation with cudf.pandas
start = time.time()
pdf['c'] = pdf['a'] + pdf['b']
end = time.time()
print(f"Pandas operation with cuDF loaded took {end - start} seconds")


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ydbyj1ixdm6ifrv3kov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ydbyj1ixdm6ifrv3kov.png" alt="Result"&gt;&lt;/a&gt;&lt;br&gt;
We can see from the image that it gives almost similar performance compared to using cuDF APIs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt; &lt;br&gt;
cuDF is the equipping methodology to speed up data processing pipelines by using the parallel computing system, GPUs. This is the tool’s biggest strength: Since its usage directly corresponds with pandas, users can switch and start enjoying the performance improvements quickly. Thus, with the help of cuDF lets incorporate it in data science movement, which will help to work with larger datasets and perform complex operations faster than conventional computers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/rapidsai/cudf" rel="noopener noreferrer"&gt;cuDF Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rapids.ai/" rel="noopener noreferrer"&gt;RAPIDS AI
&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have any questions about cuDF or if you have used it in your project in the past then please feel free to drop the questions and/or experiences in the comments section below. Happy computing!&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>data</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>From Noise to Art: Building Your First Generative Adversarial Network</title>
      <dc:creator>yuval mehta</dc:creator>
      <pubDate>Mon, 17 Jun 2024 13:00:06 +0000</pubDate>
      <link>https://forem.com/yuval728/from-noise-to-art-building-your-first-generative-adversarial-network-472o</link>
      <guid>https://forem.com/yuval728/from-noise-to-art-building-your-first-generative-adversarial-network-472o</guid>
      <description>&lt;p&gt;I was introduced to this splendid machine learning idea known as Generative Adversarial Networks (GANs) especially in the image generation area. Another framework known as GANs was developed by Ian Goodfellow in 2014; its underlying architecture is built by utilizing a two-neural-network competition. According to the scope of this blog, let me first introduce what GAN is, and then tell you what I am going to do in this blog including the code in TensorFlow about how to train a simple GAN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi0yu4jhpe12gnmby1hst.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi0yu4jhpe12gnmby1hst.png" alt="Architecture" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are GANs?&lt;/strong&gt;&lt;br&gt;
At its core, a GAN consists of two neural networks: Of course, there is the generator of the fake data, and the discriminator that learns how to distinguish between the fake and the real thing. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generator: After inputting noise and then passes them to produce an output data that resembles the pattern of the training data set. &lt;/li&gt;
&lt;li&gt;Discriminator: The discriminator employed in the description of this model takes an input sample and tries to afford a guess if the sample was drawn from the training data or was just synthesized with the help of the generator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These two networks are trained simultaneously in a zero-sum game framework: while in GANs the generative network will feed information to the discriminative network in an effort to fool it into believing that the data fed to it is real but on the other side the discriminative network has the role of distinguishing real data from fake data. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0v4kkhn0e8r2l53dszq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm0v4kkhn0e8r2l53dszq.png" alt="Example" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Guide to Building a Simple GAN&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Step 1: Setting Up the Environment&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install tensorflow&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 2: Import Necessary Libraries&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import tensorflow as tf
from tensorflow.keras import layers
import numpy as np
import matplotlib.pyplot as plt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Define the Generator&lt;/p&gt;

&lt;p&gt;The generator network will next take a randomly chosen noise vector and map it into a data point that looks like the actual training data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def build_generator():
    model = tf.keras.Sequential()
    model.add(layers.Dense(8*8*128, use_bias=False, input_shape=(100,)))
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())
    model.add(layers.Reshape((8, 8, 128)))
    assert model.output_shape == (None, 8, 8, 128)  # Note: None is the batch size

    model.add(layers.Conv2DTranspose(128, (5, 5), strides=(1, 1), padding='same', use_bias=False))
    assert model.output_shape == (None, 8, 8, 128)
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())

    model.add(layers.Conv2DTranspose(128, (5, 5), strides=(2, 2), padding='same', use_bias=False))
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())
    assert model.output_shape == (None, 16, 16, 128)

    model.add(layers.Conv2DTranspose(128, (5, 5), strides=(2, 2), padding='same', use_bias=False))
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())
    assert model.output_shape == (None, 32, 32, 128)

    model.add(layers.Conv2DTranspose(128, (5, 5), strides=(2, 2), padding='same', use_bias=False))
    model.add(layers.BatchNormalization())
    model.add(layers.LeakyReLU())
    assert model.output_shape == (None, 64, 64, 128)

    model.add(layers.Conv2DTranspose(3, (5, 5), strides=(2, 2), padding='same', use_bias=False, activation='tanh'))
    print(model.output_shape)

    return model

generator = build_generator()
generator.summary()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Define the Discriminator&lt;/p&gt;

&lt;p&gt;The discriminator network will take an input sample and classify it as real&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def build_discriminator():
    model = tf.keras.Sequential()
    model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',
                                     input_shape=[128, 128, 3]))
    model.add(layers.LeakyReLU())
    model.add(layers.Dropout(0.3))

    model.add(layers.Conv2D(128, (5, 5), strides=(2, 2), padding='same'))
    model.add(layers.LeakyReLU())
    model.add(layers.Dropout(0.3))

    model.add(layers.Conv2D(256, (5, 5), strides=(2, 2), padding='same'))
    model.add(layers.LeakyReLU())
    model.add(layers.Dropout(0.3))

    model.add(layers.Flatten())
    model.add(layers.Dense(1))
    return model

discriminator = build_discriminator()
discriminator.summary()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5: Test the models&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;noise = tf.random.normal([1,100])
generated_image = generator(noise,training=False)
print(discriminator(generated_image))
plt.imshow(generated_image[0]*127.5+127.5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 6: Setup loss function and optimizer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cross_entropy=BinaryCrossentropy(from_logits=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def discriminator_loss(real_output,fake_output):
  real_loss = cross_entropy(tf.ones_like(real_output),real_output)
  fake_loss = cross_entropy(tf.zeros_like(fake_output),fake_output)
  total_loss = real_loss + fake_loss
  return total_loss

def generator_loss(fake_output):
  return cross_entropy(tf.ones_like(fake_output),fake_output)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generator_optimizer = tf.keras.optimizers.Adam(1e-4)
discriminator_optimizer = tf.keras.optimizers.Adam(1e-4)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 7: Setup checkpoint&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;checkpoint_dir = 'training_checkpoints'
checkpoint_prefix = os.path.join(checkpoint_dir,'ckpt')
checkpoint = tf.train.Checkpoint(generator_optimizer=generator_optimizer,
                                 discriminator_optimizer=discriminator_optimizer,
                                 generator=generator,
                                 discriminator=discriminator)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 8: Defining train step&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@tf.function
def train_step(images):

    noise=tf.random.normal([batch_size,noise_dims])

    with tf.GradientTape() as gen_tape, tf.GradientTape() as dis_tape:
        generated_images=generator(noise,training=True)

        real_output=discriminator(images,training=True)
        fake_output=discriminator(generated_images,training=True)

        gen_loss=generator_loss(fake_output)
        disc_loss=discriminator_loss(real_output,fake_output)

    gen_gradients=gen_tape.gradient(gen_loss,generator.trainable_variables)
    dis_gradients=dis_tape.gradient(disc_loss,discriminator.trainable_variables)

    generator_optimizer.apply_gradients(zip(gen_gradients,generator.trainable_variables))
    discriminator_optimizer.apply_gradients(zip(dis_gradients,discriminator.trainable_variables))

    return gen_loss,disc_loss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 9: Setting up the training loop and saving generated images&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from IPython import display
import time

total_gloss=[]
total_dloss=[]
def train(dataset,epochs):
    for epoch in range(epochs):
        disc_loss=gen_loss=0
        start=time.time()
        count=0
        for batch in dataset:
            losses=train_step(batch)
            count+=1
            disc_loss+=losses[1]
            gen_loss+=losses[0]
        total_gloss.append(gen_loss.numpy())
        total_dloss.append(disc_loss.numpy())

        if (epoch+1)%50==0:
            checkpoint.save(file_prefix=checkpoint_prefix)
            display.clear_output(wait=True)
            generate_and_save_output(generator,epoch+1,seed)

        print(f'Time for epoch {epoch + 1} is {time.time()-start}')
        print(f'Gloss: {gen_loss.numpy()/count} , Dloss: {disc_loss.numpy()/count}',end='\n\n')
    display.clear_output(wait=True)
    generate_and_save_output(generator,epochs,seed)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def generate_and_save_output(model,epoch,test_input):

      predictions = model(test_input,training=False)
      fig = plt.figure(figsize=(4,4))
      for i in range(predictions.shape[0]):
        plt.subplot(4,4,i+1)
        plt.imshow((predictions[i]*127.5+127.5).numpy().astype(np.uint8),cmap='gray')
        plt.axis('off')
      plt.savefig(f'image_at_epoch_{epoch}.png')
      plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 10: Train the GAN&lt;/p&gt;

&lt;p&gt;Let's train our GAN, I have used dog image dataset, which is available on  &lt;a href="https://www.kaggle.com/datasets/jessicali9530/stanford-dogs-dataset"&gt;Kaggle stanford dog dataset&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EPOCHS = 500
noise_dims = 100
num_egs_to_generate = 16
seed = tf.random.normal([num_egs_to_generate,noise_dims])

train(train_images,EPOCHS)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: To generate good-quality images, the model would require large number of epochs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwctawbgiawgclxx1ud3d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwctawbgiawgclxx1ud3d.png" alt="Image at epoch 500" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Trying our model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new_image = generator(tf.random.normal([1,100]),training=False)
plt.imshow((new_image[0]*127.5+127.5).numpy().astype(np.uint8))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbith61tukcjnrcf2g44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbith61tukcjnrcf2g44.png" alt="Generated image" width="464" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
GANs are useful in producing realistic datasets since they are a type of neural network that learns from the labeled training data and then creates new data. From here, it would be clear and feasible to formulate a sensible GAN and from here it is evident that there exists a relative rhythm between the motions of the generator as well as Discriminator. This distills the current guide’s aim to merely introduce the reader to the subject of GAN and offer them a first taste of what is possible in this burgeoning research area. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://arxiv.org/abs/1406.2661"&gt;Ian Goodfellow's Original Paper&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.tensorflow.org/tutorials/generative/dcgan"&gt;TensorFlow Documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/yuval728/Dog-image-generation"&gt;My Github Repo&lt;/a&gt;&lt;br&gt;
Feel free to ask questions or share your GAN projects in the comments below!&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
