File size: 2,417 Bytes
b3005f8
fc8e190
 
 
b3005f8
7234ab5
d8d58f7
 
fc8e190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8d58f7
385b1f2
d8d58f7
 
 
 
 
69d27e7
d8d58f7
 
 
 
 
 
 
385b1f2
d8d58f7
 
 
 
80fa379
0d996ad
d8d58f7
 
 
 
 
fc8e190
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import streamlit as st
import spacy
import pickle
import subprocess

# Page title
st.set_page_config(page_title="Chris Capobianco's Profile", page_icon=':rocket:', layout='wide')

home = st.Page('Home.py', title = 'Home', default = True)

# Function to Load the Spacy tokenizer
@st.cache_resource
def load_nlp():
    subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
    return spacy.load('en_core_web_sm')

def tokenizer(sentence):
    # Process the text
    doc = nlp(sentence)

    # Convert tokens to lemma form for all except '-PRON-'
    # Recall: Tokens like 'I', 'my', 'me' are represented as '-PRON-' by lemma attribute (See SpaCy Introduction) 
    tokens = [ token.lemma_.lower().strip() if token.lemma_ != "-PRON-" else token.lower_ for token in doc ]

    # Remove stop words and punctuations
    tokens = [ token for token in tokens if token not in stopwords and token not in punctuations ]
    
    return tokens

# Function to Load the model
@st.cache_resource
def load_tokenizer_model():
    with open('./models/autoclassifier.pkl', 'rb') as model_file:
        stopwords = pickle.load(model_file)
        punctuations = pickle.load(model_file)
        model_pipe = pickle.load(model_file)
    return (stopwords, punctuations, model_pipe)

document_classification = st.Page('projects/01_Document_Classifier.py', title='Document Classifier')
movie_recommendation = st.Page('projects/02_Movie_Recommendation.py', title='Movie Recommendation')
# weather_classification = st.Page('projects/04_Weather_Classification.py', title='Weather Classification')
stock_market = st.Page('projects/05_Stock_Market.py', title='Stock Market Forecast')
generative_music = st.Page('projects/06_Generative_Music.py', title='Generative Music')
llm_fine_tune = st.Page('projects/07_LLM_Fine_Tuned.py', title='Fine Tuned LLM')
urban_safety_planner = st.Page('projects/08_Urban_Safety_Planner.py', title='Urban Safety Planner')

pg = st.navigation(
    {
        'Home': [
            home
        ],
        'Projects': [
            document_classification,
            movie_recommendation,
            # weather_classification,
            stock_market,
            generative_music,
            llm_fine_tune,
            urban_safety_planner
        ]
    }
)
    
pg.run()

# Load the Spacy tokenizer
nlp = load_nlp()

# Load the Model
stopwords, punctuations, model_pipe = load_tokenizer_model()