Spaces:
Sleeping
Sleeping
# import pandas as pd | |
# from sklearn.model_selection import train_test_split | |
# from sklearn.linear_model import LogisticRegression | |
# from sklearn.metrics import accuracy_score, classification_report | |
# import numpy as np | |
# import os | |
# import sys | |
# src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "src")) | |
# sys.path.append(src_directory) | |
# from data import sample_data | |
# from modules import encoding_model | |
# file_path = r"src/data/sms_process_data_main.xlsx" | |
# df = sample_data.get_data_frame(file_path) | |
# def get_label(message): | |
# from sentence_transformers import SentenceTransformer | |
# # model = SentenceTransformer('Alibaba-NLP/gte-base-en-v1.5', trust_remote_code=True) | |
# X_train, X_test, y_train, y_test = train_test_split(df['MessageText'], df['label'], test_size=0.2, random_state=42) | |
# X_train_embeddings = encoding_model.model.encode(X_train.tolist()) | |
# models = LogisticRegression(max_iter=100) | |
# models.fit(X_train_embeddings, y_train) | |
# new_embeddings = encoding_model.model.encode(message) | |
# no_of_dimention = len(new_embeddings) | |
# array = np.array(new_embeddings).tolist() | |
# # new_predictions = models.predict(new_embeddings) | |
# dimention = pd.DataFrame(array,columns=["Dimention"]) | |
# return {"Prediction_Dimention":{no_of_dimention: dimention}} | |
# def create_embending(message:str): | |
# embending_message = encoding_model.model.encode(message) | |
# result = np.array(embending_message).tolist() | |
# return result | |