Giter Club home page Giter Club logo

new-york-city-taxi-fare-prediction's Introduction

New-York-City-Taxi-Fare-Prediction

My project was to predict New York City taxi fares, which was a regression problem. The dataset was very large, with a size of 5.3 GB, which made it difficult to import into Python. I attempted to use Spark to import the dataset, but was unsuccessful. Then, I used the nrows feature of pandas and imported 2,000,000 records for the training dataset.

The first step of data cleaning involved dealing with the outliers in each feature of the dataset. To remove outliers, I defined the acceptable range of values as three standard deviations away from the median, and stored the lower and upper bounds in the variables low and high. I then filtered out any values in the DataFrame that fell outside the acceptable range by using the >= and <= operators to create a boolean mask that selected only the rows with x values between low and high. After that, I used the pickup and dropoff coordinates to calculate the distance traveled by the taxi in kilometers.

Next, I performed exploratory data analysis (EDA) on the dataset, which involved plotting different plots to gain various insights and information.

To train the model, I used a pipeline that trained five models, namely LinearRegression, DecisionTreeRegressor, RandomForestRegressor, AdaBoostRegressor, and GradientBoostingRegressor. I got the best score with the GradientBoostingRegressor, with a training score of 81.02 and a testing score of 80.78. I then used grid search CV for hyperparameter tuning for Ridge and Lasso, but the scores were similar to LinearRegression. Next, I tried hyperparameter tuning for the decision tree, which was a time-consuming task, taking 8 to 9 hours. After several attempts, I reduced the number of parameters and did hyperparameter tuning, but the scores were not good. Finally, I tried the XGBoost algorithm, which gave me the best scores, with a training score of 81.85 and a testing score of 81.20.

I used this model to predict the fare prices for the test dataset. Overall, I learned a lot from this project, and it helped me improve my skills in data cleaning, EDA, and model training.

new-york-city-taxi-fare-prediction's People

Contributors

adityag009 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.