Kendall Starcevich
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # STAT 172 Project - GLM Logistic Regression of Highly Rated Amazon Products Group members: Kendall Starcevich, Olivia Soppa, Munkh-Orgil Tumurchudur ## Code and Meaningful Outputs Below: ## Cleaning Data #### Importing Data ```sas! /* IMPORT AND READ DATA */ proc import out = amazon datafile = "/home/u63558812/amazon_products_sales_data_uncleaned.csv" dbms = csv replace; guessingrows = MAX; run; /*only keep columns we plan to use */ data amazon; set amazon; keep number_of_reviews listed_price 'current/discounted_price'n is_best_seller is_sponsored rating is_couponed buy_box_availability; run; /*check data types*/ proc contents data = amazon; run; ``` Here are the first 5 rows of the dataset. We are predicting 'rating', but will have to make this categorical. We also decided to make listed_price, is_best_seller, is_couponed, and buy_box_availability binary. ![Head of Data](https://hackmd.io/_uploads/rkAhAHnsgx.png) You can also see below from the results of ```proc contents``` that all of the variables are Char, even when we want some of them to be Num. The code for cleaning is below. ![Proc Contents](https://hackmd.io/_uploads/H1IV1U3iee.png) #### Cleaning Code *NOTE: some of the cleaning code below was written with the assistance of Chat GPT. The usage is sited in the “AI_use_documentation.pdf* ```sas! /* CLEANING */ /* ------------ Cleaning number_of_reviews -------------- */ /* Checkout values */ proc freq data = amazon; tables number_of_reviews; run; /* removes comma, makes num */ data amazon; set amazon; clean_number_reviews = input(compress(number_of_reviews, ","), best.); run; /*confirm that it is num*/ proc contents data = amazon; run; /* now called clean_number_reviews */ /*------------ cleaning listed_price --------------- */ /* check for null values*/ proc freq data=amazon; tables listed_price / missing; run; /*make binary*/ data amazon; set amazon; if listed_price = "No Discount" then is_discount = "No Discount"; else is_discount = "Discount"; run; /*now called is_discount*/ /* -------------- Cleaning current/discount_price -------------- */ /*check for missing*/ proc freq data = amazon; tables 'current/discounted_price'n / missing; run; /*convert to numeric*/ data amazon; set amazon; clean_current_discounted_price = input('current/discounted_price'n, best.); run; /*drop missing*/ data amazon; set amazon; if clean_current_discounted_price ne .; run; /* confirm missing were dropped */ proc freq data=amazon; tables clean_current_discounted_price / missing; run; /* confirm it is now numeric */ proc contents data=amazon; run; /*now called clean_current_discounted_price */ /*------------------ clean is_best_seller ----------------------*/ /*checkout is_best_seller*/ proc freq data = amazon; tables is_best_seller; run; /*make binary*/ data amazon; set amazon; is_best_seller_clean = is_best_seller; if is_best_seller in ("Amazon's", "Best Seller") then is_best_seller_clean = "Best Seller"; else is_best_seller_clean = "No"; run; /*now called is_best_seller_clean*/ /*----------------- clean is_sponsored -------------------*/ /*checkout values*/ proc freq data=amazon; tables is_sponsored / missing; run; /*it is already clean with no nulls*/ /*--------------- cleaning rating (y var) -----------------*/ /* convert to numeric */ data amazon; set amazon; rating_num = input(scan(rating, 1, ' '), best.); run; /* drop na's */ data amazon; set amazon; if rating_num ne .; run; /* make binary */ data amazon; set amazon; if rating_num >= 4.5 then rating_cat = 1; else rating_cat = 0; run; /*now called rating_cat*/ /*---------------------- clean is_couponed ------------------------*/ /*check out values*/ proc freq data = amazon; tables is_couponed; run; /*make binary*/ data amazon; set amazon; is_couponed_clean = is_couponed; if is_couponed = "No Coupon" then is_couponed_clean = "No"; else is_couponed_clean = "Yes"; run; /*now called is_couponed_clean */ /*----------------- clean buy_box_availability -------------------*/ /*checkout values*/ proc freq data=amazon; tables buy_box_availability / missing; run; /*make binary*/ data amazon; set amazon; buy_box_clean = buy_box_availability; if buy_box_availability = "Add to cart" then buy_box_clean = "Yes"; else buy_box_clean = "No"; run; /*now called buy_box_clean */ ``` Here are the results of cleaning: ![Clean Head](https://hackmd.io/_uploads/HyM4fUnjlg.png) You can also see that the variables are the correct datatypes. ![Clean Proc Contents](https://hackmd.io/_uploads/HkvLGLhigx.png) ## Pre-Anlysis Check for Complete Separation: Output and Complete Analysis Before making the model, we must plot each of the x-vars to check for Complete Separation. The categorical vars will be a table, and the quantitative vars will be a plot. ```sas! /* clean_number_reviews */ proc sgplot data = amazon; scatter x = clean_number_reviews y = rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.32.55 AM](https://hackmd.io/_uploads/r14HwL3iee.png) We can tell from this plot that all products with more than around 170,000 reviews are highly rated (rating of 4.5 or above). ```sas! /*is_discount*/ proc freq data = amazon; tables is_discount*rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.40.44 AM](https://hackmd.io/_uploads/ryFrKLnogg.png) There does not seem to be complete separation because there are no 'empty cells'. There is a very similar percentage between highly rated vs not highly rated in both discount and no discount. Both around 42-43% low rated and 56-57% high rated. This leads us to believe that this variable might not be too helpful in predicting our y. ```sas! /*clean_current_discounted_price*/ proc sgplot data = amazon; scatter x = clean_current_discounted_price y = rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.42.14 AM](https://hackmd.io/_uploads/Bk7_F83slx.png) There doesn't seem to be a visible pattern here, but no complete separation because the 1s and 0s seem evenly distributed. ```sas! /*is_best_seller_clean*/ proc freq data = amazon; tables is_best_seller_clean*rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.46.56 AM](https://hackmd.io/_uploads/Skstq8njll.png) This shows no complete separation. It also shows that 67% of Best Seller's are highly rated, compared to only 57% of not best sellers being highly rated. This makes sense contextually because 'Best Seller' items are likely popular with customers. However, only 3% of products are rated as Best Sellers. ```sas! /*is_sponsored*/ proc freq data = amazon; tables is_sponsored*rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.49.16 AM](https://hackmd.io/_uploads/HJuzo82jex.png) This shows no complete separation. 'Organic' makes up 77% of the products. It also shows that Organic items are highly rated 59% of the time, while Sponsored are only 52%. ```sas! /*is_couponed_clean*/ proc freq data = amazon; tables is_couponed_clean*rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.50.44 AM](https://hackmd.io/_uploads/HkkOiUhoxe.png) There is no complete separation here. 94.4% of the products are not couponed. This shows that 59% of products that are not couponed are highly rated, while only 26% of couponed are highly rated. This will likely be a good predictor. ```sas! /*buy_box_clean*/ proc freq data = amazon; tables buy_box_clean*rating_cat; run; ``` ![Screenshot 2025-09-20 at 11.55.27 AM](https://hackmd.io/_uploads/BJpt2Lhilx.png) There is no complete separation here. You can see most products (90.24%) do have the buy_box button. Of these, 59% are highly rated, while only 40% of products that do not have the buy_box button are highly rated. Therefore, for now **we do not suspect that there is complete separation in any of the X vars.** We will do a post-analysis check after creating the model to confirm. ## Creating the Model ### Code for Model ```sas! proc logistic data = amazon; class is_discount is_best_seller_clean is_sponsored is_couponed_clean buy_box_clean / param = reference; model rating_cat(event = '1') = clean_number_reviews is_discount clean_current_discounted_price is_best_seller_clean is_sponsored is_couponed_clean buy_box_clean / clparm = both; output out=diags predicted = pred xbeta=linpred; run; ``` ### Model Outputs ![Screenshot 2025-09-20 at 12.02.49 PM](https://hackmd.io/_uploads/BJHH0Uhoxx.png) ![Screenshot 2025-09-23 at 11.30.33 PM](https://hackmd.io/_uploads/ByEeEgb2xg.png) ![Screenshot 2025-09-23 at 11.31.12 PM](https://hackmd.io/_uploads/rkoMVlW3lx.png) ![Screenshot 2025-09-20 at 12.03.47 PM](https://hackmd.io/_uploads/rJGF0U3oex.png) ![Screenshot 2025-09-20 at 12.04.43 PM](https://hackmd.io/_uploads/HkI30Lhigl.png) ![Screenshot 2025-09-20 at 12.04.51 PM](https://hackmd.io/_uploads/Sy6nALhige.png) ![Screenshot 2025-09-20 at 12.04.59 PM](https://hackmd.io/_uploads/r1LTRU3sel.png) ![Screenshot 2025-09-20 at 12.05.09 PM](https://hackmd.io/_uploads/r1kRA8hoxg.png) ![Screenshot 2025-09-20 at 12.05.17 PM](https://hackmd.io/_uploads/SyDARUnixl.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully