<jupyter_start><jupyter_text>There are 12 missing values for pledged data, 59 for reward_levels and 1322 for location.<jupyter_code>ks_df.describe()<jupyter_output><empty_output><jupyter_text>1. What is the mean (total) pledge that projects get?<jupyter_code>pledged_mean = round(ks_df["pledged"].mean(), 2)
pledged_mean<jupyter_output><empty_output><jupyter_text>2. Create a histogram that shows the distribution for number of backers. What is the skew of the distribution?<jupyter_code>plt.figure(figsize=(12, 5))
sns.histplot(ks_df["backers"], kde=True, bins=100)
plt.xlabel("Backers")
plt.ylabel("Frequency")
plt.title("Distribution of Project Backers")
plt.show()
ks_df["backers"].describe()
ks_df.skew(axis=0, skipna=True)
backers_skewness = ks_df["backers"].skew()

print("Skewness:")
print(round(backers_skewness, 2))<jupyter_output>Skewness:
87.47<jupyter_text>There are lots of otliers which I will eliminate usint the IQR method.<jupyter_code># calculate 25% and 75% quartiles and IQR = Q3-Q1
Q1 = ks_df.backers.quantile(0.25)
Q3 = ks_df.backers.quantile(0.75)
IQR = Q3 - Q1
Q1, Q3, IQR
# calculate min and max thresholds
lower_limit = Q1 - 1.5 * IQR
upper_limit = Q3 + 1.5 * IQR
lower_limit, upper_limit
# outliers
# ks_df[(ks_df.backers < lower_limit) | (ks_df.backers > upper_limit)]

# dataframe w/o outliers
df_no_outlier = ks_df[(ks_df.backers > lower_limit) & (ks_df.backers < upper_limit)]
df_no_outlier.head(2)
df_no_outlier.describe()
sns.boxplot(x=df_no_outlier["backers"])
plt.xlabel("Backers")
plt.title("Boxplot of Project Backers (outliers excluded)")
plt.show()
plt.figure(figsize=(12, 5))
sns.histplot(df_no_outlier["backers"], kde=True, bins=50, color="orange")
plt.xlabel("Backers")
plt.ylabel("Frequency")
plt.title("Distribution of Project Backers (outliers removed)")
plt.show()
backers_skewness_n = df_no_outlier["backers"].skew()

print("Skewness_wo_outliers:")
print(round(backers_skewness_n, 2))<jupyter_output>Skewness_wo_outliers:
1.26<jupyter_text>3. Is the 'duration' variable normally distributed?<jupyter_code>plt.figure(figsize=(10, 5))
sns.histplot(ks_df["duration"], kde=True, bins=30)
plt.xlabel("Duration")
plt.ylabel("Frequecny")
plt.title("Distribution of Project Duration")
plt.show()<jupyter_output><empty_output><jupyter_text>Duration variable is not normal distributed.  4. If you could collect data on another attribute of these projects, what would it be and why? There is nothing about marketing presence so a possible new variable can be if there is a FB or Twitter account which can contribute to the marketing campaign. Also of interest might be knowing the targeted audience or even the expected number of customers.  Qualitative Analysis<jupyter_code>ks_df.status.value_counts(normalize=True).plot(kind="pie", figsize=(9, 6))
# colors = ["orange", "red", "grey", "darkturquoise", "salmon"]
# status = round(ks_df["status"].value_counts() / len(ks_df["status"]) * 100, 2)

# labels = list(status.index)
# values = list(status.values)

# trace1 = go.Pie(
#     labels=labels,
#     values=values,
#     marker=dict(colors=colors),
#     #    line=dict(color="rgb(100,100,100)", width=1),
# )

# layout = go.Layout(title="Distribuition of Status", legend=dict(orientation="h"))

# fig = go.Figure(data=[trace1], layout=layout)
# iplot(fig)<jupyter_output><empty_output><jupyter_text>What's the best length of time to run a campaign?<jupyter_code># average succsessful project duration
success_duration_avg = ks_df[ks_df["status"] == "successful"].duration.mean()

print("Successful campaign average duration:")
print(round(success_duration_avg, 1))
plt.figure(figsize=(12, 5))
sns.histplot(
    data=ks_df[ks_df["status"] == "successful"],
    x="duration",
    bins=20,
    color="orange",
    kde=True,
)<jupyter_output><empty_output><jupyter_text>What's the ideal pledge goal?<jupyter_code># average successful project pledge
success_pledge_goal_avg = ks_df[ks_df["status"] == "successful"].goal.mean()

print("Successful campaign average goal: ")
print(round(success_pledge_goal_avg, 1))
# Plot showing rates of success by duration

plt.figure(figsize=(12, 6))

sns.catplot(x="status", y="goal", data=ks_df, kind="bar", ci=None)
plt.xlabel("Status")
plt.ylabel("Pledge Goal")
plt.title("Pledge Goals by Status")
plt.show()<jupyter_output><empty_output><jupyter_text>What type of projects would be most successful at getting funded?<jupyter_code># Print categories
ks_df["category"].value_counts()<jupyter_output><empty_output><jupyter_text>Film & video apperas 2 times, one of them is misspelled, needs to be fixed<jupyter_code>ks_df["category"] = ks_df["category"].replace(["Film &amp; Video"], "Film & Video")
ks_df["category"].value_counts()<jupyter_output><empty_output><jupyter_text>There are 14 categories<jupyter_code>ks_df.category.value_counts(normalize=True).plot(kind="pie", figsize=(9, 6))
# colors = ["orange", "red", "grey", "darkturquoise", "salmon"]
# category = round(ks_df["category"].value_counts() / len(ks_df["category"]) * 100, 2)

# labels = list(category.index)
# values = list(category.values)

# trace1 = go.Pie(
#     labels=labels,
#     values=values,
#     marker=dict(colors=colors),
#     #    line=dict(color="rgb(100,100,100)", width=1),
# )

# layout = go.Layout(title="Distribuition of Category", legend=dict(orientation="h"))

# fig = go.Figure(data=[trace1], layout=layout)
# iplot(fig)
ks_df[ks_df["status"] == "successful"].category.value_counts(normalize=True).plot(kind="pie", figsize=(9, 6))
#df[df["status"] == "successful"]["category"]

# colors = ["orange", "red", "grey", "darkturquoise", "salmon"]
# category = round(ks_df[ks_df["status"] == "successful"]["category"].value_counts() / len(ks_df[ks_df["status"] == "successful"]) * 100, 2)

# labels = list(category.index)
# values = list(category.values)

# trace1 = go.Pie(
#     labels=labels,
#     values=values,
#     marker=dict(colors=colors),
#     #    line=dict(color="rgb(100,100,100)", width=1),
# )

# layout = go.Layout(title="Distribuition of Category", legend=dict(orientation="h"))

# fig = go.Figure(data=[trace1], layout=layout)
# iplot(fig)

plt.figure(figsize=(12,6))
#sns.countplot(x="category", data=ks_df_success, palette="coolwarm")
#plt.title("Count of Successful Campaigns Based on Category")
#plt.show()

plt.figure(figsize=(15,6))
chart=sns.countplot(
    x='category',
    data=ks_df[ks_df["status"] == "successful"],
    order=ks_df[ks_df["status"] == "successful"]['category'].value_counts().index[:13]
)

chart.set_xticklabels(chart.get_xticklabels(),
    rotation=30,
    horizontalalignment='right',
    fontweight='light',
    fontsize='large') 
plt.title('Count of Successful Campaigns Based on Category')
    
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Is there an ideal month/day/time to launch a campaign?<jupyter_code># Changing the datetime object
ks_df["funded date"] = pd.to_datetime(ks_df["funded date"])

# Extracting Timestamp to generate new columns as Month, Day, Hour and Weekday
# ad_df["Timestamp"].dt.hour
ks_df["funded hour"] = ks_df["funded date"].dt.hour
ks_df["funded month"] = ks_df["funded date"].dt.month
ks_df["funded day no"] = ks_df["funded date"].dt.weekday
ks_df["funded day"] = ks_df["funded date"].dt.day_name()
ks_df["funded year"] = ks_df["funded date"].dt.year
ks_df.head(2)
# Hourly distribution of succsessful campaigns
plt.figure(figsize=(12, 6))
sns.countplot(
    x="funded hour", data=ks_df[ks_df["status"] == "successful"], palette="magma"
)
plt.title("Successful Campaigns by funded hour distribution")<jupyter_output><empty_output><jupyter_text>The most uccessful campaigns were funded at 3-4am<jupyter_code># Dayly distribution of succsessful campaigns
plt.figure(figsize=(12, 6))
sns.countplot(
    x="funded day", data=ks_df[ks_df["status"] == "successful"], palette="magma"
)
plt.title("Successful Campaigns by funded day distribution")<jupyter_output><empty_output><jupyter_text>Not a big difference but he most uccessful campaigns were funded Saturdays.<jupyter_code># Monthly distribution of succsessful campaigns
plt.figure(figsize=(12, 6))
sns.countplot(
    x="funded month", data=ks_df[ks_df["status"] == "successful"], palette="magma"
)
plt.title("Successful Campaigns by funded month distribution")<jupyter_output><empty_output><jupyter_text>The most successful campaigns were funded in spring, March - May.<jupyter_code>ks_df["funded year"].value_counts()<jupyter_output><empty_output><jupyter_text>Future analysis might include the location of the campaign- continents, countries, states for US<jupyter_code># average successful project updates
success_pledge_updates_avg = ks_df[ks_df["status"] == "successful"].updates.mean()

print("Successful campaign average updates: ")
print(round(success_pledge_updates_avg, 1))
# average successful project comments
success_pledge_comments_avg = ks_df[ks_df["status"] == "successful"].comments.mean()

print("Successful campaign average comments: ")
print(round(success_pledge_comments_avg, 1))<jupyter_output>Successful campaign average comments: 
14.4
{'fraction_non_alphanumeric': 0.1510640643951924, 'fraction_numerical': 0.01742198698864263, 'mean_word_length': 7.2230281051677245, 'pattern_counts': {'":': 0, '<': 64, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '459759', 'license': 'MIT', 'n_tokens_mistral': 3368, 'n_tokens_neox': 3156, 'n_words': 663, 'path': 'DSI_kickstarterscrape_dataset.ipynb', 'repo_name': 'cristina-iacob/kickstarter_analysis', 'size': '9069'}