AnalyticsVidhya / app.py
BobyMaurya455's picture
update1 app.py
4b9a0b8 verified
import streamlit as st
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer
# Course data
course_data = [
{'title': 'Framework to Choose the Right LLM for your Business', 'description': 'This course teaches you how to evaluate and select the right large language model (LLM) for your business needs. Learn key factors like model performance, training resources, and business use-case alignment.'},
{'title': 'Improving Real World RAG Systems: Key Challenges & Practical Solutions', 'description': 'Dive deep into the key challenges faced by Retrieval-Augmented Generation (RAG) systems in real-world applications. This course presents practical solutions to improve the performance of these systems.'},
{'title': 'Building Smarter LLMs with Mamba and State Space Model', 'description': 'Master Mamba\'s selective state space model for LLMs. Discover key components like the Mamba block, optimizing sequence modeling with efficient, scalable training and inference, surpassing traditional Transformers.'},
{'title': 'Generative AI - A Way of Life', 'description': 'Understand how Generative AI is transforming industries and applications across various sectors. This free course explores the practical uses and impact of Generative AI models in day-to-day life.'},
{'title': 'Getting Started with Large Language Models', 'description': 'Learn how large language models (LLMs) work and get started building applications using pre-trained models like GPT. This course offers a foundational understanding and practical exercises.'},
{'title': 'Building LLM Applications using Prompt Engineering', 'description': 'This free course focuses on prompt engineering for building efficient applications with large language models. Gain hands-on experience in optimizing prompts for better performance.'},
{'title': 'MidJourney: From Inspiration to Implementation', 'description': 'Explore how MidJourney works and learn how to convert inspiration into functional projects. This free course covers key concepts for building with MidJourney.'},
{'title': 'Building Your First RAG System using LlamaIndex - Free Course', 'description': 'This hands-on course walks you through the creation of your first RAG (Retrieval-Augmented Generation) system using LlamaIndex. Learn how to use LlamaIndex for effective data retrieval and generation tasks.'},
{'title': 'Exploring Stability.AI', 'description': 'Learn about Stability.AI\'s tools and technologies that are driving innovation in generative models. This free course offers an introduction to Stability.AI\'s offerings and applications.'},
{'title': 'Introduction to AI & ML', 'description': 'Artificial Intelligence (AI) and Machine Learning (ML) are changing the world around us. From functions to industries, AI and ML are disrupting how we work and how we function. Get to know all about the different facets of AI and ML in this course.'},
{'title': 'Introduction to Python', 'description': 'Learn the fundamentals of Python programming in this introductory course. From variables to loops and functions, gain the foundational knowledge you need to start coding in Python.'},
{'title': 'Machine Learning Certification Course for Beginners', 'description': 'In this free machine learning certification course, you will learn Python, the basics of machine learning, how to build machine learning models, and feature engineering techniques to improve the performance of your machine learning models.'},
{'title': 'The Working of Neural Networks', 'description': 'Dive into the mechanics of neural networks and understand how they work. This free course covers topics like activation functions, layers, and optimization techniques.'},
{'title': 'Understanding Linear Regression', 'description': 'Learn how linear regression works, from theory to implementation. This free course will help you build your own linear regression model using Python and understand its real-world applications.'},
{'title': 'Building a Text Classification Model with Natural Language Processing', 'description': 'This free course teaches you how to build a text classification model using Natural Language Processing (NLP). You’ll learn how to preprocess text, train models, and evaluate their performance.'},
{'title': 'The A to Z of Unsupervised ML', 'description': 'Explore unsupervised machine learning techniques in this comprehensive course. Learn about clustering, dimensionality reduction, and anomaly detection without relying on labeled data.'},
{'title': 'Bagging and Boosting ML Algorithms', 'description': 'Understand two powerful ensemble learning techniques: Bagging and Boosting. Learn how they combine weak learners to build strong models and improve accuracy.'},
{'title': 'Data Preprocessing on a Real-World Problem Statement', 'description': 'This free course teaches you how to preprocess real-world data to prepare it for machine learning models. Learn key techniques like handling missing values, encoding categorical variables, and scaling features.'},
{'title': 'Introduction to Business Analytics', 'description': 'This course provides an Introduction to the Certified Business Analytics Program, including courses on Excel, SQL, Tableau, Python, and more. Get a roadmap to becoming a business analytics expert.'},
{'title': 'Microsoft Excel: Formulas & Functions', 'description': 'Microsoft Excel is still the tool of choice in the industry when it comes to performing data analysis, thanks to its incredible depth and array of formulas and functions. This course covers a wide range of Excel formulas, including LookUp Functions!'},
{'title': 'Tableau for Beginners', 'description': 'Tableau is the tool of choice for business intelligence, analytics, and data visualization experts. Learn how to use Tableau, the different features of Tableau, and start building impactful visualizations using this Tableau tutorial!'},
{'title': 'Loan Prediction Practice Problem (Using Python)', 'description': 'This course is aimed for people getting started into Data Science and Machine Learning while working on a real-life practical problem. Learn how to build a machine learning model to predict loan approval.'},
{'title': 'Twitter Sentiment Analysis', 'description': 'What is sentiment analysis? Why is sentiment analysis so popular in data science? And how can you perform sentiment analysis? Find the answers to all these questions in this free course on Sentiment Analysis using Python!'},
{'title': 'Big Mart Sales Prediction Using R', 'description': 'This course is aimed at people getting started in Data Science and Machine Learning while solving the Big Mart Sales Prediction problem using R. Learn how to analyze sales data and build predictive models.'},
{'title': 'Time Series Forecasting using Python', 'description': 'Learn the techniques for time series forecasting using Python. This course covers essential concepts such as trend analysis, seasonal decomposition, and ARIMA models for accurate forecasting.'}
]
# Initialize the model and FAISS index (similar to what we did earlier)
model = SentenceTransformer('all-MiniLM-L6-v2')
# Create a list of course descriptions and generate embeddings
course_descriptions = [course['description'] for course in course_data]
embeddings = model.encode(course_descriptions, convert_to_tensor=True)
# Initialize FAISS index
embedding_matrix = embeddings.cpu().detach().numpy()
index = faiss.IndexFlatL2(embedding_matrix.shape[1]) # L2 distance index
index.add(embedding_matrix)
# Function to search courses based on user query
def search_courses(query, top_k=3):
query_embedding = model.encode([query], convert_to_tensor=True).cpu().detach().numpy()
D, I = index.search(query_embedding, top_k)
results = []
for idx in I[0]: # I[0] contains the indices of the most similar courses
course = course_data[idx]
results.append({
'title': course['title'],
'description': course['description'],
})
return results
# Streamlit UI
st.set_page_config(page_title="Smart Search for Free Courses", page_icon=":book:", layout="wide")
# Title and Description
st.title("🔍 Smart Course Search")
st.markdown("""
Welcome to **Vidhya Analytics**!
Here, you can find a curated list of free courses to help you advance your knowledge in fields like Machine Learning, AI, Business Analytics, and more.
**How It Works:**
- Enter a keyword or phrase related to your interest (e.g., 'data science', 'Python', 'AI').
- We will display the most relevant courses based on your search.
""")
# User input
query = st.text_input("Search for a course", placeholder="e.g., Machine Learning, Python, Data Science...")
if query:
st.subheader(f"Search Results for: '{query}'")
results = search_courses(query)
if results:
for idx, result in enumerate(results, 1):
st.markdown(f"### Result {idx}: {result['title']}")
st.write(f"**Description:** {result['description']}")
st.write("-" * 80)
else:
st.write("No results found! Please try a different query.")