AI Analiz Aracı
Kapsamlı veri analizi, metin madenciliği, duygu analizi, örüntü tanıma ve otomatik rapor oluşturma için AI destekli araçlar geliştirin.
Giriş
AI, veri analizini manuel ve zaman alıcı bir süreçten otomatik bir içgörü üretme boru hattına dönüştürür. Karmaşık sorgular yazmak veya istatistiksel modeller oluşturmak yerine, ne bilmek istediğinizi sade bir dille açıklayabilirsiniz.
Bu rehberde, yapılandırılmış verileri işleyebilen, metinleri analiz edebilen, duyguları ve örüntüleri tespit edebilen ve profesyonel raporları otomatik olarak oluşturabilen eksiksiz bir AI analiz aracı oluşturacaksınız.
AI ile Veri Analizi
AI, yapılandırılmış verileri (JSON, CSV, veritabanları) analiz edebilir ve bir insan analistin saatlerini alacak içgörüler üretebilir:
from openai import OpenAI
import json
client = OpenAI()
def analyze_dataset(data, context=""):
"""Perform AI-powered analysis on structured data."""
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": """You are a senior data analyst.
Analyze the provided data and return insights in JSON:
{
"summary": "Brief overview",
"key_metrics": [{"name": "", "value": "", "trend": ""}],
"patterns": ["pattern 1", "pattern 2"],
"anomalies": ["anomaly 1"],
"recommendations": ["action 1", "action 2"],
"risk_factors": ["risk 1"]
}"""},
{"role": "user", "content": f"Context: {context}\n\nData:\n{json.dumps(data, indent=2)}"}
],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
# Example usage
sales_data = {
"q1": {"revenue": 150000, "customers": 45, "churn": 3},
"q2": {"revenue": 180000, "customers": 52, "churn": 2},
"q3": {"revenue": 165000, "customers": 48, "churn": 7},
"q4": {"revenue": 210000, "customers": 61, "churn": 4}
}
insights = analyze_dataset(sales_data, "Annual B2B SaaS performance")
print(json.dumps(insights, indent=2))Metin Analizi
Metin analizi, yapılandırılmamış metinlerden — makaleler, e-postalar, raporlar, sosyal medya gönderileri — yapılandırılmış bilgi çıkarır:
def analyze_text(text, analysis_type="comprehensive"):
"""Analyze text for various linguistic properties."""
prompts = {
"comprehensive": """Analyze this text comprehensively:
1. Main topics and themes
2. Key entities (people, companies, locations)
3. Sentiment (positive/negative/neutral + confidence)
4. Writing style and tone
5. Summary in 2-3 sentences
Return as structured JSON.""",
"entities": """Extract all named entities from this text:
- People, Organizations, Locations, Dates, Products
Return as JSON with categories.""",
"keywords": """Extract the top 10 most important keywords/phrases.
For each, provide relevance score (0-1) and context.
Return as JSON array."""
}
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": prompts.get(analysis_type, prompts["comprehensive"])},
{"role": "user", "content": text}
],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
# Usage
article = """Artificial intelligence is transforming healthcare.
New diagnostic tools powered by machine learning can detect
diseases earlier and more accurately than traditional methods.
Hospitals in Germany and the US are adopting these systems rapidly."""
result = analyze_text(article, "comprehensive")
print(json.dumps(result, indent=2))Duygu Analizi
Duygu analizi, metnin duygusal tonunu belirler. Müşteri geri bildirimlerini, sosyal medyayı ve marka algısını izlemek için esastır:
def batch_sentiment_analysis(texts):
"""Analyze sentiment for multiple texts at once."""
formatted = "\n".join([f"{i+1}. {t}" for i, t in enumerate(texts)])
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": """Analyze the sentiment
of each numbered text. Return JSON:
{"results": [
{"id": 1, "text_preview": "first 30 chars...",
"sentiment": "positive/negative/neutral/mixed",
"confidence": 0.0-1.0,
"emotions": ["joy", "trust"],
"key_phrases": ["positive phrase"]}
]}"""},
{"role": "user", "content": formatted}
],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
# Analyze customer reviews
reviews = [
"Absolutely love this product! Best purchase ever.",
"Terrible experience. The item arrived broken.",
"It's okay. Nothing special but does the job.",
"Great quality but shipping was very slow.",
"Customer service was outstanding, they fixed everything!"
]
results = batch_sentiment_analysis(reviews)
for r in results["results"]:
print(f"Review {r['id']}: {r['sentiment']} ({r['confidence']})")✅ Pozitif/Negatifin Ötesinde
Modern AI, aynı metin içinde nüanslı duyguları (hayal kırıklığı, heyecan, kafa karışıklığı) ve karışık duyguları tespit edebilir. Daha zengin analiz için modelden sadece pozitif/negatif yerine belirli duyguları tanımlamasını isteyin.
Örüntü Tanıma
AI, verilerdeki insanların gözden kaçırabileceği örüntüleri — trendleri, anormallikleri, döngüsel davranışları ve korelasyonları — tespit etmede mükemmeldir:
def detect_patterns(data, data_type="time_series"):
"""Detect patterns in data using AI analysis."""
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": f"""You are an expert data scientist.
Analyze this {data_type} data for patterns:
1. Trends (upward, downward, cyclical)
2. Seasonality or periodic patterns
3. Outliers or anomalies
4. Correlations between variables
5. Predicted next values (if time series)
Return JSON with detailed findings and confidence levels."""},
{"role": "user", "content": json.dumps(data)}
],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
# Example: Detect patterns in website traffic
traffic_data = {
"daily_visitors": [
{"date": "2025-01-06", "visitors": 1200, "day": "Mon"},
{"date": "2025-01-07", "visitors": 1350, "day": "Tue"},
{"date": "2025-01-08", "visitors": 1400, "day": "Wed"},
{"date": "2025-01-09", "visitors": 1280, "day": "Thu"},
{"date": "2025-01-10", "visitors": 980, "day": "Fri"},
{"date": "2025-01-11", "visitors": 650, "day": "Sat"},
{"date": "2025-01-12", "visitors": 580, "day": "Sun"}
]
}
patterns = detect_patterns(traffic_data, "time_series")Rapor Oluşturma
Son adım, analiz sonuçlarını insan tarafından okunabilir raporlara dönüştürmektir. AI, hedef kitleye göre farklı stiller üretebilir:
def generate_report(analysis_results, report_type="executive"):
"""Generate a human-readable report from analysis results."""
styles = {
"executive": "Write a concise executive summary (max 300 words). Focus on key findings, business impact, and recommended actions.",
"technical": "Write a detailed technical report with methodology, statistical details, and data quality notes.",
"presentation": "Create presentation-ready bullet points with key metrics highlighted. Include talking points for each slide."
}
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": f"""Generate a {report_type}
report based on these analysis results.
Style: {styles.get(report_type, styles['executive'])}
Structure the report with clear sections and headers.
Use specific numbers from the data."""},
{"role": "user", "content": json.dumps(analysis_results, indent=2)}
]
)
return response.choices[0].message.content
# Generate different report types
report = generate_report(insights, "executive")
print(report)Analiz Boru Hattı Oluşturma
Tüm analiz adımlarını tek bir yeniden kullanılabilir boru hattında birleştirin:
class AIAnalyzer:
"""Complete AI analysis pipeline."""
def __init__(self):
self.client = OpenAI()
self.results = {}
def ingest(self, data, data_type="auto"):
"""Load and prepare data for analysis."""
self.raw_data = data
self.data_type = data_type
return self
def analyze(self, analyses=["summary", "patterns", "sentiment"]):
"""Run multiple analyses on the data."""
for analysis in analyses:
if analysis == "summary":
self.results["summary"] = analyze_dataset(self.raw_data)
elif analysis == "patterns":
self.results["patterns"] = detect_patterns(self.raw_data)
elif analysis == "sentiment":
if isinstance(self.raw_data, list):
self.results["sentiment"] = batch_sentiment_analysis(
self.raw_data
)
return self
def report(self, report_type="executive"):
"""Generate a final report."""
self.results["report"] = generate_report(
self.results, report_type
)
return self.results
# Usage — chain the pipeline
pipeline = AIAnalyzer()
results = (
pipeline
.ingest(sales_data)
.analyze(["summary", "patterns"])
.report("executive")
)
print(results["report"])⚠️ AI Analizini Doğrulayın
AI analizi güçlüdür ancak yanılmaz değildir. Sayısal iddiaları her zaman ham verilerle karşılaştırarak kontrol edin. Kritik iş kararları için AI analizini başlangıç noktası olarak kullanın, ardından geleneksel istatistiksel yöntemlerle doğrulayın.
Özet
Eksiksiz bir AI analiz boru hattı oluşturdunuz. Önemli çıkarımlar:
- AI, yapılandırılmış verileri, metinleri ve duyguları basit promptlarla saniyeler içinde analiz edebilir.
- Örüntü tanıma, insanların gözden kaçırabileceği trendleri ve anormallikleri belirlemeye yardımcı olur.
- Otomatik rapor oluşturma saatler kazandırır ve birden fazla format üretebilir.
- AI tarafından oluşturulan analizleri doğruluk için her zaman ham verilerle karşılaştırın.