Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added notebook which modifies the preprocessing step for data normalisation #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eve-b612
Copy link

@eve-b612 eve-b612 commented Oct 9, 2024

Tested performance with 3 training data normalisation approaches: min max scaling, standard scaling, robust scaling. Results showed no improvement with any of these approaches.

Issue Number

Purpose

  • Modifications to the preprocessing step to test if normalising data would improve model accuracy.

Technical Details

  • Results did not improve

Testing Instructions

  • If to be used, modify the preprocessing script by writing the additional normalising step (see implementation in cells ## MIN-MAX SCALER, ## STANDARD SCALER, ## ROBUST SCALER)

Screenshots

  • No

Summary by CodeRabbit

  • Documentation
    • Added a new section in the README discussing testing of data normalization techniques.
    • Provided insights into the impact of various normalization methods on model accuracy, complementing existing data visualizations.

Tested performance with 3 training data normalisation approaches: min max scaling, standard scaling, robust scaling. Results showed no improvement with any of these approaches.
@eve-b612 eve-b612 requested a review from a team as a code owner October 9, 2024 15:38
Copy link
Member

@jo-elimu jo-elimu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested performance with 3 training data normalisation approaches: min max scaling, standard scaling, robust scaling. Results showed no improvement with any of these approaches.

@eve-b612 Your commit contains 20,457 new lines, so I'm not sure where to look. Would you mind pointing me to the line number where you did the 3 tests?

@jo-elimu
Copy link
Member

jo-elimu commented Oct 9, 2024

I think I found it now. It's this part, is that correct?:

 {
      "cell_type": "code",
      "source": [
        "## MIN MAX SCALER\n",
        "\n",
        "with open(\"step1_2_preprocess_data.py\", \"r\") as file:\n",
        "    data = file.readlines()\n",
        "\n",
        "# insert min-max Scaler after unnecessary columns are dropped\n",
        "for i, line in enumerate(data):\n",
        "    if \"storybooks_dataframe = storybooks_dataframe[['id', 'reading_level',\" in line:\n",
        "        data.insert(i + 1, \"\"\"\n",
        "from sklearn.preprocessing import MinMaxScaler\n",
        "scaler = MinMaxScaler()\n",
        "storybooks_dataframe[['chapter_count', 'paragraph_count', 'word_count', 'avg_word_length']] = scaler.fit_transform(\n",
        "    storybooks_dataframe[['chapter_count', 'paragraph_count', 'word_count', 'avg_word_length']])\n",
        "print(storybooks_dataframe[['chapter_count', 'paragraph_count', 'word_count', 'avg_word_length']].head())\n",
        "\n",
        "\"\"\")\n",
        "\n",
        "# write to file\n",
        "with open(\"step1_2_preprocess_data.py\", \"w\") as file:\n",
        "    file.writelines(data)\n"
      ],
      "metadata": {
        "id": "wnqmawHJQoGq"
      },
      "execution_count": 26,
      "outputs": []
    }

@eve-b612
Copy link
Author

eve-b612 commented Oct 9, 2024

Yes! So sorry, I'm new to this I should have specified. It's line 5205 for min-max, line 10282 for standard scaler and 15382 for robust scaler. I think it's so long because the notebook outputs are there... I would appreciate any feedback on this approach. Clear outputs? Submit changes in a different format than notebooks? Thanks :)

@jo-elimu
Copy link
Member

jo-elimu commented Oct 9, 2024

I would appreciate any feedback on this approach. Clear outputs? Submit changes in a different format than notebooks? Thanks :)

@eve-b612 Well, if you want to be able to easily see how your code changes affected the data further down in the machine learning pipeline, it would probably be easier to add your changes to a Python script instead of a Jupyter notebook. (For example by adding your code changes to step1_2_preprocess_data.py.) Because then you can make your changes, and then run the whole pipeline with python run_all_steps.py. Then, if that triggered any changes, you can easily see the resulting diffs in Git.

@eve-b612
Copy link
Author

eve-b612 commented Oct 9, 2024

Ok I see, would you like me to do that? You mentioned that if normalisation did not improve the results then you wouldn't include it, and it in fact did not improve.

@jo-elimu
Copy link
Member

jo-elimu commented Oct 9, 2024

Ok I see, would you like me to do that? You mentioned that if normalisation did not improve the results then you wouldn't include it, and it in fact did not improve.

@eve-b612 If the normalization didn't improve the accuracy, then no need to add any more code 👍

But maybe you could add a few words about the experiments you did at the bottom of the README just so that we have a record of it?

Thank you for running the tests! 🙂

Added description of normalisation experiment, did not improve model accuracy.
@eve-b612
Copy link
Author

eve-b612 commented Oct 9, 2024

No problem! I've just updated the step1_prepare read me file.

Copy link

coderabbitai bot commented Oct 9, 2024

Walkthrough

The changes in the pmml/step1_prepare/README.md file introduce a new section that discusses the testing of various data normalization techniques. Specifically, it covers min-max scaling, standard scaling (z-score), and robust scaling. The results indicate that these normalization methods did not enhance model accuracy. This addition complements existing visualizations related to text data metrics by providing insights into the preprocessing steps undertaken during model training.

Changes

File Path Change Summary
pmml/step1_prepare/README.md Added a section on testing data normalization techniques (min-max, standard, robust scaling) and findings on model accuracy.

Assessment against linked issues

Objective Addressed Explanation
Normalize training data (#28)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
pmml/step1_prepare/README.md (1)

26-28: Approve the new section with suggestions for improvement

The addition of this section on data normalization testing is valuable and aligns well with the PR objectives. It provides a clear summary of the experiments conducted and their results. However, there are a few suggestions to enhance its clarity and usefulness:

  1. Consider improving the formatting for better readability. For example:
## Testing Data Normalization

Three variations of training data normalization were tested to improve model accuracy:
- Min-max scaling
- Standard scaling (z-score)
- Robust scaling

Findings: The model results did not improve with these normalization techniques.
  1. It would be beneficial to add more details about the implementation, such as:

    • Brief descriptions of each normalization technique
    • The specific metrics used to evaluate model accuracy
    • Any notable observations during the testing process
  2. Include references to the specific code or notebooks where these tests were performed. This will help future contributors understand the exact implementation and potentially reproduce the results.

Would you like assistance in expanding this section with the suggested improvements?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c575bef and b05debb.

📒 Files selected for processing (1)
  • pmml/step1_prepare/README.md (1 hunks)
🧰 Additional context used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Normalize training data
2 participants