gutai123 commited on
Commit
bac31f6
·
verified ·
1 Parent(s): e601e97

Update admin_utils.py

Browse files
Files changed (1) hide show
  1. admin_utils.py +27 -0
admin_utils.py CHANGED
@@ -50,3 +50,30 @@ def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,em
50
  index_name = pinecone_index_name
51
  index = Pinecone.from_documents(docs, embeddings, index_name=index_name)
52
  return index
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  index_name = pinecone_index_name
51
  index = Pinecone.from_documents(docs, embeddings, index_name=index_name)
52
  return index
53
+
54
+ def read_data(data):
55
+ df = pd.read_csv(data,delimiter=',', header=None)
56
+ return df
57
+
58
+ #Create embeddings instance
59
+ def get_embeddings():
60
+ embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
61
+ return embeddings
62
+
63
+ #Generating embeddings for our input dataset
64
+ def create_embeddings(df,embeddings):
65
+ df[2] = df[0].apply(lambda x: embeddings.embed_query(x))
66
+ return df
67
+
68
+ #Splitting the data into train & test
69
+ def split_train_test__data(df_sample):
70
+ # Split into training and testing sets
71
+ sentences_train, sentences_test, labels_train, labels_test = train_test_split(
72
+ list(df_sample[2]), list(df_sample[1]), test_size=0.25, random_state=0)
73
+ print(len(sentences_train))
74
+ return sentences_train, sentences_test, labels_train, labels_test
75
+
76
+ #Get the accuracy score on test data
77
+ def get_score(svm_classifier,sentences_test,labels_test):
78
+ score = svm_classifier.score(sentences_test, labels_test)
79
+ return score