-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
132 lines (121 loc) · 6.28 KB
/
app.py
File metadata and controls
132 lines (121 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import os
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from docx import Document
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import A4
import fitz
green = RGBColor(34, 139, 34)
black = RGBColor(0, 0, 0)
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[0])
slide.shapes.title.text = "Machine Learning Applications in Environmental Sustainability"
slide.placeholders[1].text = "A research-based presentation on data-driven approaches for a greener future 🌱"
pdf_path = "pdf.pdf"
try:
doc_pdf = fitz.open(pdf_path)
count = 0
for page_index in range(len(doc_pdf)):
for img in doc_pdf.get_page_images(page_index):
xref = img[0]
pix = fitz.Pixmap(doc_pdf, xref)
if pix.n < 5:
pix.save(f"figure_{count+1}.png")
else:
pix1 = fitz.Pixmap(fitz.csRGB, pix)
pix1.save(f"figure_{count+1}.png")
pix1 = None
count += 1
doc_pdf.close()
print(f"✅ {count} images extracted from PDF.")
except Exception as e:
print("⚠️ Error extracting images from PDF:", e)
slides_content = {
"Introduction": [
"Environmental sustainability is one of the key global challenges of the 21st century.",
"Machine learning (ML) offers innovative tools to analyze, predict, and optimize environmental systems.",
"This presentation explores ML applications in climate modeling, pollution prediction, and renewable energy management."
],
"The Role of Data": [
"High-quality data is essential for accurate environmental modeling.",
"Data sources include satellites, IoT sensors, and open governmental databases.",
"Machine learning models can process vast, noisy, and heterogeneous environmental datasets efficiently."
],
"Supervised Learning": [
"Supervised learning methods help predict future trends based on historical data.",
"Example: Predicting air quality index (AQI) using regression or classification algorithms.",
"Common algorithms: Random Forest, Gradient Boosting, Neural Networks."
],
"Unsupervised Learning": [
"Used to detect patterns or anomalies without predefined labels.",
"Example: Clustering regions with similar pollution behavior or energy consumption.",
"Techniques: K-Means, DBSCAN, PCA."
],
"Deep Learning in Climate Science": [
"Deep neural networks can model complex relationships in climate systems.",
"CNNs are used in image-based satellite analysis (e.g., glacier retreat tracking).",
"RNNs and LSTMs are useful for time-series prediction such as rainfall or temperature forecasting."
],
"Case Study: Renewable Energy Forecasting": [
"ML algorithms predict solar and wind energy output based on weather data.",
"These predictions improve grid stability and reduce energy waste.",
"Integrating AI-driven models can enhance smart grid decision-making."
],
"Challenges and Limitations": [
"Data scarcity and lack of transparency in industrial datasets.",
"Model interpretability and bias in predictions.",
"High computational cost and carbon footprint of training large ML models."
],
"Future Directions": [
"Hybrid models combining physics-based and data-driven approaches.",
"Federated learning to protect data privacy while enabling collaboration.",
"Explainable AI (XAI) for more transparent environmental insights."
],
"Practical Implications": [
"Policy-makers can use ML predictions for better urban and environmental planning.",
"Businesses can adopt predictive maintenance to minimize resource waste.",
"Environmental organizations benefit from real-time monitoring dashboards."
],
"Conclusion": [
"Machine learning is reshaping how we understand and protect our planet.",
"Despite challenges, ML-driven sustainability offers powerful pathways to a cleaner and more efficient future.",
"Thank you for your attention 🌍"
]
}
for title, points in slides_content.items():
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = title
tf = slide.placeholders[1].text_frame
for p in points:
para = tf.add_paragraph()
para.text = p
para.font.size = Pt(18)
para.font.color.rgb = black
for i in range(1, 6):
if os.path.exists(f"figure_{i}.png"):
slide = prs.slides.add_slide(prs.slide_layouts[6])
slide.shapes.add_picture(f"figure_{i}.png", Inches(1), Inches(1.5), width=Inches(8))
print(f"📊 Figure {i} added.")
prs.save("Presentation_ML_Sustainability.pptx")
styles = getSampleStyleSheet()
pdf = SimpleDocTemplate("Presentation_ML_Sustainability.pdf", pagesize=A4)
story = [
Paragraph("Machine Learning for Environmental Sustainability", styles["Title"]),
Spacer(1, 12),
Paragraph("This document summarizes the main ideas from the presentation.", styles["Normal"]),
Paragraph("It covers data-driven methods applied in environmental science, renewable energy, and pollution control.", styles["Normal"]),
Spacer(1, 12),
Paragraph("Prepared for academic and research-oriented purposes.", styles["Normal"]),
Paragraph("Thank you for your attention 🌱", styles["Normal"]),
]
pdf.build(story)
doc = Document()
doc.add_heading("Presentation Notes (ML and Sustainability)", level=1)
doc.add_paragraph("This presentation discusses how machine learning techniques can contribute to environmental sustainability.")
doc.add_paragraph("Key sections include supervised and unsupervised learning, renewable energy forecasting, and future directions.")
doc.add_paragraph("During delivery, explain each method conceptually, and provide examples of real-world applications where possible.")
doc.add_paragraph("End with a discussion on ethical and environmental impacts of AI systems.")
doc.save("Presentation_ML_Sustainability.docx")
print("✅ Presentation successfully generated! Files ready:\n- PPTX\n- PDF\n- DOCX\n")