Machine Learning with Python
Learn Machine Learning with hands-on Python tutorials, real-world code examples, and clear explanations for researchers and developers. Admin: @HusseinSheikho || @Hussein_Sheikho
Show more📈 Analytical overview of Telegram channel Machine Learning with Python
Channel Machine Learning with Python (@codeprogrammer) in the English language segment is an active participant. Currently, the community unites 67 809 subscribers, ranking 2 416 in the Education category and 5 038 in the India region.
📊 Audience metrics and dynamics
Since its creation on невідомо, the project has demonstrated rapid growth, gathering an audience of 67 809 subscribers.
According to the latest data from 09 June, 2026, the channel demonstrates stable activity. Although there has been a change in the number of participants by 70 over the last 30 days and by 10 over the last 24 hours, overall reach remains high.
- Verification status: Not verified
- Engagement rate (ER): The average audience engagement rate is 2.94%. Within the first 24 hours after publication, content typically collects 2.44% reactions from the total number of subscribers.
- Post reach: On average, each post receives 1 997 views. Within the first day, a publication typically gains 1 652 views.
- Reactions and interaction: The audience actively supports content: the average number of reactions per post is 7.
- Thematic interests: Content is focused on key topics such as insidead, learning, degree, evaluation, algorithm.
📝 Description and content policy
The author describes the resource as a platform for expressing subjective opinions:
“Learn Machine Learning with hands-on Python tutorials, real-world code examples, and clear explanations for researchers and developers.
Admin: @HusseinSheikho || @Hussein_Sheikho”
Thanks to the high frequency of updates (latest data received on 10 June, 2026), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Education category.
import easyocr
reader = easyocr.Reader(['en', 'ru']) # Choose supported languages
result = reader.readtext('image.png')
### 📌 Ideal For:
✅ Text extraction from photos, scans, and documents
✅ Embedding OCR capabilities in apps (e.g. automated data entry)
🔗 GitHub: https://github.com/JaidedAI/EasyOCR
👉 Follow us for more: @DataScienceN
#Python #OCR #MachineLearning #ComputerVision #EasyOCR✉️ Our Telegram channels: https://t.me/addlist/0f6vfFbEMdAwODBk 📱 Our WhatsApp channel: https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
def clean_html(html_file):
with open(html_file, 'r+', encoding='utf-8') as f:
content = f.read()
soup = BeautifulSoup(content, 'html.parser')
# Remove problematic elements
for element in soup(['script', 'iframe', 'object']):
element.decompose()
# Fix image paths
for img in soup.find_all('img'):
if not os.path.isabs(img['src']):
img['src'] = os.path.abspath(os.path.join(os.path.dirname(html_file), img['src']))
# Write back cleaned HTML
f.seek(0)
f.write(str(soup))
f.truncate()
---
## 🔹 Full Usage Example
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Convert EPUB to PDF')
parser.add_argument('epub_file', help='Input EPUB file path')
parser.add_argument('pdf_file', help='Output PDF file path')
args = parser.parse_args()
success = epub_to_pdf(args.epub_file, args.pdf_file)
if not success:
exit(1)
Run from command line:
python epub_to_pdf.py input.epub output.pdf
---
## 🔹 Troubleshooting Common Issues
| Problem | Solution |
|---------|----------|
| Missing images | Ensure enable-local-file-access is set |
| Broken CSS paths | Use absolute paths in CSS references |
| Encoding issues | Specify UTF-8 in both HTML and pdfkit options |
| Large file sizes | Optimize images before conversion |
| Layout problems | Add CSS media queries for print |
---
## 🔹 Alternative Libraries
If pdfkit doesn't meet your needs:
1. WeasyPrint (pure Python)
pip install weasyprint
2. PyMuPDF (fitz)
pip install pymupdf
3. Calibre's `ebook-convert` CLI
ebook-convert input.epub output.pdf
---
## 🔹 Best Practices
1. Always clean temporary files after conversion
2. Validate input EPUBs before processing
3. Handle metadata (title, author, etc.)
4. Batch process multiple files with threading
5. Log conversion results for debugging
---
### 📚 Final Notes
This solution preserves:
✔️ All images in original quality
✔️ Chapter structure and formatting
✔️ Text encoding and special characters
For production use, consider adding:
- Progress tracking
- Parallel conversion of chapters
- EPUB metadata preservation
- Custom cover page support
#PythonAutomation #EbookTools #PDFConversion 🚀
Try enhancing this script by:
1. Adding a progress bar
2. Preserving table of contents
3. Supporting custom cover pages
4. Creating a GUI versionebooklib - For EPUB parsing
- pdfkit (wrapper for wkhtmltopdf) - For PDF generation
- Pillow - For image handling (optional)
pip install ebooklib pdfkit pillow
Also install system dependencies:
# On Ubuntu/Debian
sudo apt-get install wkhtmltopdf
# On MacOS
brew install wkhtmltopdf
# On Windows (download from wkhtmltopdf.org)
---
## 🔹 Step 1: Extract EPUB Contents
First, we'll unpack the EPUB file to access its HTML and images.
from ebooklib import epub
from bs4 import BeautifulSoup
import os
def extract_epub(epub_path, output_dir):
book = epub.read_epub(epub_path)
# Create output directory
os.makedirs(output_dir, exist_ok=True)
# Extract all items (chapters, images, styles)
for item in book.get_items():
if item.get_type() == epub.ITEM_IMAGE:
# Save images
with open(os.path.join(output_dir, item.get_name()), 'wb') as f:
f.write(item.get_content())
elif item.get_type() == epub.ITEM_DOCUMENT:
# Save HTML chapters
with open(os.path.join(output_dir, item.get_name()), 'wb') as f:
f.write(item.get_content())
return [item.get_name() for item in book.get_items() if item.get_type() == epub.ITEM_DOCUMENT]
---
## 🔹 Step 2: Convert HTML to PDF
Now we'll convert the extracted HTML files to PDF while preserving images.
import pdfkit
from PIL import Image # For image validation (optional)
def html_to_pdf(html_files, output_pdf, base_dir):
options = {
'encoding': "UTF-8",
'quiet': '',
'enable-local-file-access': '', # Critical for local images
'no-outline': None,
'margin-top': '15mm',
'margin-right': '15mm',
'margin-bottom': '15mm',
'margin-left': '15mm',
}
# Validate images (optional)
for html_file in html_files:
soup = BeautifulSoup(open(os.path.join(base_dir, html_file)), 'html.parser')
for img in soup.find_all('img'):
img_path = os.path.join(base_dir, img['src'])
try:
Image.open(img_path) # Validate image
except Exception as e:
print(f"Image error in {html_file}: {e}")
img.decompose() # Remove broken images
# Convert to PDF
pdfkit.from_file(
[os.path.join(base_dir, f) for f in html_files],
output_pdf,
options=options
)
---
## 🔹 Step 3: Complete Conversion Function
Combine everything into a single workflow.
def epub_to_pdf(epub_path, output_pdf, temp_dir="temp_epub"):
try:
print(f"Converting {epub_path} to PDF...")
# Step 1: Extract EPUB
print("Extracting EPUB contents...")
html_files = extract_epub(epub_path, temp_dir)
# Step 2: Convert to PDF
print("Generating PDF...")
html_to_pdf(html_files, output_pdf, temp_dir)
print(f"Success! PDF saved to {output_pdf}")
return True
except Exception as e:
print(f"Conversion failed: {str(e)}")
return False
finally:
# Clean up temporary files
if os.path.exists(temp_dir):
import shutil
shutil.rmtree(temp_dir)
---
## 🔹 Advanced Options
### 1. Custom Styling
Add CSS to improve PDF appearance:
def html_to_pdf(html_files, output_pdf, base_dir):
options = {
# ... previous options ...
'user-style-sheet': 'styles.css', # Custom CSS
}
# Create CSS file if needed
css = """
body { font-family: "Times New Roman", serif; font-size: 12pt; }
img { max-width: 100%; height: auto; }
"""
with open(os.path.join(base_dir, 'styles.css'), 'w') as f:
f.write(css)
pdfkit.from_file(/* ... */)https://chat.openai.com/share/abc123)
• Downloads the HTML content of the chat
• Converts it to a PDF file using pdfkit and wkhtmltopdf
This is useful for archiving, sharing, or printing ChatGPT conversations in a clean format.
---
### 1. Prerequisites
Before starting, you need the following libraries and tools:
#### • Install pdfkit and requests
pip install pdfkit requests
#### • Install wkhtmltopdf
Download from:
[https://wkhtmltopdf.org/downloads.html](https://wkhtmltopdf.org/downloads.html)
Make sure to add the path of the installed binary to your system PATH.
---
### 2. Python Script: Convert Shared ChatGPT URL to PDF
import pdfkit
import requests
import os
# Define output filename
output_file = "chatgpt_conversation.pdf"
# ChatGPT shared URL (user input)
chat_url = input("Enter the ChatGPT share URL: ").strip()
# Verify the URL format
if not chat_url.startswith("https://chat.openai.com/share/"):
print("Invalid URL. Must start with https://chat.openai.com/share/")
exit()
try:
# Download HTML content
response = requests.get(chat_url)
if response.status_code != 200:
raise Exception(f"Failed to load the chat: {response.status_code}")
html_content = response.text
# Save HTML to temporary file
with open("temp_chat.html", "w", encoding="utf-8") as f:
f.write(html_content)
# Convert HTML to PDF
pdfkit.from_file("temp_chat.html", output_file)
print(f"\n✅ PDF saved as: {output_file}")
# Optional: remove temp file
os.remove("temp_chat.html")
except Exception as e:
print(f"❌ Error: {e}")
---
### 3. Notes
• This approach works only if the shared page is publicly accessible (which ChatGPT share links are).
• The PDF output will contain the web page version, including theme and layout.
• You can customize the PDF output using pdfkit options (like page size, margins, etc.).
---
### 4. Optional Enhancements
• Add GUI with Tkinter
• Accept multiple URLs
• Add PDF metadata (title, author, etc.)
• Add support for offline rendering using BeautifulSoup to clean content
---
### Exercise
• Try converting multiple ChatGPT share links to PDF
• Customize the styling with your own CSS
• Add a timestamp or watermark to the PDF
---
#Python #ChatGPT #PDF #WebScraping #Automation #pdfkit #tkinterpandas for structured data:
import pandas as pd
df = pd.read_csv('data.csv')
• Use libraries like json for JSON files:
import json
with open('data.json') as f:
data = json.load(f)
---
5. Basic Dataset Exploration
• Check shape and size:
print(df.shape)
• Preview data:
print(df.head())
• Check for missing values:
print(df.isnull().sum())
---
6. Summary
• Understanding dataset types is crucial before processing.
• Loading and exploring datasets helps identify cleaning and preprocessing needs.
---
Exercise
• Load a CSV and JSON dataset in Python, print their shapes, and identify missing values.
---
#DataScience #Datasets #DataLoading #Python #DataExploration
https://t.me/DataScienceM
Available now! Telegram Research 2025 — the year's key insights 
