Spaces:
Sleeping
Sleeping
spdin
commited on
Commit
·
f0ad92c
1
Parent(s):
5e51c52
add csv file
Browse files- data/news.csv +12 -0
- data/sample.csv +21 -0
- data/spam.csv +15 -0
- prediction.py +1 -1
- training.py +9 -2
- utils.py +11 -0
- validation.py +1 -1
data/news.csv
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"text","label"
|
2 |
+
"worldcom ex-boss launches defence lawyers defending former worldcom chief bernie ebbers against a battery of fraud charges have called a company whistleblower as their first witness. cynthia cooper worldcom s ex-head of internal accounting alerted directors to irregular accounting practices at the us telecoms giant in 2002. her warnings led to the collapse of the firm following the discovery of an $11bn (£5.7bn) accounting fraud. mr ebbers has pleaded not guilty to charges of fraud and conspiracy. prosecution lawyers have argued that mr ebbers orchestrated a series of accounting tricks at worldcom ordering employees to hide expenses and inflate revenues to meet wall street earnings estimates. but ms cooper who now runs her own consulting business told a jury in new york on wednesday that external auditors arthur andersen had approved worldcom s accounting in early 2001 and 2002. she said andersen had given a green light to the procedures and practices used by worldcom. mr ebber s lawyers have said he was unaware of the fraud arguing that auditors did not alert him to any problems. ms cooper also said that during shareholder meetings mr ebbers often passed over technical questions to the company s finance chief giving only brief answers himself. the prosecution s star witness former worldcom financial chief scott sullivan has said that mr ebbers ordered accounting adjustments at the firm telling him to hit our books . however ms cooper said mr sullivan had not mentioned anything uncomfortable about worldcom s accounting during a 2001 audit committee meeting. mr ebbers could face a jail sentence of 85 years if convicted of all the charges he is facing. worldcom emerged from bankruptcy protection in 2004 and is now known as mci. last week mci agreed to a buyout by verizon communications in a deal valued at $6.75bn.","business"
|
3 |
+
"german business confidence slides german business confidence fell in february knocking hopes of a speedy recovery in europe s largest economy. munich-based research institute ifo said that its confidence index fell to 95.5 in february from 97.5 in january its first decline in three months. the study found that the outlook in both the manufacturing and retail sectors had worsened. observers had been hoping that a more confident business sector would signal that economic activity was picking up. we re surprised that the ifo index has taken such a knock said dz bank economist bernd weidensteiner. the main reason is probably that the domestic economy is still weak particularly in the retail trade. economy and labour minister wolfgang clement called the dip in february s ifo confidence figure a very mild decline . he said that despite the retreat the index remained at a relatively high level and that he expected a modest economic upswing to continue. germany s economy grew 1.6% last year after shrinking in 2003. however the economy contracted by 0.2% during the last three months of 2004 mainly due to the reluctance of consumers to spend. latest indications are that growth is still proving elusive and ifo president hans-werner sinn said any improvement in german domestic demand was sluggish. exports had kept things going during the first half of 2004 but demand for exports was then hit as the value of the euro hit record levels making german products less competitive overseas. on top of that the unemployment rate has been stuck at close to 10% and manufacturing firms including daimlerchrysler siemens and volkswagen have been negotiating with unions over cost cutting measures. analysts said that the ifo figures and germany s continuing problems may delay an interest rate rise by the european central bank. eurozone interest rates are at 2% but comments from senior officials have recently focused on the threat of inflation prompting fears that interest rates may rise.","business"
|
4 |
+
"bbc poll indicates economic gloom citizens in a majority of nations surveyed in a bbc world service poll believe the world economy is worsening. most respondents also said their national economy was getting worse. but when asked about their own family s financial outlook a majority in 14 countries said they were positive about the future. almost 23 000 people in 22 countries were questioned for the poll which was mostly conducted before the asian tsunami disaster. the poll found that a majority or plurality of people in 13 countries believed the economy was going downhill compared with respondents in nine countries who believed it was improving. those surveyed in three countries were split. in percentage terms an average of 44% of respondents in each country said the world economy was getting worse compared to 34% who said it was improving. similarly 48% were pessimistic about their national economy while 41% were optimistic. and 47% saw their family s economic conditions improving as against 36% who said they were getting worse. the poll of 22 953 people was conducted by the international polling firm globescan together with the program on international policy attitudes (pipa) at the university of maryland. while the world economy has picked up from difficult times just a few years ago people seem to not have fully absorbed this development though they are personally experiencing its effects said pipa director steven kull. people around the world are saying: i m ok but the world isn t . there may be a perception that war terrorism and religious and political divisions are making the world a worse place even though that has not so far been reflected in global economic performance says the bbc s elizabeth blunt. the countries where people were most optimistic both for the world and for their own families were two fast-growing developing economies china and india followed by indonesia. china has seen two decades of blistering economic growth which has led to wealth creation on a huge scale says the bbc s louisa lim in beijing. but the results also may reflect the untrammelled confidence of people who are subject to endless government propaganda about their country s rosy economic future our correspondent says. south korea was the most pessimistic while respondents in italy and mexico were also quite gloomy. the bbc s david willey in rome says one reason for that result is the changeover from the lira to the euro in 2001 which is widely viewed as the biggest reason why their wages and salaries are worth less than they used to be. the philippines was among the most upbeat countries on prospects for respondents families but one of the most pessimistic about the world economy. pipa conducted the poll from 15 november 2004 to 3 january 2005 across 22 countries in face-to-face or telephone interviews. the interviews took place between 15 november 2004 and 5 january 2005. the margin of error is between 2.5 and 4 points depending on the country. in eight of the countries the sample was limited to major metropolitan areas.","business"
|
5 |
+
"lifestyle governs mobile choice faster better or funkier hardware alone is not going to help phone firms sell more handsets research suggests. instead phone firms keen to get more out of their customers should not just be pushing the technology for its own sake. consumers are far more interested in how handsets fit in with their lifestyle than they are in screen size onboard memory or the chip inside shows an in-depth study by handset maker ericsson. historically in the industry there has been too much focus on using technology said dr michael bjorn senior advisor on mobile media at ericsson s consumer and enterprise lab. we have to stop saying that these technologies will change their lives he said. we should try to speak to consumers in their own language and help them see how it fits in with what they are doing he told the bbc news website. for the study ericsson interviewed 14 000 mobile phone owners on the ways they use their phone. people s habits remain the same said dr bjorn. they just move the activity into the mobile phone as it s a much more convenient way to do it. one good example of this was diary-writing among younger people he said. while diaries have always been popular a mobile phone -- especially one equipped with a camera -- helps them keep it in a different form. youngsters use of text messages also reflects their desire to chat and keep in contact with friends and again just lets them do it in a slightly changed way. dr bjorn said that although consumers do what they always did but use a phone to do it the sheer variety of what the new handset technologies make possible does gradually drive new habits and lifestyles. ericsson s research has shown that consumers divide into different tribes that use phones in different ways. dr bjorn said groups dubbed pioneers and materialists were most interested in trying new things and were behind the start of many trends in phone use. for instance he said older people are using sms much more than they did five years ago. this was because younger users often the children of ageing mobile owners encouraged older people to try it so they could keep in touch. another factor governing the speed of change in mobile phone use was the simple speed with which new devices are bought by pioneers and materialists. only when about 25% of people have handsets with new innovations on them such as cameras can consumers stop worrying that if they send a picture message the person at the other end will be able to see it. once this significant number of users is passed use of new innovations tends to take off. dr bjorn said that early reports of camera phone usage in japan seemed to imply that the innovation was going to be a flop. however he said now 45% of the japanese people ericsson questioned use their camera phone at least once a month. in 2003 the figure was 29%. similarly across europe the numbers of people taking snaps with cameras is starting to rise. in 2003 only 4% of the people in the uk took a phonecam snap at least once a month. now the figure is 14%. similar rises have been seen in many other european nations. dr bjorn said that people also used their camera phones in very different ways to film and even digital cameras. usage patterns for digital cameras are almost exactly replacing usage patterns for analogue cameras he said. digital cameras tend to be used on significant events such as weddings holidays and birthdays. by contrast he said camera phones were being used much more to capture a moment and were being woven into everyday life.","technology"
|
6 |
+
"enron bosses in $168m payout eighteen former enron directors have agreed a $168m (£89m) settlement deal in a shareholder lawsuit over the collapse of the energy firm. leading plaintiff the university of california announced the news adding that 10 of the former directors will pay $13m from their own pockets. the settlement will be put to the courts for approval next week. enron went bankrupt in 2001 after it emerged it had hidden hundreds of millions of dollars in debt. before its collapse the firm was the seventh biggest public us company by revenue. its demise sent shockwaves through financial markets and dented investor confidence in corporate america. the settlement is very significant in holding these outside directors at least partially personally responsible william lerach the lawyer leading the class action suit against enron said. hopefully this will help send a message to corporate boardrooms of the importance of directors performing their legal duties he added. under the terms of the $168m settlement - $155m of which will be covered by insurance - none of the 18 former directors will admit any wrongdoing. the deal is the fourth major settlement negotiated by lawyers who filed a class action on behalf of enron s shareholders almost three years ago. so far including the latest deal just under $500m (£378.8m) has been retrieved for investors. however the latest deal does not include former enron chief executives ken lay and jeff skilling. both men are facing criminal charges for their alleged misconduct in the run up to the firm s collapse. neither does it cover andrew fastow who has pleaded guilty to taking part in an illegal conspiracy while he was chief financial officer at the group. enron s shareholders are still seeking damages from a long list of other big name defendants including the financial institutions jp morgan chase citigroup merrill lynch and credit suisse first boston. the university of california said the trial in the case is scheduled to begin in october 2006. it joined the lawsuit in december 2001alleging massive insider trading and fraud claiming it had lost $145m on its investments in the company.","business"
|
7 |
+
"howard truanted to play snooker conservative leader michael howard has admitted he used to play truant to spend time with his school friends at a snooker hall. mr howard said his time at jack s snooker hall in llanelli in the 1950s had not done him any lasting damage . but he told the times educational supplement that truancy was very bad and said firm action was needed. mr howard also called for a return to o-levels and more classroom discipline. mr howard eventually left llanelli grammar school - and the snooker hall - to go to cambridge university. he said: i don t think it s done me any lasting damage. nor has it made me a snooker world champion. there might have been some occasions when we left early of an afternoon. i m just being honest. i think truancy is a very bad thing and that firm action should be taken to deal with it. another player who has failed to win snooker s world championship - jimmy the whirlwind white - has previously admitted missing lessons instead spending his days in smoky halls. tony meo [another player] and me used to spend all of our spare time there mr white said we loved the game and the atmosphere. school went out of the window. i went for a while and then started taking time off. mr howard s fellow welshman ray reardon - known by his fellow professionals as dracula - won the snooker world championship six times having left school at 14 to work as a miner. and terry griffiths like mr howard from llanelli won the tournament in 1979. it is not known whether the two of them ever clashed cues at jack s.","politics"
|
8 |
+
"wales silent on grand slam talk rhys williams says wales are still not thinking of winning the grand slam despite a third six nations win. that s the last thing on our minds at the moment said williams a second- half replacement in saturday s 24-18 win over france in paris. we all realise how difficult a task it is to go up to scotland and beat them. we ve come unstuck there a couple of times recently so our focus is on that game and we ll worry about ireland hopefully after we ve beaten scotland. with captain gareth thomas ruled out of the rest of the campaign with a broken thumb williams is vying for his first start in the championship so far. kevin morgan is probably favourite to replace thomas at full-back leaving williams and hal luscombe to battle for the right wing berth. a hamstring injury denied luscombe the opportunity to make a third successive start but the dragons winger is expected to be fit for the trip to murrayfield on 13 march. hooker robin mcbryde is doubtful after picking up a knee injury in paris but centre sonny parker and flanker colin charvis are set to recover from injury to be in contention for selection. said wales assistant coach scott johnson: they ve worked through the weekend and the reports are a bit more positive. so we re getting a couple back and that adds to the depth of the squad. scotland secured their first win of the campaign on saturday by grinding out an 18-10 win over italy. matt williams side has shown little in attack but johnson insisted the scots will be difficult opposition to break down. italy are really brave opposition and sometimes it s very hard to win he said. so an ugly win can be just as effective as a 30 or 40 point victory. scotland are a hard side and very underrated so we re not taking anything for granted. we re not basking in the glory of winning our first three games. we ve got to be diligent in our preparation. that s my job and we ve got to make sure we re focused.","sport"
|
9 |
+
"french honour for director parker british film director sir alan parker has been made an officer in the order of arts and letters one of france s highest cultural honours. sir alan received his decoration in paris on wednesday from french culture minister renaud donnedieu de vabres. you have explored the possibilities of film with an immense talent mr de vabres said as he presented the award. parker praised french films saying: hollywood which created modern cinema uses it only as a commodity. he told the minister: i am honoured to be thus distinguished by france the flag carrier of cinema throughout the world. sir alan s films include oscar-winning fame plus midnight express and the commitments. a founding member of the director s guild of great britain he is a former chairman of the uk film council and on the board of the british film institute. through your work and your campaigns you have shown us how the artist occupies an essential place in our contemporary society mr de vabres said. through your dreams which you show us through the links that you weave you question the world through the mirror of your work. he also cited the director s 2003 film the life of david gale in which kevin spacey played a man on death row as proof of his veritable artistic commitment against the death sentence .","entertainment"
|
10 |
+
"car giant hit by mercedes slump a slump in profitability at luxury car maker mercedes has prompted a big drop in profits at parent daimlerchrysler. the german-us carmaker saw fourth quarter operating profits fall to 785m euros ($1bn) from 2.4bn euros in 2003. mercedes-benz s woes - its profits slid to just 20m euros - obscured a strong performance from the chrysler group whose returns met market expectations. mercedes faces fierce competition in the luxury car sector from bmw and but hopes to revive its fortunes by 2006. mercedes profits over the period compared unfavourably with 2003 s 784m euro figure and were well below analyst expectations of 374m euros. for the year as a whole its operating profits fell 46% to 1.6bn euros. sales of mercedes brands fell 2% as demand cooled while revenues were affected by the weakness of the us dollar. the carmaker blamed the fall in profits on high launch costs for new models and losses from its mercedes smart mini-car range. mercedes is hoping to increase productivity by 3bn euros having negotiated 500m euros in annual savings with german workers last year. the firm said it was determined to retain mercedes position as the world s most successful luxury brand. however daimlerchrysler s shares fell 1.5% on the news. while all these divisions are doing well the big worries continue to surround mercedes-benz michael rabb an analyst with bank sal oppenheim told reuters. in contrast chrysler enjoyed a 5% annual increase in unit sales while revenues - calculated in us dollars - rose 10%. the us division - whose marques include dodge and jeep - transformed a full year operating loss of 506m euros in 2003 into a 1.4bn euros profit last year. overall daimlerchrysler saw worldwide vehicle sales rise 8% to 4.7 million in 2004 while total revenues added 4% to 142bn euros. chrysler s strong performance helped the world s fifth largest carmaker boost net income by 400m euros to 2.5bn euros. the year 2004 shows that our strategy works well - even in such a challenging competitive environment said jurgen schrempp daimlerchrysler s chairman. daimlerchrysler took a 475m euro hit in costs stemming from a defects scandal at its joint venture japanese subsidiary fuso. daimlerchrysler last week agreed a compensation package with partner mitsubishi motors which will see it buy out its stake in fuso. looking forward daimerchrysler s profits are expected to be slightly higher in 2005. however it is expecting significant improvements in profitability in 2006 as a result of a major investment in the mercedes product range.","business"
|
11 |
+
"fockers fuel festive film chart comedy meet the fockers topped the festive box office in north america setting a new record for christmas day. the sequel took $44.7m (£23.2m) between 24 and 26 december according to studio estimates. it took $19.1m (£9.9m) on christmas day alone the highest takings on that day in box office history. meet the fockers is the sequel to ben stiller comedy meet the parents also starring robert de niro blythe danner dustin hoffman and barbra streisand. despite the success of meet the fockers takings were down 26.5% on 2003 s figures - which was blamed on christmas falling over a weekend this year. when christmas falls on a weekend it s bad for business said paul dergarabedian president of exhibitor relations which compiles box office statistics. the weekend s top 12 films took an estimated $121.9m (£63.3m) compared with $165.8m (£86.1m) last year when the third lord of the rings film dominated the box office. meet the fockers knocked last week s top film lemony snicket s a series of unfortunate events down to third place with $12.5m (£6.5m). comedy fat albert - co-written by bill cosby - entered the chart in second place after opening on christmas day taking $12.7m (£6.6m). the aviator starring leonardo dicaprio as howard hughes took $9.4m after expanding from 40 to 1 796 cinemas on christmas day.","entertainment"
|
12 |
+
|
data/sample.csv
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
text,label
|
2 |
+
"Hey, can you send me those files?",ham
|
3 |
+
"Get rich quick with this amazing offer!",spam
|
4 |
+
"Reminder: meeting tomorrow at 2 PM",ham
|
5 |
+
"URGENT: Your account has been compromised",spam
|
6 |
+
"Check out our new product line",ham
|
7 |
+
"Congratulations, you've won a prize!",spam
|
8 |
+
"Are you free for lunch today?",ham
|
9 |
+
"Lowest prices on the market, guaranteed!",spam
|
10 |
+
"New job opportunity at our company",ham
|
11 |
+
"You've been selected for a special offer!",spam
|
12 |
+
"Important update regarding your account",ham
|
13 |
+
"Get a free trial of our service today!",spam
|
14 |
+
"Can you confirm the meeting time?",ham
|
15 |
+
"Unlock the secret to instant success!",spam
|
16 |
+
"Reminder: deadline is approaching",ham
|
17 |
+
"Get exclusive access to our VIP program!",spam
|
18 |
+
"Can we reschedule the meeting to tomorrow?",ham
|
19 |
+
"Act now to take advantage of our limited time offer!",spam
|
20 |
+
"New product launch: be the first to try it!",ham
|
21 |
+
"Congratulations, you've been approved for a loan!",spam
|
data/spam.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
text,label
|
2 |
+
"From: John Doe <[email protected]>\nTo: Jane Smith <[email protected]>\nSubject: Follow-up on Meeting\n\nHi Jane,\n\nI just wanted to follow up on our meeting last week and see if you had any additional questions or concerns. As a reminder, we discussed the upcoming product launch and the marketing strategy for the next quarter. Please let me know if there's anything else you need from me.\n\nBest regards,\nJohn",ham
|
3 |
+
"From: Free Money <[email protected]>\nTo: You <[email protected]>\nSubject: Make Money Fast!\n\nAre you tired of working long hours for low pay? Do you want to make thousands of dollars from home? Our proven system can help you achieve financial freedom in no time! Just click the link below to get started.\n\nhttp://www.freemoney.com\n\nDon't miss out on this amazing opportunity!\n\nRegards,\nThe Free Money Team",spam
|
4 |
+
"From: Sarah Smith <[email protected]>\nTo: Mark Johnson <[email protected]>\nSubject: Invitation to Charity Event\n\nHi Mark,\n\nI wanted to invite you to a charity event that I'm hosting next month. We'll be raising money for a great cause and I think you'd really enjoy it. Let me know if you're interested and I'll send you more details.\n\nBest,\nSarah",ham
|
5 |
+
"From: Your Bank <[email protected]>\nTo: John Smith <[email protected]>\nSubject: Urgent Security Alert\n\nDear John,\n\nWe have detected suspicious activity on your account and need you to take immediate action. Please log in to your online banking account and follow the prompts to secure your account.\n\nIf you have any questions or concerns, please contact us immediately.\n\nSincerely,\nYour Bank",spam
|
6 |
+
"From: Michael Johnson <[email protected]>\nTo: Emily Davis <[email protected]>\nSubject: Re: Dinner Plans\n\nHi Emily,\n\nThanks for getting back to me. How about we meet at that new Italian place downtown at 7 PM on Friday? I hear it's really good. Let me know if that works for you.\n\nBest,\nMike",ham
|
7 |
+
"From: Online Pharmacy <[email protected]>\nTo: You <[email protected]>\nSubject: Discount Medications\n\nGet the medications you need at a fraction of the cost! Our online pharmacy offers the lowest prices on a wide range of prescription and over-the-counter drugs. Plus, we offer fast and discreet shipping to your doorstep.\n\nVisit us today to see our full selection and start saving!\n\nhttp://www.onlinepharmacy.com\n\nRegards,\nThe Online Pharmacy Team",spam
|
8 |
+
"From: Rachel Thompson <[email protected]>\nTo: David Brown <[email protected]>\nSubject: Re: Project Update\n\nHi David,\n\nThanks for the update. It sounds like everything is on track. Let me know if there's anything I can do to help.\n\nBest,\nRachel",ham
|
9 |
+
"From: Lottery Winner <[email protected]>\nTo: You <[email protected]>\nSubject: Congratulations, You've Won!\n\nYou are the lucky winner of our monthly lottery drawing! You have been selected to receive a cash prize of $10,000. To claim your winnings, simply click",spam
|
10 |
+
"From: John Doe <[email protected]>\nTo: Jane Smith <[email protected]>\nSubject: Follow-up on Meeting\n\nHi Jane,\n\nI just wanted to follow up on our meeting last week and see if you had any additional questions or concerns. As a reminder, we discussed the upcoming product launch and the marketing strategy for the next quarter. I think we made some good progress and I'm looking forward to seeing the results!\n\nBest regards,\nJohn",ham
|
11 |
+
"From: Savings Bank <[email protected]>\nTo: Valued Customer <[email protected]>\nSubject: IMPORTANT: Account Security Update\n\nDear Valued Customer,\n\nWe have recently detected some suspicious activity on your account and need to verify your identity to ensure that your account is secure. Please click on the link below to verify your information and update your password. Failure to do so may result in your account being temporarily suspended.\n\n[LINK]\n\nThank you for your prompt attention to this matter.\n\nSincerely,\nThe Savings Bank Team",spam
|
12 |
+
"From: Jane Smith <[email protected]>\nTo: John Doe <[email protected]>\nSubject: Re: Follow-up on Meeting\n\nHi John,\n\nThanks for following up! I don't have any additional questions at the moment, but I'll definitely keep you in mind if anything comes up. I agree that we made some good progress in the meeting and I'm excited to see the results too.\n\nBest regards,\nJane",ham
|
13 |
+
"From: PayPal <[email protected]>\nTo: You <[email protected]>\nSubject: IMPORTANT: Account Verification Required\n\nDear valued PayPal customer,\n\nWe have detected some unusual activity on your account and need to verify your identity to ensure that your account is secure. Please click on the link below to verify your information and restore full access to your account.\n\n[LINK]\n\nIf you do not take action within 24 hours, your account may be permanently suspended. Thank you for your prompt attention to this matter.\n\nSincerely,\nThe PayPal Team",spam
|
14 |
+
"From: Marketing Department <[email protected]>\nTo: All Employees <[email protected]>\nSubject: New Product Launch\n\nDear colleagues,\n\nI'm excited to announce that our new product line will be launching next month! As you know, we've been working hard on this project for several months and I'm confident that it will be a huge success. Please stay tuned for more information on the launch and how we can all work together to make it a success.\n\nBest regards,\nThe Marketing Department",ham
|
15 |
+
"From: Lottery <[email protected]>\nTo: You <[email protected]>\nSubject: Congratulations, You're a Winner!\n\nDear lucky winner,\n\nCongratulations! You have been selected as the winner of our latest lottery drawing and have won a prize of $10,000. To claim your prize, please click on the link below and follow the instructions.\n\n[LINK]\n\nThank you for participating in our lottery and we hope you enjoy your prize!\n\nSincerely,\nThe Lottery Team",spam
|
prediction.py
CHANGED
@@ -8,7 +8,7 @@ import model
|
|
8 |
def main():
|
9 |
st.title("Model Prediction")
|
10 |
|
11 |
-
st.write(f"Session ID: {st.session_state.key}")
|
12 |
session_id = st.session_state.key
|
13 |
|
14 |
if not os.path.isdir(f"models/{session_id}"):
|
|
|
8 |
def main():
|
9 |
st.title("Model Prediction")
|
10 |
|
11 |
+
# st.write(f"Session ID: {st.session_state.key}")
|
12 |
session_id = st.session_state.key
|
13 |
|
14 |
if not os.path.isdir(f"models/{session_id}"):
|
training.py
CHANGED
@@ -5,15 +5,22 @@ import streamlit as st
|
|
5 |
from datasets import Dataset
|
6 |
|
7 |
import model
|
8 |
-
from utils import check_columns, count_labels
|
9 |
|
10 |
# Main function to run the Streamlit app
|
11 |
def main():
|
12 |
# Set app title
|
13 |
st.title("Few Shot Learning Demo using SetFit")
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Display the session ID
|
16 |
-
st.write(f"Session ID: {st.session_state.key}")
|
17 |
session_id = st.session_state.key
|
18 |
|
19 |
# Create file uploader
|
|
|
5 |
from datasets import Dataset
|
6 |
|
7 |
import model
|
8 |
+
from utils import check_columns, count_labels, get_download_link
|
9 |
|
10 |
# Main function to run the Streamlit app
|
11 |
def main():
|
12 |
# Set app title
|
13 |
st.title("Few Shot Learning Demo using SetFit")
|
14 |
|
15 |
+
st.write("Prepare CSV file with text and label header, here is the sample file")
|
16 |
+
|
17 |
+
df = pd.read_csv("data/sample.csv")
|
18 |
+
|
19 |
+
# Display a link to download the file
|
20 |
+
st.markdown(get_download_link(df), unsafe_allow_html=True)
|
21 |
+
|
22 |
# Display the session ID
|
23 |
+
# st.write(f"Session ID: {st.session_state.key}")
|
24 |
session_id = st.session_state.key
|
25 |
|
26 |
# Create file uploader
|
utils.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
# Function to check if the uploaded file has the expected columns
|
2 |
def check_columns(df):
|
3 |
if set(df.columns) == set(["text", "label"]):
|
@@ -10,3 +13,11 @@ def check_columns(df):
|
|
10 |
def count_labels(df):
|
11 |
counts = df["label"].value_counts()
|
12 |
return counts.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import base64
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
# Function to check if the uploaded file has the expected columns
|
5 |
def check_columns(df):
|
6 |
if set(df.columns) == set(["text", "label"]):
|
|
|
13 |
def count_labels(df):
|
14 |
counts = df["label"].value_counts()
|
15 |
return counts.to_dict()
|
16 |
+
|
17 |
+
|
18 |
+
def get_download_link(df):
|
19 |
+
"""Generates a link allowing the data in a pandas dataframe to be downloaded"""
|
20 |
+
csv = df.to_csv(index=False)
|
21 |
+
b64 = base64.b64encode(csv.encode()).decode() # encoding the data
|
22 |
+
href = f'<a href="data:file/csv;base64,{b64}" download="sample.csv">Download CSV file (sample)</a>'
|
23 |
+
return href
|
validation.py
CHANGED
@@ -14,7 +14,7 @@ def main():
|
|
14 |
st.title("Model Validation")
|
15 |
|
16 |
# Display the session ID
|
17 |
-
st.write(f"Session ID: {st.session_state.key}")
|
18 |
session_id = st.session_state.key
|
19 |
|
20 |
if not os.path.isdir(f"models/{session_id}"):
|
|
|
14 |
st.title("Model Validation")
|
15 |
|
16 |
# Display the session ID
|
17 |
+
# st.write(f"Session ID: {st.session_state.key}")
|
18 |
session_id = st.session_state.key
|
19 |
|
20 |
if not os.path.isdir(f"models/{session_id}"):
|