This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Example of web scraping using Python and BeautifulSoup. | |
Sraping ESPN College Football data | |
http://www.espn.com/college-sports/football/recruiting/databaseresults/_/sportid/24/class/2006/sort/school/starsfilter/GT/ratingfilter/GT/statuscommit/Commitments/statusuncommit/Uncommited | |
The script will loop through a defined number of pages to extract footballer data. | |
''' | |
from bs4 import BeautifulSoup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# input name of image folder | |
image_folder = str(input("Enter folder name to fetch images: ")).lower() | |
# instantiate Dropbox connection | |
dbx = dropbox.Dropbox('dropbox access token') | |
# proceed if image folder exists in Dropbox | |
if dbx.files_get_metadata(image_folder).path_lower == image_folder: | |
# iterate through the files inside Dropbox folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Perform sentiment analysis on product reviews of Amazon product """ | |
import requests | |
from bs4 import BeautifulSoup | |
from textblob import TextBlob | |
def analyze_product_reviews(url): | |
response = requests.get(url) | |
soup = BeautifulSoup(response.content, 'html.parser') | |
reviews = soup.find_all('div', {'data-hook': 'review-collapsed'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script utilizes machine learning techniques to predict house prices based on various input features. | |
It performs data preprocessing, splits the data into training and testing sets, trains a linear regression model, | |
evaluates its performance using mean squared error (MSE) and R-squared. | |
""" | |
import pandas as pd | |
import numpy as np | |
from sklearn.preprocessing import OneHotEncoder | |
from sklearn.model_selection import train_test_split |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This Python script demonstrates the usage of logistic regression to predict whether customers will make the next purchase on an e-commerce site. | |
The code performs the following steps: | |
1. Load and Preprocess Data: | |
- Loads an e-commerce dataset containing customer features such as 'time_on_site', 'total_spent', 'is_returning_customer', and 'will_make_next_purchase'. | |
- Splits the data into training and testing sets. | |
2. Model Training: | |
- Creates a logistic regression model using scikit-learn. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This Python script showcases the application of decision trees in the context of e-commerce data analysis. | |
""" | |
# Import necessary libraries | |
import pandas as pd | |
from sklearn.model_selection import train_test_split | |
from sklearn.tree import DecisionTreeClassifier | |
from sklearn.metrics import accuracy_score, confusion_matrix | |
from sklearn.tree import export_text |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TransactionAmount TransactionTime MerchantInfo LocationInfo UserInfo DeviceInfo | |
68.2 01/03/2023 14:30 LocalShop3 CityA JohnDoe123 Mobile | |
95.4 02/03/2023 9:45 LocalShop2 CityB AliceSmith456 Desktop | |
110.8 03/03/2023 16:15 OnlineStore1 CityC BobJohnson789 Tablet | |
45.6 04/03/2023 12:00 OnlineStore1 CityA EveWilliams123 Mobile | |
75.3 05/03/2023 10:30 OnlineStore2 CityB CharlieBrown456 Desktop |