File size: 5,118 Bytes
df265ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b1ee78
 
084b37d
 
d371ba4
eaa815a
084b37d
eaa815a
c7ba0ad
1f8f953
 
 
eaa815a
084b37d
eaa815a
 
 
d371ba4
 
 
0fd1750
084b37d
0fd1750
 
 
084b37d
0fd1750
57c8f02
0fd1750
084b37d
eaa815a
 
 
 
 
 
 
 
 
 
084b37d
0fd1750
 
 
084b37d
0fd1750
a336123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35a3d83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a336123
35a3d83
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
license: apache-2.0
datasets:
- ProfessorLeVesseur/EnglishTense
language:
- en
metrics:
- accuracy
- precision
- recall
- f1
base_model:
- google-bert/bert-base-uncased
pipeline_tag: text-classification
tags:
- time
- timeframe
- tense
- past
- current
- future
- chronological
evaluation_results:
  accuracy: 1.00
  macro_precision: 1.00
  macro_recall: 1.00
  macro_f1: 1.00
  weighted_precision: 1.00
  weighted_recall: 1.00
  weighted_f1: 1.00
  class_precision:
    Future: 1.00
    Past: 1.00
    Present: 1.00
  class_recall:
    Future: 1.00
    Past: 1.00
    Present: 1.00
  class_f1:
    Future: 1.00
    Past: 1.00
    Present: 1.00
  support:
    Future: 727
    Past: 577
    Present: 694
---

## Model Overview ⏳🔮🔄

This model is a **text classification model** trained to **predict the tense of English sentences**: **Past**, **Present**, or **Future**. It is based on the `bert-base-uncased` architecture.

## Intended Use 🔍

This model can be used in applications such as:
- Identifying if statements are discussing past needs, motivations, products, etc. ⏪
- Determining current events or situations in text.                                ⏺️
- Predicting future plans or intentions based on sentence structure.               ⏩

### Example Sentences and Labels 📝

| Sentence                                                                 | Label   |
|--------------------------------------------------------------------------|---------|
| the fishermen had caught a variety of fish including bass and perch      | Past |
| medical professionals are researching the impact of social determinants on health | Present |
| in the future robotic surgical systems will have been empowering surgeons to perform increasingly complex procedures | Future |

## Training Details 🏋️‍♂️

The model was fine-tuned on the `ProfessorLeVesseur/EnglishTense` dataset, which provides a diverse set of sentences labeled with their respective tenses. The training involved optimizing the model's weights for three epochs using a learning rate of 5e-5.

## Evaluation Results 📊

The model achieves a **perfect accuracy of 1.00** on the test set, with **precision**, **recall**, and **F1-scores** also at **1.00 for all classes**. These results indicate excellent performance in classifying sentence tenses.

### Classification Report ✅

| Class       | Precision | Recall | F1-Score | Support |
|-------------|-----------|--------|----------|---------|
| Future      | 1.00      | 1.00   | 1.00     | 727     |
| Past        | 1.00      | 1.00   | 1.00     | 577     |
| Present     | 1.00      | 1.00   | 1.00     | 694     |
| **Accuracy**|           |        | 1.00     | 1998    |
| **Macro Avg** | 1.00    | 1.00   | 1.00     | 1998    |
| **Weighted Avg** | 1.00 | 1.00   | 1.00     | 1998    |

### Limitations ⚠️

While the model performs well on the provided dataset, it may not generalize to all types of English text, particularly those with ambiguous or complex sentence structures.

## How to Use 🚀

This model can be used for text classification tasks, either for individual text inputs or for batch processing via a DataFrame. Below are examples of both use cases.

### Classifying Input Text

To classify a single piece of text and retrieve the predicted label along with the confidence score, you can use the following code:

```python
from transformers import pipeline  # Import the pipeline function from the transformers library

# Initialize a text classification pipeline using the specified model
classifier = pipeline(
    "text-classification",  # Specify the task type as text classification
    model="ProfessorLeVesseur/bert-base-cased-timeframe-classifier"  # Specify the model to use from the Hugging Face Model Hub
)
result = classifier("MTSS.ai is the future of education, call it education².")  # Classify the input text and store the result
print(result)  # Output the result
```

### Classifying Text in a DataFrame

For batch processing, you can classify multiple text entries stored in a DataFrame. This example demonstrates how to read a CSV file and add a new column with the predicted labels:

```python
# Import libraries
from transformers import pipeline  # Import the pipeline function from the transformers library
import pandas as pd  # Import pandas for data manipulation

# Read the CSV file
file_path = 'filename.csv'  # Define the path to the CSV file
df = pd.read_csv(file_path)  # Read the CSV file into a DataFrame

# Initialize the text classification pipeline
classifier = pipeline(
    "text-classification",  # Specify the task type as text classification
    model="ProfessorLeVesseur/bert-base-cased-timeframe-classifier"  # Specify the model to use from the Hugging Face Model Hub
)

# Apply the classifier to each row in the "Text" column and store results in a new column "label"
df['label'] = df['Text'].apply(lambda text: classifier(text)[0]['label'])  # Classify each text and store the label

# Display the DataFrame with the new "label" column
df.head(5)  # Display the first 5 rows of the DataFrame
```