Skip to content

Instantly share code, notes, and snippets.

View kashaziz's full-sized avatar
💭
Contemplating the next Big Idea ...

Kashif Aziz kashaziz

💭
Contemplating the next Big Idea ...
View GitHub Profile
@kashaziz
kashaziz / scrapingexample.py
Last active May 28, 2024 04:36
Example of web scraping using Python and BeautifulSoup.
'''
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
@kashaziz
kashaziz / dropbox_file_renamer.py
Created March 25, 2019 08:15
Rename files in Dropbox using Python SDK and Dropbox API
# 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
@kashaziz
kashaziz / gist:48c8ca6996ac32e9c143db3231864c54
Created November 25, 2023 15:52
Product review sentiment analysis using python
""" 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'})
@kashaziz
kashaziz / house_prices_prediction_linear_regression.py
Created December 3, 2023 11:24
Predict House Pricing Date using Liner Regression and Python
"""
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
@kashaziz
kashaziz / logistic_regression_customer_prediction.py
Last active December 3, 2023 14:02
Using Logistic Regression to identify Customer Retention on e-commerce site
"""
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.
@kashaziz
kashaziz / decision_tree_customer_buying_prediction.py
Created December 3, 2023 18:00
Using Decision Tree Algorithm to predict Customer Buying pattern
"""
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
@kashaziz
kashaziz / fraud_live_data.csv
Last active December 17, 2023 16:20
Live shopping data for fraud detection
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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