Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -58,102 +58,41 @@ def classify_text(text):
|
|
| 58 |
|
| 59 |
return output
|
| 60 |
|
| 61 |
-
# Example questions -
|
| 62 |
-
#
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
["
|
| 68 |
-
["
|
| 69 |
-
["
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
["Which party
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
["Trust in country's parliament"],
|
| 74 |
-
["How satisfied are you with the
|
| 75 |
-
["How
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
["
|
| 79 |
-
["
|
| 80 |
-
["
|
| 81 |
-
|
| 82 |
-
# LABOUR AND EMPLOYMENT
|
| 83 |
-
["What best describes what you have been doing for the last 7 days - in paid work?"],
|
| 84 |
-
["Which description best describes the sort of work your mother did when you were 14?"],
|
| 85 |
-
["How many hours do you normally work per week in your main job?"],
|
| 86 |
-
["Are you a member of a trade union or similar organization?"],
|
| 87 |
-
|
| 88 |
-
# SOCIETY AND CULTURE
|
| 89 |
-
["How often do you pray apart from at religious services?"],
|
| 90 |
-
["How important is it to always behave properly and avoid doing anything people would say is wrong?"],
|
| 91 |
-
["Do you consider yourself as belonging to any particular religion or denomination?"],
|
| 92 |
-
|
| 93 |
-
# DEMOGRAPHY (POPULATION, VITAL STATISTICS, AND CENSUSES)
|
| 94 |
-
["What is your age?"],
|
| 95 |
-
["What is your gender?"],
|
| 96 |
-
["What is your current legal marital status?"],
|
| 97 |
-
["In which country were you born?"],
|
| 98 |
-
|
| 99 |
-
# ECONOMICS
|
| 100 |
-
["Which of the descriptions on this card comes closest to how you feel about your household's income nowadays?"],
|
| 101 |
-
["What is your household's total net income from all sources?"],
|
| 102 |
-
|
| 103 |
-
# PSYCHOLOGY
|
| 104 |
-
["Taking all things together, how happy would you say you are?"],
|
| 105 |
-
["Have you felt depressed or sad in the last two weeks?"],
|
| 106 |
-
["How often do you feel stressed?"],
|
| 107 |
-
|
| 108 |
-
# NATURAL ENVIRONMENT
|
| 109 |
-
["How worried are you about climate change?"],
|
| 110 |
-
["To what extent do you think climate change is caused by human activity?"],
|
| 111 |
-
|
| 112 |
-
# LAW, CRIME AND LEGAL SYSTEMS
|
| 113 |
-
["How safe do you feel walking alone at night in your local area?"],
|
| 114 |
-
["Have you or a member of your household been a victim of burglary or assault in the last 5 years?"],
|
| 115 |
-
|
| 116 |
-
# MEDIA, COMMUNICATION AND LANGUAGE
|
| 117 |
-
["How much time do you spend watching television on an average weekday?"],
|
| 118 |
-
["How often do you use the internet for news?"],
|
| 119 |
-
|
| 120 |
-
# SOCIAL STRATIFICATION AND GROUPINGS
|
| 121 |
-
["In society there are groups which tend to be towards the top and groups which tend to be towards the bottom. Where would you place yourself?"],
|
| 122 |
-
["Do you belong to any discriminated group in this country?"],
|
| 123 |
-
|
| 124 |
-
# HOUSING AND LAND USE
|
| 125 |
-
["Do you rent or own your accommodation?"],
|
| 126 |
-
["How many rooms do you have for your household's use only?"],
|
| 127 |
-
|
| 128 |
-
# SOCIAL WELFARE POLICY AND SYSTEMS
|
| 129 |
-
["Should the government reduce income differences?"],
|
| 130 |
-
["How satisfied are you with the state of social benefits in your country?"],
|
| 131 |
-
|
| 132 |
-
# TRANSPORT AND TRAVEL
|
| 133 |
-
["How long does your daily commute to work take?"],
|
| 134 |
-
["What is your main mode of transportation?"],
|
| 135 |
-
|
| 136 |
-
# SCIENCE AND TECHNOLOGY
|
| 137 |
-
["To what extent do you think scientific advances benefit society?"],
|
| 138 |
-
["How often do you use a smartphone or tablet?"],
|
| 139 |
-
|
| 140 |
-
# HISTORY
|
| 141 |
-
["What do you think about your country's colonial past?"],
|
| 142 |
-
["How important is it to preserve historical monuments?"],
|
| 143 |
-
|
| 144 |
-
# TRADE, INDUSTRY AND MARKETS
|
| 145 |
-
["Do you work in the private or public sector?"],
|
| 146 |
-
["How do you feel about free trade agreements?"],
|
| 147 |
-
|
| 148 |
-
# OTHER
|
| 149 |
-
["What are your thoughts on the future?"],
|
| 150 |
-
["How do you define quality of life?"],
|
| 151 |
]
|
| 152 |
|
| 153 |
-
# Shuffle and select 30 examples
|
| 154 |
-
random.seed(42) # For reproducibility
|
| 155 |
-
examples = random.sample(all_examples, min(30, len(all_examples)))
|
| 156 |
-
|
| 157 |
# Custom CSS for Sikt branding using design tokens
|
| 158 |
custom_css = """
|
| 159 |
:root {
|
|
@@ -277,6 +216,18 @@ demo = gr.Interface(
|
|
| 277 |
Automatically classify European Social Survey (ESS) questions into <strong>19 subject categories</strong>.
|
| 278 |
This AI model is fine-tuned from XLM-RoBERTa-Base and achieves <strong>83.8% accuracy</strong>.
|
| 279 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
</div>
|
| 281 |
""",
|
| 282 |
examples=examples,
|
|
|
|
| 58 |
|
| 59 |
return output
|
| 60 |
|
| 61 |
+
# Example questions - REAL questions from training data (metadata_classified.csv)
|
| 62 |
+
# Randomly selected from actual ESS variables
|
| 63 |
+
examples = [
|
| 64 |
+
["How likely, governments in enough countries take action to reduce climate change"],
|
| 65 |
+
["Country"],
|
| 66 |
+
["Age of respondent, calculated"],
|
| 67 |
+
["Partner, control paid work last 7 days"],
|
| 68 |
+
["Ninth person in household: relationship to respondent"],
|
| 69 |
+
["Year of birth of eighth person in household"],
|
| 70 |
+
["Partner's age when completed full time education"],
|
| 71 |
+
["Religion or denomination belonging to in the past"],
|
| 72 |
+
["Which party feel closer to"],
|
| 73 |
+
["Highest level of education"],
|
| 74 |
+
["Ever unemployed and seeking work for a period more than three months"],
|
| 75 |
+
["Religion or denomination belonging to at present"],
|
| 76 |
+
["Partner doing last 7 days: housework, looking after children, others"],
|
| 77 |
+
["Year of birth of sixth person in household"],
|
| 78 |
+
["I like to be a leader, to what extent"],
|
| 79 |
+
["Main activity, last 7 days"],
|
| 80 |
+
["Mother's highest level of education"],
|
| 81 |
+
["Main activity last 7 days"],
|
| 82 |
+
["Doing last 7 days: unemployed, not actively looking for job"],
|
| 83 |
+
["How feminine respondent feels"],
|
| 84 |
+
["Father's highest level of education"],
|
| 85 |
["Trust in country's parliament"],
|
| 86 |
+
["How satisfied are you with the state of education"],
|
| 87 |
+
["How important to get respect from others"],
|
| 88 |
+
["Important to show abilities and be admired"],
|
| 89 |
+
["How often socially meet with friends, relatives or colleagues"],
|
| 90 |
+
["Placement on left right scale"],
|
| 91 |
+
["How often pray apart from at religious services"],
|
| 92 |
+
["Important to help people and care for others well-being"],
|
| 93 |
+
["Subjective general health"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
]
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
# Custom CSS for Sikt branding using design tokens
|
| 97 |
custom_css = """
|
| 98 |
:root {
|
|
|
|
| 216 |
Automatically classify European Social Survey (ESS) questions into <strong>19 subject categories</strong>.
|
| 217 |
This AI model is fine-tuned from XLM-RoBERTa-Base and achieves <strong>83.8% accuracy</strong>.
|
| 218 |
</p>
|
| 219 |
+
|
| 220 |
+
<div style="background: linear-gradient(135deg, #fff4e6 0%, #ffe8cc 100%); padding: 1rem; border-radius: 6px; margin-top: 1rem; border-left: 4px solid #ff9500;">
|
| 221 |
+
<p style="margin: 0; color: #8b5a00; font-weight: 600; font-size: 0.95rem;">
|
| 222 |
+
⚠️ <strong>Prototype Notice</strong>
|
| 223 |
+
</p>
|
| 224 |
+
<p style="margin: 0.5rem 0 0 0; color: #8b5a00; font-size: 0.9rem; line-height: 1.5;">
|
| 225 |
+
This is a <strong>prototype model</strong> trained on <strong>582 samples</strong>.
|
| 226 |
+
Only <strong>8 categories</strong> have sufficient training data (≥20 samples) and can be considered reliable:
|
| 227 |
+
<strong>Education, Politics, Society and Culture, Demography, Labour and Employment, Health, Psychology, and Other</strong>.
|
| 228 |
+
Results for remaining categories should be interpreted with caution.
|
| 229 |
+
</p>
|
| 230 |
+
</div>
|
| 231 |
</div>
|
| 232 |
""",
|
| 233 |
examples=examples,
|