pszemraj commited on
Commit
2d8411f
1 Parent(s): f899167

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -9
README.md CHANGED
@@ -42,26 +42,21 @@ regression_config_path = hf_hub_download(
42
  with open(regression_config_path, "r") as f:
43
  regression_config = json.load(f)
44
 
45
-
46
  def inverse_scale(prediction, config):
47
  """apply inverse scaling to a prediction"""
48
  min_value, max_value = config["min_value"], config["max_value"]
49
  return prediction * (max_value - min_value) + min_value
50
 
51
-
52
- def predict_with_pipeline(text, pipe, config, ndigits=4):
53
- result = pipe(text, truncation=True)[0] # Get the first (and likely only) result
54
- score = result["score"] if result["label"] == "LABEL_1" else 1 - result["score"]
55
- # Apply inverse scaling
56
- scaled_score = inverse_scale(score, config)
57
  return round(scaled_score, ndigits)
58
 
59
-
60
  text = "This is an example text for regression prediction."
61
 
62
  # Get predictions
63
  predictions = predict_with_pipeline(text, pipe, regression_config)
64
- print("Predicted returns (frec):", predictions)
65
  ```
66
 
67
  </details>
 
42
  with open(regression_config_path, "r") as f:
43
  regression_config = json.load(f)
44
 
 
45
  def inverse_scale(prediction, config):
46
  """apply inverse scaling to a prediction"""
47
  min_value, max_value = config["min_value"], config["max_value"]
48
  return prediction * (max_value - min_value) + min_value
49
 
50
+ def predict_with_pipeline(text, pipe, config, ndigits=5):
51
+ result = pipe(text, truncation=True)[0]
52
+ scaled_score = inverse_scale(result['score'], config)
 
 
 
53
  return round(scaled_score, ndigits)
54
 
 
55
  text = "This is an example text for regression prediction."
56
 
57
  # Get predictions
58
  predictions = predict_with_pipeline(text, pipe, regression_config)
59
+ print("Predicted Value:", predictions)
60
  ```
61
 
62
  </details>