ilovetools 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ilovetools/ml/metrics.py CHANGED
@@ -16,7 +16,11 @@ __all__ = [
16
16
  'mean_absolute_error',
17
17
  'root_mean_squared_error',
18
18
  'r2_score',
19
- 'roc_auc_score'
19
+ 'roc_auc_score',
20
+ # Aliases
21
+ 'mse',
22
+ 'mae',
23
+ 'rmse',
20
24
  ]
21
25
 
22
26
 
@@ -331,6 +335,8 @@ def mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
331
335
  """
332
336
  Calculate Mean Squared Error for regression.
333
337
 
338
+ Alias: mse()
339
+
334
340
  MSE = Average of (actual - predicted)^2
335
341
 
336
342
  Args:
@@ -341,25 +347,23 @@ def mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
341
347
  float: MSE value
342
348
 
343
349
  Examples:
344
- >>> from ilovetools.ml import mean_squared_error
350
+ >>> from ilovetools.ml import mse # Short alias
345
351
 
346
352
  # Perfect predictions
347
353
  >>> y_true = [1.0, 2.0, 3.0, 4.0]
348
354
  >>> y_pred = [1.0, 2.0, 3.0, 4.0]
349
- >>> mean_squared_error(y_true, y_pred)
355
+ >>> mse(y_true, y_pred)
350
356
  0.0
351
357
 
352
358
  # With errors
353
359
  >>> y_true = [100, 200, 300, 400]
354
360
  >>> y_pred = [110, 190, 310, 390]
355
- >>> mse = mean_squared_error(y_true, y_pred)
356
- >>> print(f"MSE: {mse:.2f}")
361
+ >>> error = mse(y_true, y_pred)
362
+ >>> print(f"MSE: {error:.2f}")
357
363
  MSE: 100.00
358
364
 
359
- # House price prediction
360
- >>> actual_prices = [250000, 300000, 350000]
361
- >>> predicted_prices = [245000, 310000, 340000]
362
- >>> mse = mean_squared_error(actual_prices, predicted_prices)
365
+ >>> from ilovetools.ml import mean_squared_error # Full name
366
+ >>> error = mean_squared_error(y_true, y_pred)
363
367
 
364
368
  Notes:
365
369
  - Penalizes large errors heavily
@@ -374,10 +378,16 @@ def mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
374
378
  return sum(squared_errors) / len(squared_errors)
375
379
 
376
380
 
381
+ # Create alias
382
+ mse = mean_squared_error
383
+
384
+
377
385
  def mean_absolute_error(y_true: List[float], y_pred: List[float]) -> float:
378
386
  """
379
387
  Calculate Mean Absolute Error for regression.
380
388
 
389
+ Alias: mae()
390
+
381
391
  MAE = Average of |actual - predicted|
382
392
 
383
393
  Args:
@@ -388,27 +398,23 @@ def mean_absolute_error(y_true: List[float], y_pred: List[float]) -> float:
388
398
  float: MAE value
389
399
 
390
400
  Examples:
391
- >>> from ilovetools.ml import mean_absolute_error
401
+ >>> from ilovetools.ml import mae # Short alias
392
402
 
393
403
  # Perfect predictions
394
404
  >>> y_true = [1.0, 2.0, 3.0, 4.0]
395
405
  >>> y_pred = [1.0, 2.0, 3.0, 4.0]
396
- >>> mean_absolute_error(y_true, y_pred)
406
+ >>> mae(y_true, y_pred)
397
407
  0.0
398
408
 
399
409
  # With errors
400
410
  >>> y_true = [100, 200, 300, 400]
401
411
  >>> y_pred = [110, 190, 310, 390]
402
- >>> mae = mean_absolute_error(y_true, y_pred)
403
- >>> print(f"MAE: ${mae:.2f}")
412
+ >>> error = mae(y_true, y_pred)
413
+ >>> print(f"MAE: ${error:.2f}")
404
414
  MAE: $10.00
405
415
 
406
- # House price prediction
407
- >>> actual_prices = [250000, 300000, 350000]
408
- >>> predicted_prices = [245000, 310000, 340000]
409
- >>> mae = mean_absolute_error(actual_prices, predicted_prices)
410
- >>> print(f"Average error: ${mae:,.0f}")
411
- Average error: $8,333
416
+ >>> from ilovetools.ml import mean_absolute_error # Full name
417
+ >>> error = mean_absolute_error(y_true, y_pred)
412
418
 
413
419
  Notes:
414
420
  - Easy to interpret
@@ -423,10 +429,16 @@ def mean_absolute_error(y_true: List[float], y_pred: List[float]) -> float:
423
429
  return sum(absolute_errors) / len(absolute_errors)
424
430
 
425
431
 
432
+ # Create alias
433
+ mae = mean_absolute_error
434
+
435
+
426
436
  def root_mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
427
437
  """
428
438
  Calculate Root Mean Squared Error for regression.
429
439
 
440
+ Alias: rmse()
441
+
430
442
  RMSE = sqrt(MSE)
431
443
 
432
444
  Args:
@@ -437,27 +449,23 @@ def root_mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
437
449
  float: RMSE value
438
450
 
439
451
  Examples:
440
- >>> from ilovetools.ml import root_mean_squared_error
452
+ >>> from ilovetools.ml import rmse # Short alias
441
453
 
442
454
  # Perfect predictions
443
455
  >>> y_true = [1.0, 2.0, 3.0, 4.0]
444
456
  >>> y_pred = [1.0, 2.0, 3.0, 4.0]
445
- >>> root_mean_squared_error(y_true, y_pred)
457
+ >>> rmse(y_true, y_pred)
446
458
  0.0
447
459
 
448
460
  # With errors
449
461
  >>> y_true = [100, 200, 300, 400]
450
462
  >>> y_pred = [110, 190, 310, 390]
451
- >>> rmse = root_mean_squared_error(y_true, y_pred)
452
- >>> print(f"RMSE: {rmse:.2f}")
463
+ >>> error = rmse(y_true, y_pred)
464
+ >>> print(f"RMSE: {error:.2f}")
453
465
  RMSE: 10.00
454
466
 
455
- # House price prediction
456
- >>> actual_prices = [250000, 300000, 350000]
457
- >>> predicted_prices = [245000, 310000, 340000]
458
- >>> rmse = root_mean_squared_error(actual_prices, predicted_prices)
459
- >>> print(f"RMSE: ${rmse:,.0f}")
460
- RMSE: $8,165
467
+ >>> from ilovetools.ml import root_mean_squared_error # Full name
468
+ >>> error = root_mean_squared_error(y_true, y_pred)
461
469
 
462
470
  Notes:
463
471
  - Most common regression metric
@@ -465,8 +473,12 @@ def root_mean_squared_error(y_true: List[float], y_pred: List[float]) -> float:
465
473
  - Penalizes large errors
466
474
  - Lower is better
467
475
  """
468
- mse = mean_squared_error(y_true, y_pred)
469
- return mse ** 0.5
476
+ mse_value = mean_squared_error(y_true, y_pred)
477
+ return mse_value ** 0.5
478
+
479
+
480
+ # Create alias
481
+ rmse = root_mean_squared_error
470
482
 
471
483
 
472
484
  def r2_score(y_true: List[float], y_pred: List[float]) -> float: