Skip to content
Snippets Groups Projects
Commit ab119c16 authored by Fadi Gattoussi's avatar Fadi Gattoussi
Browse files

Cleanup git

parent bd4e2b41
No related branches found
No related tags found
No related merge requests found
# .gitignore
sas2/
\ No newline at end of file
sas2/
.idea/
\ No newline at end of file
,fadi,hp,21.12.2023 18:45,file:///home/fadi/.config/libreoffice/4;
\ No newline at end of file
......@@ -78,9 +78,6 @@ class MainWindow(QMainWindow):
self.GUI_selections = {}
# create new graphs
self.scatt = MplCanvas(self, width=6, height=5, dpi=100)
self.scatt.axes.set_title("Carats vs Price")
self.scatt.axes.scatter(diamonds['carat'], diamonds['price'], color='red', s=2)
# Create labels and input fields
self.input_fields = [QComboBox(self), QComboBox(self), QComboBox(self), QLineEdit(self),
QLineEdit(self), QLineEdit(self), QLineEdit(self), QLineEdit(self),
......@@ -113,6 +110,11 @@ class MainWindow(QMainWindow):
self.setWindowTitle('Assistance Systems')
self.show()
def update_graph(self):
self.scatt.axes.set_title("Carats vs Price")
self.scatt.axes.scatter(diamonds['carat'], diamonds['price'], color='red', s=2)
# self.scatt.axes.scatter(self.GUI_selections['carat'], self.price, color='blue', s=50)
def disable_input_field(self, field_name):
for key, value in self.menu_items.items():
if value == field_name:
......@@ -148,7 +150,7 @@ class MainWindow(QMainWindow):
self.price = model.predict_price(X_test)
# price = model.predict(X_test)[0]
self.display_price.setText(str(self.price))
self.update_graph()
def validate_inputs(self, val, attribute):
if Advanced.Advanced_selections[attribute]:
......@@ -291,4 +293,4 @@ app = QApplication(sys.argv)
window = MyTabs()
window.show()
app.exec()
app.exec()
\ No newline at end of file
File deleted
File deleted
File deleted
File deleted
import pandas as pd
from sklearn.model_selection import train_test_split
class DataPreprocessor:
def __init__(self, filepath):
self.filepath = filepath
self.data = pd.read_csv(filepath)
def clean_data(self):
self.data = self.data.dropna(inplace=True)
@staticmethod
def convert_to_numeric(self):
self['cut'] = self['cut'].map({'Ideal': 5, 'Premium': 4, 'Very Good': 3, 'Good': 2, 'Fair': 1})
self['color'] = self['color'].map({'D': 7, 'E': 6, 'F': 5, 'G': 4, 'H': 3, 'I': 2, 'J': 1})
self['clarity'] = self['clarity'].map({'IF': 8, 'VVS1': 7, 'VVS2': 6, 'VS1': 5, 'VS2': 4, 'SI1': 3, 'SI2': 2,
'I1': 1})
def get_X(self):
return self.data.drop('price', axis=1)
def get_y(self):
return self.data['price']
def split_data(X, y):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
return X_train, X_test, y_train, y_test
This diff is collapsed.
File deleted
["Endeavor Air Inc.", "JetBlue Airways", "ExpressJet Airlines Inc.", "Allegiant Air", "Hawaiian Airlines Inc.", "Spirit Air Lines", "SkyWest Airlines Inc.", "Frontier Airlines Inc.", "Empire Airlines Inc.", "Southwest Airlines Co.", "Mesa Airlines Inc.", "Republic Airlines", "Delta Air Lines Inc.", "United Air Lines Inc.", "Alaska Airlines Inc.", "Horizon Air", "Commutair Aka Champlain Enterprises, Inc.", "Trans States Airlines", "GoJet Airlines, LLC d/b/a United Express", "Air Wisconsin Airlines Corp", "Cape Air", "Compass Airlines", "Virgin America", "Peninsula Airways Inc.", "Envoy Air", "American Airlines Inc.", "Comair Inc.", "Capital Cargo International"]
\ No newline at end of file
File deleted
["Atlanta, GA", "Albany, GA", "Mobile, AL", "Evansville, IN", "Detroit, MI", "Jacksonville/Camp Lejeune, NC", "Boston, MA", "Syracuse, NY", "New Bern/Morehead/Beaufort, NC", "Montgomery, AL", "New York, NY", "Minneapolis, MN", "Cleveland, OH", "Charlotte, NC", "Fayetteville, NC", "St. Louis, MO", "Columbus, OH", "Indianapolis, IN", "Knoxville, TN", "Mosinee, WI", "Alexandria, LA", "Killeen, TX", "San Antonio, TX", "Peoria, IL", "Houston, TX", "Dallas/Fort Worth, TX", "Richmond, VA", "Portland, ME", "Kalamazoo, MI", "Cincinnati, OH", "Bristol/Johnson City/Kingsport, TN", "Washington, DC", "Asheville, NC", "Baton Rouge, LA", "Buffalo, NY", "Grand Rapids, MI", "Bismarck/Mandan, ND", "Chattanooga, TN", "Traverse City, MI", "Fort Smith, AR", "Burlington, VT", "Kansas City, MO", "Green Bay, WI", "Tulsa, OK", "Valdosta, GA", "Charleston/Dunbar, WV", "Fayetteville, AR", "Rochester, NY", "Savannah, GA", "Roanoke, VA", "Harrisburg, PA", "New Orleans, LA", "Nashville, TN", "Raleigh/Durham, NC", "Milwaukee, WI", "Gainesville, FL", "Tampa, FL", "Greensboro/High Point, NC", "Charlottesville, VA", "Bangor, ME", "Grand Forks, ND", "Brunswick, GA", "Memphis, TN", "Wilmington, NC", "Bloomington/Normal, IL", "Norfolk, VA", "Manchester, NH", "Dayton, OH", "Greer, SC", "Lexington, KY", "Louisville, KY", "Hartford, CT", "Saginaw/Bay City/Midland, MI", "Minot, ND", "Columbia, SC", "Columbus, GA", "Des Moines, IA", "Dothan, AL", "Elmira/Corning, NY", "Pittsburgh, PA", "Jacksonville, FL", "Chicago, IL", "Springfield, MO", "Shreveport, LA", "Huntsville, AL", "Omaha, NE", "Tallahassee, FL", "Madison, WI", "Lansing, MI", "Baltimore, MD", "Charleston, SC", "Little Rock, AR", "Fort Myers, FL", "Orlando, FL", "Fargo, ND", "Appleton, WI", "Akron, OH", "Harlingen/San Benito, TX", "White Plains, NY", "Philadelphia, PA", "Moline, IL", "Aguadilla, PR", "San Francisco, CA", "Newark, NJ", "Fort Lauderdale, FL", "Salt Lake City, UT", "Ponce, PR", "San Jose, CA", "Long Beach, CA", "Las Vegas, NV", "Los Angeles, CA", "West Palm Beach/Palm Beach, FL", "San Juan, PR", "Sarasota/Bradenton, FL", "Austin, TX", "Newburgh/Poughkeepsie, NY", "Denver, CO", "Seattle, WA", "Providence, RI", "Sacramento, CA", "Charlotte Amalie, VI", "Portland, OR", "Worcester, MA", "San Diego, CA", "Reno, NV", "Albany, NY", "Phoenix, AZ", "Oakland, CA", "Palm Springs, CA", "Christiansted, VI", "Burbank, CA", "Daytona Beach, FL", "Albuquerque, NM", "Brownsville, TX", "El Paso, TX", "Oklahoma City, OK", "Gulfport/Biloxi, MS", "South Bend, IN", "Mission/McAllen/Edinburg, TX", "Lake Charles, LA", "Lafayette, LA", "Myrtle Beach, SC", "Rochester, MN", "Lincoln, NE", "Birmingham, AL", "Augusta, GA", "Jackson/Vicksburg, MS", "Cedar Rapids/Iowa City, IA", "Panama City, FL", "Valparaiso, FL", "Key West, FL", "Allentown/Bethlehem/Easton, PA", "Sanford, FL", "Billings, MT", "Flint, MI", "Missoula, MT", "Idaho Falls, ID", "Stockton, CA", "Toledo, OH", "Sioux Falls, SD", "Ashland, WV", "Fresno, CA", "Eugene, OR", "Bellingham, WA", "Punta Gorda, FL", "St. Cloud, MN", "St. Petersburg, FL", "Plattsburgh, NY", "Ogdensburg, NY", "Concord, NC", "Springfield, IL", "Provo, UT", "Montrose/Delta, CO", "Fort Wayne, IN", "Portsmouth, NH", "Trenton, NJ", "Niagara Falls, NY", "Belleville, IL", "Rockford, IL", "Ogden, UT", "Boise, ID", "Medford, OR", "Great Falls, MT", "Pasco/Kennewick/Richland, WA", "Wichita, KS", "Grand Island, NE", "Monterey, CA", "Grand Junction, CO", "Laredo, TX", "Rapid City, SD", "Kalispell, MT", "Santa Maria, CA", "Bozeman, MT", "Hagerstown, MD", "Clarksburg/Fairmont, WV", "Colorado Springs, CO", "Owensboro, KY", "Honolulu, HI", "Kahului, HI", "Kona, HI", "Lihue, HI", "Hilo, HI", "Columbia, MO", "Casper, WY", "Scranton/Wilkes-Barre, PA", "Tucson, AZ", "Bend/Redmond, OR", "Santa Barbara, CA", "Aspen, CO", "Ontario, CA", "Helena, MT", "Sun Valley/Hailey/Ketchum, ID", "Durango, CO", "Williston, ND", "Arcata/Eureka, CA", "San Luis Obispo, CA", "Mammoth Lakes, CA", "Spokane, WA", "Jackson, WY", "Santa Rosa, CA", "Santa Ana, CA", "Redding, CA", "Bakersfield, CA", "Hayden, CO", "Midland/Odessa, TX", "Ithaca/Cortland, NY", "Lewiston, ID", "Pocatello, ID", "Aberdeen, SD", "Cody, WY", "Alpena, MI", "Escanaba, MI", "Pellston, MI", "Bemidji, MN", "Brainerd, MN", "Butte, MT", "Cedar City, UT", "St. George, UT", "Sault Ste. Marie, MI", "Marquette, MI", "Elko, NV", "Hibbing, MN", "Binghamton, NY", "Twin Falls, ID", "Rhinelander, WI", "International Falls, MN", "Iron Mountain/Kingsfd, MI", "Dallas, TX", "Columbus, MS", "Monroe, LA", "State College, PA", "Erie, PA", "La Crosse, WI", "Duluth, MN", "Muskegon, MI", "Pueblo, CO", "Hancock/Houghton, MI", "Paducah, KY", "Quincy, IL", "Rock Springs, WY", "Jamestown, ND", "Devils Lake, ND", "Laramie, WY", "Gillette, WY", "Eau Claire, WI", "Hays, KS", "Eagle, CO", "Cape Girardeau, MO", "North Bend/Coos Bay, OR", "Amarillo, TX", "Miami, FL", "Islip, NY", "Pago Pago, TT", "Hoolehua, HI", "Lanai, HI", "Kapalua, HI", "Atlantic City, NJ", "Latrobe, PA", "Lubbock, TX", "Pensacola, FL", "Corpus Christi, TX", "Melbourne, FL", "Fairbanks, AK", "Anchorage, AK", "Newport News/Williamsburg, VA", "Guam, TT", "Gunnison, CO", "Bethel, AK", "Kodiak, AK", "Deadhorse, AK", "Barrow, AK", "Ketchikan, AK", "Juneau, AK", "Sitka, AK", "Petersburg, AK", "Wrangell, AK", "Nome, AK", "Kotzebue, AK", "Yakutat, AK", "Cordova, AK", "Adak Island, AK", "Yakima, WA", "Santa Fe, NM", "Champaign/Urbana, IL", "Dickinson, ND", "Saipan, TT", "Rota, TT", "Walla Walla, WA", "Wenatchee, WA", "Pullman, WA", "College Station/Bryan, TX", "Hobbs, NM", "Youngstown/Warren, OH", "Unalaska, AK", "Scottsbluff, NE", "Nantucket, MA", "Martha's Vineyard, MA", "Branson, MO", "Tyler, TX", "San Angelo, TX", "Wichita Falls, TX", "Beaumont/Port Arthur, TX", "Lawton/Fort Sill, OK", "Waco, TX", "Flagstaff, AZ", "Yuma, AZ", "Meridian, MS", "Hattiesburg/Laurel, MS", "Roswell, NM", "Kearney, NE", "Moab, UT", "Vernal, UT", "Lewisburg, WV", "Staunton, VA", "Salina, KS", "Liberal, KS", "North Platte, NE", "Prescott, AZ", "Abilene, TX", "Manhattan/Ft. Riley, KS", "Texarkana, AR", "Lynchburg, VA", "Greenville, NC", "New Haven, CT", "Presque Isle/Houlton, ME", "Hilton Head, SC", "Longview, TX", "Waterloo, IA", "Sioux City, IA", "Dubuque, IA", "Garden City, KS", "Salisbury, MD", "Williamsport, PA", "Florence, SC", "Stillwater, OK", "Joplin, MO", "Watertown, NY", "Cheyenne, WY", "Del Rio, TX", "Hyannis, MA", "Dillingham, AK", "King Salmon, AK", "Gustavus, AK", "West Yellowstone, MT"]
\ No newline at end of file
asttokens==2.4.1
comm==0.2.0
contourpy==1.2.0
cycler==0.12.1
debugpy==1.8.0
decorator==5.1.1
exceptiongroup==1.2.0
executing==2.0.1
fonttools==4.46.0
ipykernel==6.27.1
ipython==8.18.1
jedi==0.19.1
joblib==1.3.2
jupyter_client==8.6.0
jupyter_core==5.5.0
kiwisolver==1.4.5
lightgbm==4.1.0
Markdown==3.5.1
matplotlib==3.8.2
matplotlib-inline==0.1.6
nest-asyncio==1.5.8
numpy==1.26.2
packaging==23.2
pandas==2.1.4
parso==0.8.3
pexpect==4.9.0
Pillow==10.1.0
platformdirs==4.1.0
prompt-toolkit==3.0.41
psutil==5.9.6
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.17.2
pyparsing==3.1.1
PyQt6==6.6.1
PyQt6-Qt6==6.6.1
PyQt6-sip==13.6.0
pyqtgraph==0.13.3
python-dateutil==2.8.2
pytz==2023.3.post1
pyzmq==25.1.2
qtgui==0.0.1
qtwidgets==1.1
scikit-learn==1.3.2
scipy==1.11.4
six==1.16.0
stack-data==0.6.3
threadpoolctl==3.2.0
tornado==6.4
traitlets==5.14.0
tzdata==2023.3
wcwidth==0.2.12
xgboost==2.0.3
%% Cell type:code id: tags:
``` python
import pandas as pd
import sklearn as sk
import matplotlib.pyplot as plt
import json
import math
```
%% Cell type:code id: tags:
``` python
cf_2018 = pd.read_csv('flight_data/Combined_Flights_2018.csv')
cf_2019 = pd.read_csv('flight_data/Combined_Flights_2019.csv')
cf_2018.head()
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[2], line 1
----> 1 cf_2018 = pd.read_csv('flight_data/Combined_Flights_2019.csv')
2 cf_2018.head()
NameError: name 'pd' is not defined
%% Cell type:code id: tags:
``` python
# Filter the dataframe to include only the delays from JFK
import RegressionModel
filtered_df = cf_2018[(cf_2018['Origin'] == 'JFK')].copy()
RegressionModel.destinations = list(cf_2018['DestCityName'].unique())
filtered_df
```
%% Cell type:code id: tags:
``` python
relevant_columns = ['FlightDate', 'DOT_ID_Operating_Airline', 'DestAirportID', 'DepDelayMinutes', 'ArrDelayMinutes']
jfk_flights_2018 = filtered_df[relevant_columns].copy()
jfk_flights_2018.dropna(inplace=True)
```
%% Cell type:code id: tags:
``` python
jfk_flights_2018
```
%% Cell type:code id: tags:
``` python
# Convert 'FlightDate' into numerical components
jfk_flights_2018['FlightDate'] = pd.to_datetime(jfk_flights_2018['FlightDate'])
jfk_flights_2018['Year'] = jfk_flights_2018['FlightDate'].dt.year
jfk_flights_2018['Month'] = jfk_flights_2018['FlightDate'].dt.month
jfk_flights_2018['Day'] = jfk_flights_2018['FlightDate'].dt.day
jfk_flights_2018 = jfk_flights_2018.dropna()
```
%% Cell type:code id: tags:
``` python
from sklearn.model_selection import train_test_split
# Choose your target variable, e.g., 'DepDelayMinutes'
X = jfk_flights_2018.drop('DepDelayMinutes', axis=1)
y = jfk_flights_2018['DepDelayMinutes']
jfk_flights_2018
```
%% Cell type:code id: tags:
``` python
# Splitting the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
X_train = X_train.apply(pd.to_numeric, errors='coerce')
y_train = y_train.apply(pd.to_numeric, errors='coerce')
X_test = X_test.apply(pd.to_numeric, errors='coerce')
y_test = y_test.apply(pd.to_numeric, errors='coerce')
```
%% Cell type:code id: tags:
``` python
from sklearn.linear_model import LinearRegression
# Initialize the model
model = LinearRegression()
# Train the model
model.fit(X_train, y_train)
```
%% Cell type:code id: tags:
``` python
from sklearn.metrics import mean_squared_error, r2_score
# Predict on the test set
y_pred = model.predict(X_test)
# Evaluate the model
mse = mean_squared_error(y_test, y_pred)
r2 = r2_score(y_test, y_pred)
print("Mean Squared Error:", mse)
print("R^2 Score:", r2)
```
This diff is collapsed.
%% Cell type:code id:initial_id tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment