0% found this document useful (0 votes)
6 views4 pages

Deprecation Warning for Seaborn Palette

Uploaded by

Immanuel Sam 12B
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Deprecation Warning for Seaborn Palette

Uploaded by

Immanuel Sam 12B
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import os

import pandas as pd
import [Link] as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from [Link] import mean_squared_error, r2_score

facebook_file = "Facebook_Marketplace_data.csv"
sales_file = "advertising_sales_data.xlsx"

if not [Link](facebook_file):
raise FileNotFoundError(f"Error: {facebook_file} not found. Please
check the file path.")

if not [Link](sales_file):
raise FileNotFoundError(f"Error: {sales_file} not found. Please
check the file path.")

facebook_df = pd.read_csv(facebook_file)

facebook_df["status_published"] =
pd.to_datetime(facebook_df["status_published"])

[Link](figsize=(10, 6))
[Link](data=facebook_df, x="status_type", y="num_reactions",
palette="coolwarm")
[Link]("Distribution of Reactions by Post Type")
[Link](rotation=45)
[Link]()

facebook_df["post_month"] = facebook_df["status_published"].[Link]
monthly_engagement = facebook_df.groupby("post_month")
[["num_reactions", "num_comments", "num_shares"]].sum()

[Link](figsize=(12, 6))
monthly_engagement.plot(marker="o")
[Link]("Monthly Engagement Trends")
[Link]("Month")
[Link]("Total Engagement")
[Link](title="Engagement Type")
[Link](True)
[Link]()
sales_df = pd.read_excel(sales_file)

if "Radio" in sales_df.columns:
sales_df["Radio"] =
sales_df["Radio"].fillna(sales_df["Radio"].median())

X = sales_df[["TV", "Radio", "Newspaper"]]


y = sales_df["Sales"]

X_train, X_test, y_train, y_test = train_test_split(X, y,


test_size=0.2, random_state=42)

model = LinearRegression()
[Link](X_train, y_train)

y_pred = [Link](X_test)

r2 = r2_score(y_test, y_pred)
rmse = mean_squared_error(y_test, y_pred) ** 0.5

print(f"Model Performance:")
print(f"R² Score: {r2:.3f}")
print(f"Root Mean Squared Error (RMSE): {rmse:.3f}")

coefficients = [Link](model.coef_, [Link],


columns=["Coefficient"])
print("\nFeature Importance:")
print(coefficients)

<ipython-input-4-11893b8494d8>:27: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be


removed in v0.14.0. Assign the `x` variable to `hue` and set
`legend=False` for the same effect.

[Link](data=facebook_df, x="status_type", y="num_reactions",


palette="coolwarm")
<Figure size 1200x600 with 0 Axes>
Model Performance:
R² Score: 0.906
Root Mean Squared Error (RMSE): 1.704

Feature Importance:
Coefficient
TV 0.054509
Radio 0.100991
Newspaper 0.004299

You might also like