Monday 18 March 2024
Friday 15 March 2024
The json library in Python
Python Coding March 15, 2024 Python No comments
The json library in Python
1. Encoding Python Data to JSON:
import json
# Python dictionary to be encoded to JSON
data = {
"name": "John",
"age": 30,
"city": "New York"
}
# Encode the Python dictionary to JSON
json_data = json.dumps(data)
print("Encoded JSON:", json_data)
#clcoding.com
Encoded JSON: {"name": "John", "age": 30, "city": "New York"}
2. Decoding JSON to Python Data:
import json
# JSON data to be decoded to Python
json_data = '{"name": "John", "age": 30, "city": "New York"}'
# Decode the JSON data to a Python dictionary
data = json.loads(json_data)
print("Decoded Python Data:", data)
#clcoding.com
Decoded Python Data: {'name': 'John', 'age': 30, 'city': 'New York'}
3. Reading JSON from a File:
clcoding
import json
# Read JSON data from a file
with open('clcoding.json', 'r') as file:
data = json.load(file)
print("JSON Data from File:", data)
#clcoding.com
JSON Data from File: {'We are supporting freely to everyone. Join us for live support. \n\nWhatApp Support: wa.me/919767292502\n\nInstagram Support : https://www.instagram.com/pythonclcoding/\n\nFree program: https://www.clcoding.com/\n\nFree Codes: https://clcoding.quora.com/\n\nFree Support: pythonclcoding@gmail.com\n\nLive Support: https://t.me/pythonclcoding\n\nLike us: https://www.facebook.com/pythonclcoding\n\nJoin us: https://www.facebook.com/groups/pythonclcoding': None}
4. Writing JSON to a File:
import json
# Python dictionary to be written to a JSON file
data = {
"name": "John",
"age": 30,
"city": "New York"
}
# Write the Python dictionary to a JSON file
with open('output.json', 'w') as file:
json.dump(data, file)
#clcoding.com
5. Handling JSON Errors:
import json
# JSON data with syntax error
json_data = '{"name": "John", "age": 30, "city": "New York"'
try:
# Attempt to decode JSON data
data = json.loads(json_data)
except json.JSONDecodeError as e:
# Handle JSON decoding error
print("Error decoding JSON:", e)
#clcoding.com
Error decoding JSON: Expecting ',' delimiter: line 1 column 47 (char 46)
Thursday 14 March 2024
Learn hashlib library in Python
Python Coding March 14, 2024 Python No comments
1. Hashing Strings:
import hashlib
# Hash a string using SHA256 algorithm
string_to_hash = "Hello, World!"
hashed_string = hashlib.sha256(string_to_hash.encode()).hexdigest()
print("Original String:", string_to_hash)
print("Hashed String:", hashed_string)
#clcoding.com
Original String: Hello, World!
Hashed String: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f
2. Hashing Files:
#clcoding.com
import hashlib
def calculate_file_hash(file_path, algorithm='sha256'):
# Choose the hash algorithm
hash_algorithm = getattr(hashlib, algorithm)()
# Read the file in binary mode and update the hash object
with open(file_path, 'rb') as file:
for chunk in iter(lambda: file.read(4096), b''):
hash_algorithm.update(chunk)
# Get the hexadecimal representation of the hash value
hash_value = hash_algorithm.hexdigest()
return hash_value
# Example usage
file_path = 'example.txt'
file_hash = calculate_file_hash(file_path)
print("SHA-256 Hash of the file:", file_hash)
#clcoding.com
SHA-256 Hash of the file: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
3. Using Different Hash Algorithms:
import hashlib
# Hash a string using different algorithms
string_to_hash = "Hello, World!"
# MD5
md5_hash = hashlib.md5(string_to_hash.encode()).hexdigest()
# SHA1
sha1_hash = hashlib.sha1(string_to_hash.encode()).hexdigest()
# SHA512
sha512_hash = hashlib.sha512(string_to_hash.encode()).hexdigest()
print("MD5 Hash:", md5_hash)
print("SHA1 Hash:", sha1_hash)
print("SHA512 Hash:", sha512_hash)
#clcoding.com
MD5 Hash: 65a8e27d8879283831b664bd8b7f0ad4
SHA1 Hash: 0a0a9f2a6772942557ab5355d76af442f8f65e01
SHA512 Hash: 374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387
4. Hashing Passwords (Securely):
import hashlib
# Hash a password securely using a salt
password = "my_password"
salt = "random_salt"
hashed_password = hashlib.pbkdf2_hmac('sha256', password.encode(), salt.encode(), 100000)
hashed_password_hex = hashed_password.hex()
print("Salted and Hashed Password:", hashed_password_hex)
#clcoding.com
Salted and Hashed Password: b18597b62cda4415c995eaff30f61460da8ff4d758d3880f80593ed5866dcf98
5. Verifying Passwords:
import hashlib
# Verify a password against a stored hash
stored_hash = "stored_hashed_password"
def verify_password(password, stored_hash):
input_hash = hashlib.sha256(password.encode()).hexdigest()
if input_hash == stored_hash:
return True
else:
return False
password_to_verify = "password_to_verify"
if verify_password(password_to_verify, stored_hash):
print("Password is correct!")
else:
print("Password is incorrect.")
#clcoding.com
Password is incorrect.
6. Hashing a String using SHA-256:
import hashlib
# Create a hash object
hash_object = hashlib.sha256()
# Update the hash object with the input data
input_data = b'Hello, World!'
hash_object.update(input_data)
# Get the hexadecimal representation of the hash value
hash_value = hash_object.hexdigest()
print("SHA-256 Hash:", hash_value)
#clcoding.com
SHA-256 Hash: dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f
7. Hashing a String using MD5:
import hashlib
# Create a hash object
hash_object = hashlib.md5()
# Update the hash object with the input data
input_data = b'Hello, World!'
hash_object.update(input_data)
# Get the hexadecimal representation of the hash value
hash_value = hash_object.hexdigest()
print("MD5 Hash:", hash_value)
#clcoding.com
MD5 Hash: 65a8e27d8879283831b664bd8b7f0ad4
Wednesday 13 March 2024
Learn psutil library in Python 🧵:
Python Coding March 13, 2024 Python No comments
Learn psutil library in Python
pip install psutil
1. Getting CPU Information:
import psutil
# Get CPU information
cpu_count = psutil.cpu_count()
cpu_percent = psutil.cpu_percent(interval=1)
print("CPU Count:", cpu_count)
print("CPU Percent:", cpu_percent)
#clcoding.com
CPU Count: 8
CPU Percent: 6.9
2. Getting Memory Information:
import psutil
# Get memory information
memory = psutil.virtual_memory()
total_memory = memory.total
available_memory = memory.available
used_memory = memory.used
percent_memory = memory.percent
print("Total Memory:", total_memory)
print("Available Memory:", available_memory)
print("Used Memory:", used_memory)
print("Memory Percent:", percent_memory)
#clcoding.com
Total Memory: 8446738432
Available Memory: 721600512
Used Memory: 7725137920
Memory Percent: 91.5
3. Listing Running Processes:
import psutil
# List running processes
for process in psutil.process_iter():
print(process.pid, process.name())
#clcoding.com
0 System Idle Process
4 System
124 Registry
252 chrome.exe
408 PowerToys.Peek.UI.exe
436 msedge.exe
452 svchost.exe
504 smss.exe
520 svchost.exe
532 RuntimeBroker.exe
544 TextInputHost.exe
548 svchost.exe
680 csrss.exe
704 fontdrvhost.exe
768 wininit.exe
776 chrome.exe
804 chrome.exe
848 services.exe
924 lsass.exe
1036 WUDFHost.exe
1100 svchost.exe
1148 svchost.exe
1160 SgrmBroker.exe
1260 dllhost.exe
1284 PowerToys.exe
1328 svchost.exe
1392 svchost.exe
1400 svchost.exe
1408 svchost.exe
1488 svchost.exe
1504 svchost.exe
1512 svchost.exe
1600 SmartAudio3.exe
1608 svchost.exe
1668 svchost.exe
1716 svchost.exe
1724 IntelCpHDCPSvc.exe
1732 svchost.exe
1752 svchost.exe
1796 TiWorker.exe
1828 svchost.exe
1920 chrome.exe
1972 svchost.exe
1992 svchost.exe
2016 svchost.exe
2052 svchost.exe
2060 svchost.exe
2068 IntelCpHeciSvc.exe
2148 igfxCUIService.exe
2168 svchost.exe
2224 svchost.exe
2260 svchost.exe
2316 svchost.exe
2360 chrome.exe
2364 svchost.exe
2400 MsMpEng.exe
2420 svchost.exe
2428 svchost.exe
2448 PowerToys.FancyZones.exe
2480 screenrec.exe
2488 svchost.exe
2496 svchost.exe
2504 svchost.exe
2552 svchost.exe
2604 svchost.exe
2616 MemCompression
2716 svchost.exe
2792 chrome.exe
2796 dasHost.exe
2804 chrome.exe
2852 svchost.exe
2876 svchost.exe
2932 CxAudioSvc.exe
3016 svchost.exe
3240 svchost.exe
3416 svchost.exe
3480 svchost.exe
3536 spoolsv.exe
3620 svchost.exe
3660 svchost.exe
3700 svchost.exe
3752 RuntimeBroker.exe
3848 taskhostw.exe
3976 svchost.exe
3984 svchost.exe
3992 svchost.exe
4000 svchost.exe
4008 svchost.exe
4016 svchost.exe
4024 svchost.exe
4032 svchost.exe
4100 svchost.exe
4132 OneApp.IGCC.WinService.exe
4140 AnyDesk.exe
4148 armsvc.exe
4156 CxUtilSvc.exe
4208 WMIRegistrationService.exe
4284 msedge.exe
4312 svchost.exe
4320 AGMService.exe
4340 svchost.exe
4488 chrome.exe
4516 svchost.exe
4584 svchost.exe
4720 jhi_service.exe
4928 chrome.exe
5004 chrome.exe
5176 dwm.exe
5348 svchost.exe
5368 Flow.exe
5380 svchost.exe
5536 chrome.exe
5540 chrome.exe
5584 audiodg.exe
5620 svchost.exe
5724 svchost.exe
5776 svchost.exe
5992 ctfmon.exe
6032 CompPkgSrv.exe
6056 SearchProtocolHost.exe
6076 msedge.exe
6120 SearchIndexer.exe
6128 RuntimeBroker.exe
6156 svchost.exe
6192 MoUsoCoreWorker.exe
6380 PowerToys.PowerLauncher.exe
6424 PowerToys.Awake.exe
6480 msedge.exe
6596 svchost.exe
6740 svchost.exe
6792 winlogon.exe
6856 TrustedInstaller.exe
6872 svchost.exe
6888 igfxEM.exe
6908 svchost.exe
6948 chrome.exe
7140 csrss.exe
7296 PowerToys.KeyboardManagerEngine.exe
7336 WhatsApp.exe
7348 chrome.exe
7416 chrome.exe
7440 MusNotifyIcon.exe
7444 StartMenuExperienceHost.exe
7480 svchost.exe
7520 chrome.exe
7556 SearchApp.exe
7560 SecurityHealthService.exe
7720 msedge.exe
8220 MmReminderService.exe
8316 RuntimeBroker.exe
8636 svchost.exe
8836 python.exe
9088 ShellExperienceHost.exe
9284 svchost.exe
9344 NisSrv.exe
9560 msedge.exe
9664 chrome.exe
9736 chrome.exe
9784 SearchApp.exe
9808 svchost.exe
9868 python.exe
9884 svchost.exe
9908 chrome.exe
9936 chrome.exe
9996 QtWebEngineProcess.exe
10012 taskhostw.exe
10024 chrome.exe
10148 svchost.exe
10228 svchost.exe
10236 PowerToys.CropAndLock.exe
10304 Taskmgr.exe
10324 Video.UI.exe
10584 svchost.exe
10680 chrome.exe
10920 LockApp.exe
11064 chrome.exe
11176 chrome.exe
11188 msedge.exe
11396 msedge.exe
11500 QtWebEngineProcess.exe
11592 svchost.exe
12132 msedge.exe
12212 RuntimeBroker.exe
12360 RuntimeBroker.exe
12500 chrome.exe
12596 python.exe
12704 chrome.exe
12744 svchost.exe
12832 svchost.exe
12848 MicTray64.exe
12852 fontdrvhost.exe
12992 chrome.exe
13092 chrome.exe
13268 chrome.exe
13332 chrome.exe
13388 sihost.exe
13572 chrome.exe
13760 SecurityHealthSystray.exe
13792 msedge.exe
13880 fodhelper.exe
13900 chrome.exe
14160 UserOOBEBroker.exe
14220 RuntimeBroker.exe
14260 chrome.exe
14356 msedge.exe
14572 chrome.exe
14648 chrome.exe
14696 PowerToys.AlwaysOnTop.exe
14852 chrome.exe
14868 PowerToys.ColorPickerUI.exe
14876 conhost.exe
14888 PowerToys.PowerOCR.exe
14948 chrome.exe
15324 explorer.exe
4. Getting Process Information:
252
import psutil
# Get information for a specific process
pid = 252 # Replace with the process ID of interest
process = psutil.Process(pid)
print("Process Name:", process.name())
print("Process Status:", process.status())
print("Process CPU Percent:", process.cpu_percent(interval=1))
print("Process Memory Info:", process.memory_info())
#clcoding.com
Process Name: chrome.exe
Process Status: running
Process CPU Percent: 0.0
Process Memory Info: pmem(rss=29597696, vms=24637440, num_page_faults=14245, peak_wset=37335040, wset=29597696, peak_paged_pool=635560, paged_pool=635560, peak_nonpaged_pool=21344, nonpaged_pool=17536, pagefile=24637440, peak_pagefile=33103872, private=24637440)
5. Killing a Process:
import psutil
# Kill a process
pid_to_kill = 10088
# Replace with the process ID to kill
process_to_kill = psutil.Process(pid_to_kill)
process_to_kill.terminate()
#clcoding.com
6. Getting Disk Usage:
import psutil
# Get disk usage information
disk_usage = psutil.disk_usage('/')
total_disk_space = disk_usage.total
used_disk_space = disk_usage.used
free_disk_space = disk_usage.free
disk_usage_percent = disk_usage.percent
print("Total Disk Space:", total_disk_space)
print("Used Disk Space:", used_disk_space)
print("Free Disk Space:", free_disk_space)
print("Disk Usage Percent:", disk_usage_percent)
#clcoding.com
Total Disk Space: 479491600384
Used Disk Space: 414899838976
Free Disk Space: 64591761408
Disk Usage Percent: 86.5
Tuesday 12 March 2024
Plots using Python
Python Coding March 12, 2024 Python No comments
1. Line Plot:
#clcoding.com
import matplotlib.pyplot as plt
# Sample data
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a line plot
plt.plot(x, y)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Line Plot Example')
plt.show()
#clcoding.com
2. Bar Plot:
import matplotlib.pyplot as plt
# Sample data
categories = ['A', 'B', 'C', 'D']
values = [10, 20, 15, 25]
# Create a bar plot
plt.bar(categories, values)
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Bar Plot Example')
plt.show()
3. Histogram:
import matplotlib.pyplot as plt
import numpy as np
# Generate random data
data = np.random.randn(1000)
# Create a histogram
plt.hist(data, bins=30)
plt.xlabel('Values')
plt.ylabel('Frequency')
plt.title('Histogram Example')
plt.show()
4. Scatter Plot:
import matplotlib.pyplot as plt
import numpy as np
# Generate random data
x = np.random.randn(100)
y = 2 * x + np.random.randn(100)
# Create a scatter plot
plt.scatter(x, y)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Scatter Plot Example')
plt.show()
5. Box Plot:
import seaborn as sns
import numpy as np
# Generate random data
data = np.random.randn(100)
# Create a box plot
sns.boxplot(data=data)
plt.title('Box Plot Example')
plt.show()
6. Violin Plot:
import seaborn as sns
import numpy as np
# Generate random data
data = np.random.randn(100)
# Create a violin plot
sns.violinplot(data=data)
plt.title('Violin Plot Example')
plt.show()
7. Heatmap:
#clcoding.com
import seaborn as sns
import numpy as np
# Generate random data
data = np.random.rand(10, 10)
#clcoding.com
# Create a heatmap
sns.heatmap(data)
plt.title('Heatmap Example')
plt.show()
8. Area Plot:
import matplotlib.pyplot as plt
# Sample data #clcoding.com
x = [1, 2, 3, 4, 5]
y1 = [2, 4, 6, 8, 10]
y2 = [1, 3, 5, 7, 9]
# Create an area plot
plt.fill_between(x, y1, color="skyblue", alpha=0.4)
plt.fill_between(x, y2, color="salmon", alpha=0.4)
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.title('Area Plot Example')
plt.show()
9. Pie Chart:
import matplotlib.pyplot as plt
# Sample data
sizes = [30, 20, 25, 15, 10]
labels = ['A', 'B', 'C', 'D', 'E']
# Create a pie chart
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
plt.title('Pie Chart Example')
plt.show()
10. Polar Plot:
g
import matplotlib.pyplot as plt
import numpy as np
# Sample data
theta = np.linspace(0, 2*np.pi, 100)
r = np.sin(3*theta)
# Create a polar plot #clcoding.com
plt.polar(theta, r)
plt.title('Polar Plot Example')
plt.show()
11. 3D Plot:
import matplotlib.pyplot as plt
import numpy as np
# Sample data
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(np.sqrt(X**2 + Y**2))
# Create a 3D surface plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z)
ax.set_title('3D Plot Example')
plt.show()
12. Violin Swarm Plot:
#clcoding.com
import seaborn as sns
import numpy as np
# Generate random data
data = np.random.randn(100)
#clcoding.com
# Create a violin swarm plot
sns.violinplot(data=data, inner=None, color='lightgray')
sns.swarmplot(data=data, color='blue', alpha=0.5)
plt.title('Violin Swarm Plot Example')
plt.show()
13. Pair Plot:
import seaborn as sns
import pandas as pd
# Load sample dataset
iris = sns.load_dataset('iris')
# Create a pair plot
sns.pairplot(iris)
plt.title('Pair Plot Example')
plt.show()
Monday 11 March 2024
Cybersecurity using Python
Python Coding March 11, 2024 Python No comments
1. Hashing Passwords:
import hashlib
def hash_password(password):
hashed_password = hashlib.sha256(password.encode()).hexdigest()
return hashed_password
# Example
password = "my_secure_password"
hashed_password = hash_password(password)
print("Hashed Password:", hashed_password)
#clcoding.com
Hashed Password: 2c9a8d02fc17ae77e926d38fe83c3529d6638d1d636379503f0c6400e063445f
2. Generating Random Passwords:
import random
import string
def generate_random_password(length=12):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
# Example
random_password = generate_random_password()
print("Random Password:", random_password)
#clcoding.com
Random Password: zH7~ANoO:7#S
3. Network Scanning with Scapy:
from scapy.all import IP, ICMP, sr1
def ping(host):
packet = IP(dst=host)/ICMP()
response = sr1(packet, timeout=2, verbose=0)
if response:
return f"{host} is online"
else:
return f"{host} is offline"
# Example
host_to_scan = "example.com"
result = ping(host_to_scan)
print(result)
#clcoding.com
4. Web Scraping for Security Research:
import requests
from bs4 import BeautifulSoup
def scrape_security_news():
url = "https://example-security-news.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
headlines = soup.find_all('h2', class_='security-headline')
return [headline.text for headline in headlines]
# Example
security_headlines = scrape_security_news()
print("Security Headlines:", security_headlines)
#clcoding.com
5. Password Cracking Simulation:
import hashlib
def simulate_password_cracking(hashed_password, password_list):
for password in password_list:
if hashlib.sha256(password.encode()).hexdigest() == hashed_password:
return f"Password cracked: {password}"
return "Password not found"
# Example
hashed_password_to_crack = "d033e22ae348aeb5660fc2140aec35850c4da997"
common_passwords = ["password", "123456", "qwerty", "admin"]
result = simulate_password_cracking(hashed_password_to_crack, common_passwords)
print(result)
#clcoding.com
6. Secure File Handling:
import os
def secure_file_deletion(file_path):
with open(file_path, 'w') as file:
file.write(os.urandom(1024))
# Overwrite the file with random data
os.remove(file_path)
print(f"{file_path} securely deleted")
# Example
file_path_to_delete = "example.txt"
secure_file_deletion(file_path_to_delete)
#clcoding.com
Thursday 7 March 2024
Interpretable Machine Learning with Python - Second Edition: Build explainable, fair, and robust high-performance models with hands-on, real-world examples
Python Coding March 07, 2024 Books, Machine Learning, Python No comments
A deep dive into the key aspects and challenges of machine learning interpretability using a comprehensive toolkit, including SHAP, feature importance, and causal inference, to build fairer, safer, and more reliable models.
Purchase of the print or Kindle book includes a free eBook in PDF format.
Key Features
Interpret real-world data, including cardiovascular disease data and the COMPAS recidivism scores
Build your interpretability toolkit with global, local, model-agnostic, and model-specific methods
Analyze and extract insights from complex models from CNNs to BERT to time series models
Book Description
Interpretable Machine Learning with Python, Second Edition, brings to light the key concepts of interpreting machine learning models by analyzing real-world data, providing you with a wide range of skills and tools to decipher the results of even the most complex models.
Build your interpretability toolkit with several use cases, from flight delay prediction to waste classification to COMPAS risk assessment scores. This book is full of useful techniques, introducing them to the right use case. Learn traditional methods, such as feature importance and partial dependence plots to integrated gradients for NLP interpretations and gradient-based attribution methods, such as saliency maps.
In addition to the step-by-step code, you'll get hands-on with tuning models and training data for interpretability by reducing complexity, mitigating bias, placing guardrails, and enhancing reliability.
By the end of the book, you'll be confident in tackling interpretability challenges with black-box models using tabular, language, image, and time series data.
What you will learn
Progress from basic to advanced techniques, such as causal inference and quantifying uncertainty
Build your skillset from analyzing linear and logistic models to complex ones, such as CatBoost, CNNs, and NLP transformers
Use monotonic and interaction constraints to make fairer and safer models
Understand how to mitigate the influence of bias in datasets
Leverage sensitivity analysis factor prioritization and factor fixing for any model
Discover how to make models more reliable with adversarial robustness
Who this book is for
This book is for data scientists, machine learning developers, machine learning engineers, MLOps engineers, and data stewards who have an increasingly critical responsibility to explain how the artificial intelligence systems they develop work, their impact on decision making, and how they identify and manage bias. It's also a useful resource for self-taught ML enthusiasts and beginners who want to go deeper into the subject matter, though a good grasp of the Python programming language is needed to implement the examples.
Table of Contents
Interpretation, Interpretability and Explainability; and why does it all matter?
Key Concepts of Interpretability
Interpretation Challenges
Global Model-agnostic Interpretation Methods
Local Model-agnostic Interpretation Methods
Anchors and Counterfactual Explanations
Visualizing Convolutional Neural Networks
Interpreting NLP Transformers
Interpretation Methods for Multivariate Forecasting and Sensitivity Analysis
Feature Selection and Engineering for Interpretability
Bias Mitigation and Causal Inference Methods
Monotonic Constraints and Model Tuning for Interpretability
Adversarial Robustness
What's Next for Machine Learning Interpretability?
Hard Copy: Interpretable Machine Learning with Python - Second Edition: Build explainable, fair, and robust high-performance models with hands-on, real-world examples
Generative AI with LangChain: Build large language model (LLM) apps with Python, ChatGPT and other LLMs
Python Coding March 07, 2024 AI, Books, Python No comments
Get to grips with the LangChain framework from theory to deployment and develop production-ready applications.
Code examples regularly updated on GitHub to keep you abreast of the latest LangChain developments.
Purchase of the print or Kindle book includes a free PDF eBook.
Key Features
Learn how to leverage LLMs' capabilities and work around their inherent weaknesses
Delve into the realm of LLMs with LangChain and go on an in-depth exploration of their fundamentals, ethical dimensions, and application challenges
Get better at using ChatGPT and GPT models, from heuristics and training to scalable deployment, empowering you to transform ideas into reality
Book Description
ChatGPT and the GPT models by OpenAI have brought about a revolution not only in how we write and research but also in how we can process information. This book discusses the functioning, capabilities, and limitations of LLMs underlying chat systems, including ChatGPT and Bard. It also demonstrates, in a series of practical examples, how to use the LangChain framework to build production-ready and responsive LLM applications for tasks ranging from customer support to software development assistance and data analysis - illustrating the expansive utility of LLMs in real-world applications.
Unlock the full potential of LLMs within your projects as you navigate through guidance on fine-tuning, prompt engineering, and best practices for deployment and monitoring in production environments. Whether you're building creative writing tools, developing sophisticated chatbots, or crafting cutting-edge software development aids, this book will be your roadmap to mastering the transformative power of generative AI with confidence and creativity.
What you will learn
Understand LLMs, their strengths and limitations
Grasp generative AI fundamentals and industry trends
Create LLM apps with LangChain like question-answering systems and chatbots
Understand transformer models and attention mechanisms
Automate data analysis and visualization using pandas and Python
Grasp prompt engineering to improve performance
Fine-tune LLMs and get to know the tools to unleash their power
Deploy LLMs as a service with LangChain and apply evaluation strategies
Privately interact with documents using open-source LLMs to prevent data leaks
Who this book is for
The book is for developers, researchers, and anyone interested in learning more about LLMs. Whether you are a beginner or an experienced developer, this book will serve as a valuable resource if you want to get the most out of LLMs and are looking to stay ahead of the curve in the LLMs and LangChain arena.
Basic knowledge of Python is a prerequisite, while some prior exposure to machine learning will help you follow along more easily.
Table of Contents
What Is Generative AI?
LangChain for LLM Apps
Getting Started with LangChain
Building Capable Assistants
Building a Chatbot like ChatGPT
Developing Software with Generative AI
LLMs for Data Science
Customizing LLMs and Their Output
Generative AI in Production
The Future of Generative Models
Hard Copy: Generative AI with LangChain: Build large language model (LLM) apps with Python, ChatGPT and other LLMs
Wednesday 6 March 2024
Data Science Fundamentals with Python and SQL Specialization
Python Coding March 06, 2024 Data Science, IBM, Python, SQL No comments
What you'll learn
Working knowledge of Data Science Tools such as Jupyter Notebooks, R Studio, GitHub, Watson Studio
Python programming basics including data structures, logic, working with files, invoking APIs, and libraries such as Pandas and Numpy
Statistical Analysis techniques including Descriptive Statistics, Data Visualization, Probability Distribution, Hypothesis Testing and Regression
Relational Database fundamentals including SQL query language, Select statements, sorting & filtering, database functions, accessing multiple tables
Join Free: Data Science Fundamentals with Python and SQL Specialization
Specialization - 5 course series
Where math doesn’t work in Python
Python Coding March 06, 2024 Python No comments
1. Precision Issues:
x = 1.0
y = 1e-16
result = x + y
print(result)
#clcoding.com
1.0
2. Comparing Floating-Point Numbers:
a = 0.1 + 0.2
b = 0.3
print(a == b)
#clcoding.com
False
3. NaN (Not a Number) and Inf (Infinity):
result = float('inf') / float('inf')
print(result)
#clcoding.com
nan
4. Large Integers:
result = 2 ** 1000
print(result)
#clcoding.com
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
5. Round-off Errors:
result = 0.1 + 0.2 - 0.3
print(result)
#clcoding.com
5.551115123125783e-17
Tuesday 5 March 2024
Python & SQL Mastery: 5 Books in 1: Your Comprehensive Guide from Novice to Expert (2024 Edition) (Data Dynamics: Python & SQL Mastery)
Python Coding March 05, 2024 Books, Python, SQL No comments
Are you poised to elevate your technical expertise and stay ahead in the rapidly evolving world of data and programming?
Look no further!
Our 5 Books Series is meticulously crafted to guide you from the basics to the most advanced concepts in Python and SQL, making it a must-have for database enthusiasts, aspiring data scientists, and seasoned coders alike.
Comprehensive Learning Journey:
Mastering SQL: Dive deep into every facet of SQL, from fundamental data retrieval to complex transactions, views, and indexing.
Synergizing Code and Data: Explore the synergy between Python and SQL Server Development, mastering techniques from executing SQL queries through Python to advanced data manipulation.
Python and SQL for Data Solutions: Uncover the powerful combination of Python and SQL for data analysis, reporting, and integration, including ETL processes and machine learning applications.
Advanced Data Solutions: Delve into integrating Python and SQL for data retrieval, manipulation, and performance optimization.
Integrating Python and SQL: Master database manipulation, focusing on crafting SQL queries in Python and implementing security best practices.
Empower Your Career: Gain the skills that are highly sought after in today's job market. From database management to advanced analytics, this series prepares you for a multitude of roles in tech, data analysis, and beyond.
Practical, Real-World Application: Each book is packed with practical examples, real-world case studies, and hands-on projects. This approach not only reinforces learning but also prepares you to apply your knowledge effectively in professional settings.
Expert Insight and Future Trends: Learn from experts with years of experience in the field. The series not only teaches you current best practices but also explores emerging trends, ensuring you stay at the forefront of technology.
For Beginners and Experts Alike: Whether you're just starting out or looking to deepen your existing knowledge, our series provides a clear, structured path to mastering both Python and SQL.
Embark on this comprehensive journey to mastering Python and SQL. With our series, you'll transform your career, opening doors to new opportunities and achieving data excellence.
Hard Copy: Python & SQL Mastery: 5 Books in 1: Your Comprehensive Guide from Novice to Expert (2024 Edition) (Data Dynamics: Python & SQL Mastery)
Finance with Rust: The 2024 Quantitative Finance Guide to - Financial Engineering, Machine Learning, Algorithmic Trading, Data Visualization & More
Python Coding March 05, 2024 Books, data management, Machine Learning, Python No comments
Reactive Publishing
"Finance with Rust" is a pioneering guide that introduces financial professionals and software developers to the transformative power of Rust in the financial industry. With its emphasis on speed, safety, and concurrency, Rust presents an unprecedented opportunity to enhance financial systems and applications.
Written by an accomplished software developer and entrepreneur, this book bridges the gap between complex financial processes and cutting-edge technology. It offers a comprehensive exploration of Rust's application in finance, from developing faster algorithms to ensuring data security and system reliability.
Within these pages, you'll discover:
An introduction to Rust for those new to the language, focusing on its relevance and benefits in financial applications.
Step-by-step guides on using Rust to build scalable and secure financial models, algorithms, and infrastructure.
Case studies demonstrating the successful integration of Rust in financial systems, highlighting its impact on performance and security.
Practical insights into leveraging Rust for financial innovation, including blockchain technology, cryptocurrency platforms, and more.
"Finance with Rust" empowers you to stay ahead in the fast-evolving world of financial technology. Whether you're aiming to optimize financial operations, develop high-performance trading systems, or innovate with blockchain and crypto technologies, this book is your essential roadmap to success.
Hard Copy: Finance with Rust: The 2024 Quantitative Finance Guide to - Financial Engineering, Machine Learning, Algorithmic Trading, Data Visualization & More
PYTHON PROGRAMMING FOR BEGINNERS: Mastering Python With No Prior Experience: The Ultimate Guide to Conquer Your Coding Fear From Crash and Land Your First Job in Tech
Python Coding March 05, 2024 Books, Python No comments
Learn Python Programming Fast - A Beginner's Guide to Mastering Python from Home
Grab the Bonus Chapter Inside with 50 Coding Journal
Python is the most in-demand programming language in 2024. As a beginner, learning Python can open up high-paying remote and freelance job opportunities in fields like data science, web development, AI, and more.
This hands-on Python Programming is designed specifically for beginners with no prior coding experience. It provides a foundations-first introduction to Python programming concepts using simplified explanations, practical examples, and step-by-step tutorials.
Programming is best learned by doing, and thus, this book incorporates numerous practical exercises and real-world projects.
This is not Hype; you will learn something new in this Python Programming for Beginners.
What You Will Learn in this Python Programming for Beginners Book:
Python Installation - How to download Python and set up your coding environment
Python Syntax - Key programming constructs like variables, data types, functions, conditionals and loops
Core Programming Techniques - Best practices for writing clean, efficient Python code
Built-in Data Structures - Hands-on projects using Python lists, tuples, dictionaries and more
Object-Oriented Programming - How to work with classes, objects and inheritance in Python
Python for Web Development - Build a web app and API with Python frameworks like Django and Flask
Python for Data Analysis - Use Python for data science and work with Jupyter Notebooks
Python for Machine Learning - Implement machine learning algorithms for prediction and classification
Bonus: Python Coding Interview Questions - Practice questions and answers to prepare for the interview
This beginner-friendly guide will give you a solid foundation in Python to build real-world apps and land your first Python developer job.
Hard Copy: PYTHON PROGRAMMING FOR BEGINNERS: Mastering Python With No Prior Experience: The Ultimate Guide to Conquer Your Coding Fear From Crash and Land Your First Job in Tech
Econometric Python: Harnessing Data Science for Economic Analysis: The Science of Pythonomics in 2024
Python Coding March 05, 2024 Books, Data Science, Python No comments
Reactive Publishing
In the rapidly evolving landscape of economics, "Econometric Python" emerges as a groundbreaking guide, perfectly blending the intricate world of econometrics with the dynamic capabilities of Python. This book is crafted for economists, data scientists, researchers, and students who aspire to revolutionize their approach to economic data analysis.
At its center, "Econometric Python" serves as a beacon for those navigating the complexities of econometric models, offering a unique perspective on applying Python's powerful data science tools in economic research. The book starts with a fundamental introduction to Python, focusing on aspects most relevant to econometric analysis. This makes it an invaluable resource for both Python novices and seasoned programmers.
As the narrative unfolds, readers are led through a series of progressively complex econometric techniques, all demonstrated with Python's state-of-the-art libraries such as pandas, NumPy, and statsmodels. Each chapter is meticulously designed to balance theory and practice, providing in-depth explanations of econometric concepts, followed by practical coding examples.
Key features of "Econometric Python" include:
Comprehensive Coverage: From basic economic concepts to advanced econometric models, the book covers a wide array of topics, ensuring a thorough understanding of both theoretical and practical aspects.
Hands-On Approach: With real-world datasets and step-by-step coding tutorials, readers gain hands-on experience in applying econometric theories using Python.
Latest Trends and Techniques: Stay abreast of the latest developments in both econometrics and Python programming, including machine learning applications in economic data analysis.
Expert Insights: The authors, renowned in the fields of economics and data science, provide valuable insights and tips, enhancing the learning experience.
"Econometric Python" is more than just a textbook; it's a journey into the future of economic analysis. By the end of this book, readers will not only be proficient in using Python for econometric analysis but will also be equipped with the skills to contribute innovatively to the field of economics. Whether it's for academic purposes, professional development, or personal interest, this book is an indispensable asset for anyone looking to merge the power of data science with economic analysis.
Hard Copy: Econometric Python: Harnessing Data Science for Economic Analysis: The Science of Pythonomics in 2024
Python Data Science 2024: Explore Data, Build Skills, and Make Data-Driven Decisions in 30 Days (Machine Learning and Data Analysis for Beginners)
Python Coding March 05, 2024 Books, Data Science, Machine Learning, Python No comments
Data Science Crash Course for Beginners with Python...
Uncover the energy of records in 30 days with Python Data Science 2024!
Are you searching for a hands-on strategy to study Python coding and Python for Data Analysis fast?
This beginner-friendly route offers you the abilities and self-belief to discover data, construct sensible abilities, and begin making data-driven selections inside a month.
On the program:
Deep mastering
Neural Networks and Deep Learning
Deep Learning Parameters and Hyper-parameters
Deep Neural Networks Layers
Deep Learning Activation Functions
Convolutional Neural Network
Python Data Structures
Best practices in Python and Zen of Python
Installing Python
Python
These are some of the subjects included in this book:
Fundamentals of deep learning
Fundamentals of probability
Fundamentals of statistics
Fundamentals of linear algebra
Introduction to desktop gaining knowledge of and deep learning
Fundamentals of computer learning
Deep gaining knowledge of parameters and hyper-parameters
Deep neural networks layers
Deep getting to know activation functions
Convolutional neural network
Deep mastering in exercise (in jupyter notebooks)
Python information structures
Best practices in python and zen of Python
Installing Python
At the cease of this course, you may be in a position to:
Confidently deal with real-world datasets.
Wrangle, analyze, and visualize facts the usage of Python.
Turn records into actionable insights and knowledgeable decisions.
Speak the language of data-driven professionals.
Lay the basis for in addition studying in statistics science and computing device learning.
Hard Copy: Python Data Science 2024: Explore Data, Build Skills, and Make Data-Driven Decisions in 30 Days (Machine Learning and Data Analysis for Beginners)
Saturday 2 March 2024
Data Analysis with Python
Python Coding March 02, 2024 Coursera, IBM, Python No comments
What you'll learn
Develop Python code for cleaning and preparing data for analysis - including handling missing values, formatting, normalizing, and binning data
Perform exploratory data analysis and apply analytical techniques to real-word datasets using libraries such as Pandas, Numpy and Scipy
Manipulate data using dataframes, summarize data, understand data distribution, perform correlation and create data pipelines
Build and evaluate regression models using machine learning scikit-learn library and use them for prediction and decision making
Join Free: Data Analysis with Python
Get Started with Python by Google
Python Coding March 02, 2024 Coursera, Python No comments
What you'll learn
Explain how Python is used by data professionals
Explore basic Python building blocks, including syntax and semantics
Understand loops, control statements, and string manipulation
Use data structures to store and organize data
Join Free : Get Started with Python
There are 5 modules in this course
This is the second of seven courses in the Google Advanced Data Analytics Certificate. The Python programming language is a powerful tool for data analysis. In this course, you’ll learn the basic concepts of Python programming and how data professionals use Python on the job. You'll explore concepts such as object-oriented programming, variables, data types, functions, conditional statements, loops, and data structures.
Google employees who currently work in the field will guide you through this course by providing hands-on activities that simulate relevant tasks, sharing examples from their day-to-day work, and helping you enhance your data analytics skills to prepare for your career.
Learners who complete the seven courses in this program will have the skills needed to apply for data science and advanced data analytics jobs. This certificate assumes prior knowledge of foundational analytical principles, skills, and tools covered in the Google Data Analytics Certificate.
By the end of this course, you will:
-Define what a programming language is and why Python is used by data scientists
-Create Python scripts to display data and perform operations
-Control the flow of programs using conditions and functions
-Utilize different types of loops when performing repeated operations
-Identify data types such as integers, floats, strings, and booleans
-Manipulate data structures such as , lists, tuples, dictionaries, and sets
-Import and use Python libraries such as NumPy and pandas
Thursday 29 February 2024
Probabilistic Graphical Models 3: Learning
Python Coding February 29, 2024 Books, Machine Learning, Python No comments
Build your subject-matter expertise
This course is part of the Probabilistic Graphical Models Specialization
When you enroll in this course, you'll also be enrolled in this Specialization.
Learn new concepts from industry experts
Gain a foundational understanding of a subject or tool
Develop job-relevant skills with hands-on projects
Earn a shareable career certificate
Join Free: Probabilistic Graphical Models 3: Learning
There are 8 modules in this course
Probabilistic Graphical Models 2: Inference
Python Coding February 29, 2024 Books, Python No comments
Build your subject-matter expertise
This course is part of the Probabilistic Graphical Models Specialization
When you enroll in this course, you'll also be enrolled in this Specialization.
Learn new concepts from industry experts
Gain a foundational understanding of a subject or tool
Develop job-relevant skills with hands-on projects
Earn a shareable career certificate
Join Free: Probabilistic Graphical Models 2: Inference
There are 7 modules in this course
Probabilistic Graphical Models 1: Representation
Python Coding February 29, 2024 Books, Coursera, Python No comments
Build your subject-matter expertise
This course is part of the Probabilistic Graphical Models Specialization
When you enroll in this course, you'll also be enrolled in this Specialization.
Learn new concepts from industry experts
Gain a foundational understanding of a subject or tool
Develop job-relevant skills with hands-on projects
Earn a shareable career certificate
Join Free: Probabilistic Graphical Models 1: Representation
There are 7 modules in this course
Popular Posts
-
There are 6 modules in this course Cybersecurity affects everyone, including in the delivery of basic products and services. If you or you...
-
Let's break down the provided code: d = {'Milk': 1, 'Soap': 2, 'Towel': 3} if 'Soap' in d: print(d[&...
-
1. Line Plot: #clcoding.com import matplotlib.pyplot as plt # Sample data x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Create a line plo...
-
Let's break down the given code: for i in range(1, 3): print(i, end=' - ') This code snippet is a for loop in Python. Let&...
-
Let's break down each line: my_tuple = (1, 2, 3): This line creates a tuple named my_tuple containing three elements: 1, 2, and 3. x, ...
-
Learn psutil library in Python pip install psutil 1. Getting CPU Information: import psutil # Get CPU information cpu_count = psutil.cpu_c...
-
The json library in Python 1. Encoding Python Data to JSON: import json # Python dictionary to be encoded to JSON data = { "name&...
-
Financial Machine Learning surveys the nascent literature on machine learning in the study of financial markets. The authors highlight th...
-
Let's break down the code: s = 'clcoding' index = s.find('n', -1) print(index) s = 'clcoding': This line ini...
-
What you'll learn Understand why version control is a fundamental tool for coding and collaboration Install and run Git on your local ...