Skip to content

configcat-labs/feature-flags-with-ml-models-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Feature Flags with Machine Learning Models

A companion repository for the blog post above. This repository contains a sample application that demonstrates how to use feature flags with machine learning models. It showcases the implementation of two text classification models using the popular machine learning library SpaCy. The models, namely the Base Model and the Pro Model, are designed to classify user-input text into specific intents based on their training data.

Key Features

  • Base Model: Designed for general text classification, covering intents such as goodbye, greeting, and business_hours.

  • Pro Model: Tailored for advanced scenarios, including additional intent classification such as payment_methods, making it ideal for scenarios where premium features are reserved for paid users.

Usage Scenario

These models are particularly useful in scenarios where you want to differentiate user access based on their subscription level. For instance, the Pro Model allows for more sophisticated intent classification, making it suitable for cases where users need information about payment methods, a capability not available in the Base Model.

Example

The Pro Model is able to classify the following user input:

"Can I pay you with my Google Pay wallet?"

resulting in classification to the payment_methods intent, a capability beyond the scope of the Base Model.

Build & Run

Prerequisites

Steps to run

  1. Clone the repository
git clone [email protected]:configcat-labs/feature-flags-with-ml-models-sample.git
  1. Create a and activate a virtual environment
python3 -m venv venv

source venv/bin/activate
  1. Install dependencies and run the app
pip3 install -r requirements.txt
python3 interact.py
  1. Train both base and pro models by entering the appropriate option in the command line. For this example, I'll train the base model first.
1 - Interact | 2 - Train | 3 - Exit: 2

Model to train: 1 - Base | 2 - Pro: 1

Training completed for base model

Train the pro model.

1 - Interact | 2 - Train | 3 - Exit: 2

Model to train: 1 - Base | 2 - Pro: 2

Training completed for pro model
  1. Now, copy your SDK key from the ConfigCat dashboard and paste it in the YOUR-CONFIGCAT-SDK-KEY placeholder in the interact.py file.

Learn more

Useful links to technical resources:

ConfigCat also supports many other frameworks and languages. Check out the full list of supported SDKs here.

You can also explore other code samples for various languages, frameworks, and topics here in the ConfigCat labs on GitHub.

Keep up with ConfigCat on Twitter, Facebook, LinkedIn, and GitHub.

Author

Chavez Harris

Contributions

Contributions are welcome!

About

A companion repo the blog article titled: Using feature flags with machine learning models

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages