packages feed

dataframe-hasktorch 0.2.0.2 → 0.4.0.0

raw patch · 2 files changed

+12/−74 lines, 2 filesdep −dataframe-hasktorchdep −ghc-typelits-natnormalisedep ~dataframe-coredep ~dataframe-operationsdep ~vectorPVP ok

version bump matches the API change (PVP)

Dependencies removed: dataframe-hasktorch, ghc-typelits-natnormalise

Dependency ranges changed: dataframe-core, dataframe-operations, vector

API changes (from Hackage documentation)

Files

dataframe-hasktorch.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               dataframe-hasktorch-version:            0.2.0.2+version:            0.4.0.0 synopsis:           Converts between dataframes and hasktorch tensors  description:        @@ -36,14 +36,10 @@     exposed-modules:  DataFrame.Hasktorch      build-depends:    base >= 4.11 && < 5,-                      vector ^>= 0.13,-                      dataframe-core ^>= 1.1,-                      dataframe-operations ^>= 1.1.1,+                      vector >= 0.13 && < 0.15,+                      dataframe-core ^>= 2.1,+                      dataframe-operations ^>= 2.1,                       hasktorch >= 0.2.1.6 && < 0.3-    if impl(ghc >= 9.12)-      build-depends: ghc-typelits-natnormalise == 0.9.3-    else-      build-depends: ghc-typelits-natnormalise >= 0.7.7 && < 0.9      hs-source-dirs:   src @@ -56,5 +52,4 @@     hs-source-dirs:   test     main-is:          Main.hs     build-depends:-        base >= 4.11 && < 5,-        dataframe-hasktorch+        base >= 4.11 && < 5
src/DataFrame/Hasktorch.hs view
@@ -11,41 +11,15 @@ import qualified DataFrame.Operations.Core as D  import Control.Exception (throw)-import DataFrame.Internal.DataFrame (DataFrame)+import DataFrame.Core (DataFrame) import Torch -{- | Converts a dataframe to a floating-point tensor.--This function converts all columns in the dataframe to floats and creates-a tensor suitable for machine learning operations. The tensor dimensions-are determined by the dataframe's shape.--==== __Dimensional behavior__--* Multi-column dataframe: Creates a 2D tensor with shape @[rows, columns]@-* Single-column dataframe: Creates a 1D tensor with shape @[rows]@--==== __Conversion process__--1. Converts the dataframe to a float matrix using 'D.toFloatMatrix'-2. Flattens the matrix features into a 1D representation-3. Reshapes into the appropriate tensor dimensions--==== __Throws__--* 'DataFrameException' - if any column cannot be converted to float--==== __Examples__+{- | Convert a dataframe to a floating-point tensor of shape @[rows, columns]@+(or @[rows]@ when single-column). Throws 'DataFrameException' if a column+cannot be converted to float.  >>> toTensor df  -- where df has shape (100, 5) Tensor with shape [100, 5]-->>> toTensor df  -- where df has shape (100, 1)-Tensor with shape [100]--==== __See also__--* 'toIntTensor' - for integer tensor conversion -} toTensor :: DataFrame -> Tensor toTensor df = case D.toFloatMatrix df of@@ -57,43 +31,12 @@          in             reshape dims' (asTensor (flattenFeatures m)) -{- | Converts a dataframe to an integer tensor.--This function converts all columns in the dataframe to integers and creates-a tensor suitable for machine learning operations (e.g., classification labels,-discrete features). The tensor dimensions are determined by the dataframe's shape.--==== __Dimensional behavior__--* Multi-column dataframe: Creates a 2D tensor with shape @[rows, columns]@-* Single-column dataframe: Creates a 1D tensor with shape @[rows]@--==== __Conversion process__--1. Converts the dataframe to an int matrix using 'D.toIntMatrix'-2. Flattens the matrix features into a 1D representation-3. Reshapes into the appropriate tensor dimensions--==== __Throws__--* 'DataFrameException' - if any column cannot be converted to int--==== __Examples__-->>> toIntTensor labelsDf  -- where labelsDf has shape (100, 1)-Tensor with shape [100]+{- | Convert a dataframe to an integer tensor of shape @[rows, columns]@ (or+@[rows]@ when single-column). Floating-point values are rounded. Throws+'DataFrameException' if a column cannot be converted to int.  >>> toIntTensor featuresDf  -- where featuresDf has shape (100, 3) Tensor with shape [100, 3]--==== __Note__--Floating-point values in the dataframe will be rounded to the nearest integer.-See 'D.toIntMatrix' for details on the conversion behavior.--==== __See also__--* 'toTensor' - for floating-point tensor conversion -} toIntTensor :: DataFrame -> Tensor toIntTensor df = case D.toIntMatrix df of