File size: 976 Bytes
c03cd2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
import plotly.express as px
import plotly.graph_objects as go

# Uygulama başlığı
st.title("TV Reklamı ve Satış Analizi")

# Veriyi yükle
data = pd.read_csv("https://raw.githubusercontent.com/amankharwal/Website-data/master/Advertising.csv")

# İlk 5 satırı göster
st.subheader("Veri Seti")
st.write(data.head())

# X ve y değerlerini ayır
x = data["TV"].values.reshape(-1, 1)
y = data["Sales"]

# Modeli oluştur ve eğit
model = LinearRegression()
model.fit(x, y)

# Tahminler için aralık oluştur
x_range = np.linspace(x.min(), x.max(), 100)
y_range = model.predict(x_range.reshape(-1, 1))

# Grafiği oluştur
fig = px.scatter(data, x='TV', y='Sales', opacity=0.65)
fig.add_traces(go.Scatter(x=x_range, y=y_range, name='Linear Regresyon', mode='lines'))

# Grafiği göster
st.subheader("TV Reklamı ve Satış İlişkisi")
st.plotly_chart(fig)