diff --git a/docs/api/SUMMARY.md b/docs/api/SUMMARY.md index 7e74858da..b4f3f2440 100644 --- a/docs/api/SUMMARY.md +++ b/docs/api/SUMMARY.md @@ -8,6 +8,7 @@ search: - image - containers - [Image](safeds/data/image/containers/Image.md) + - [ImageList](safeds/data/image/containers/ImageList.md) - tabular - containers - [Column](safeds/data/tabular/containers/Column.md) @@ -62,6 +63,7 @@ search: - [SupportVectorMachineClassifier](safeds/ml/classical/classification/SupportVectorMachineClassifier.md) - regression - [AdaBoostRegressor](safeds/ml/classical/regression/AdaBoostRegressor.md) + - [ArimaRegressor](safeds/ml/classical/regression/ArimaRegressor.md) - [DecisionTreeRegressor](safeds/ml/classical/regression/DecisionTreeRegressor.md) - [ElasticNetRegressor](safeds/ml/classical/regression/ElasticNetRegressor.md) - [GradientBoostingRegressor](safeds/ml/classical/regression/GradientBoostingRegressor.md) @@ -73,6 +75,7 @@ search: - [RidgeRegressor](safeds/ml/classical/regression/RidgeRegressor.md) - [SupportVectorMachineRegressor](safeds/ml/classical/regression/SupportVectorMachineRegressor.md) - nn - - [FNNLayer](safeds/ml/nn/FNNLayer.md) + - [ForwardLayer](safeds/ml/nn/ForwardLayer.md) + - [Layer](safeds/ml/nn/Layer.md) - [NeuralNetworkClassifier](safeds/ml/nn/NeuralNetworkClassifier.md) - [NeuralNetworkRegressor](safeds/ml/nn/NeuralNetworkRegressor.md) diff --git a/docs/api/safeds/data/image/containers/Image.md b/docs/api/safeds/data/image/containers/Image.md index f4d2ede69..7eff25ae8 100644 --- a/docs/api/safeds/data/image/containers/Image.md +++ b/docs/api/safeds/data/image/containers/Image.md @@ -55,6 +55,21 @@ A container for image data. path: String ) + /** + * Return a new `Image` that has the given number of channels. + * + * The original image is not modified. + * + * @param channel The new number of channels. 1 will result in a grayscale image. + * + * @result result1 The image with the given number of channels. + */ + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> result1: Image + /** * Return a new `Image` that has been resized to a given size. * @@ -330,7 +345,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="163" + ```sds linenums="178" @Pure @PythonName("add_noise") fun addNoise( @@ -360,7 +375,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="146" + ```sds linenums="161" @Pure @PythonName("adjust_brightness") fun adjustBrightness( @@ -390,7 +405,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="203" + ```sds linenums="218" @Pure @PythonName("adjust_color_balance") fun adjustColorBalance( @@ -420,7 +435,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="183" + ```sds linenums="198" @Pure @PythonName("adjust_contrast") fun adjustContrast( @@ -450,7 +465,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="221" + ```sds linenums="236" @Pure fun blur( const radius: Int @@ -459,6 +474,34 @@ The original image is not modified. } ``` +## `#!sds fun` changeChannel {#safeds.data.image.containers.Image.changeChannel data-toc-label='changeChannel'} + +Return a new `Image` that has the given number of channels. + +The original image is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `channel` | [`Int`][safeds.lang.Int] | The new number of channels. 1 will result in a grayscale image. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `result1` | [`Image`][safeds.data.image.containers.Image] | The image with the given number of channels. | + +??? quote "Stub code in `image.sdsstub`" + + ```sds linenums="65" + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> result1: Image + ``` + ## `#!sds fun` convertToGrayscale {#safeds.data.image.containers.Image.convertToGrayscale data-toc-label='convertToGrayscale'} Return a new `Image` that is converted to grayscale. @@ -473,7 +516,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="82" + ```sds linenums="97" @Pure @PythonName("convert_to_grayscale") fun convertToGrayscale() -> result1: Image @@ -502,7 +545,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="98" + ```sds linenums="113" @Pure fun crop( const x: Int, @@ -531,7 +574,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="287" + ```sds linenums="302" @Pure @PythonName("find_edges") fun findEdges() -> result1: Image @@ -551,7 +594,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="129" + ```sds linenums="144" @Pure @PythonName("flip_horizontally") fun flipHorizontally() -> result1: Image @@ -571,7 +614,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="118" + ```sds linenums="133" @Pure @PythonName("flip_vertically") fun flipVertically() -> result1: Image @@ -591,7 +634,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="254" + ```sds linenums="269" @Pure @PythonName("invert_colors") fun invertColors() -> result1: Image @@ -618,7 +661,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="66" + ```sds linenums="81" @Pure fun resize( @PythonName("new_width") const newWidth: Int, @@ -643,7 +686,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="276" + ```sds linenums="291" @Pure @PythonName("rotate_left") fun rotateLeft() -> result1: Image @@ -663,7 +706,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="265" + ```sds linenums="280" @Pure @PythonName("rotate_right") fun rotateRight() -> result1: Image @@ -689,7 +732,7 @@ The original image is not modified. ??? quote "Stub code in `image.sdsstub`" - ```sds linenums="240" + ```sds linenums="255" @Pure fun sharpen( const factor: Float diff --git a/docs/api/safeds/data/image/containers/ImageList.md b/docs/api/safeds/data/image/containers/ImageList.md new file mode 100644 index 000000000..89b75d1bf --- /dev/null +++ b/docs/api/safeds/data/image/containers/ImageList.md @@ -0,0 +1,1371 @@ +# `#!sds abstract class` ImageList {#safeds.data.image.containers.ImageList data-toc-label='ImageList'} + +An ImageList is a list of different images. It can hold different sizes of Images. The channel of all images is the same. + +To create an `ImageList` call one of the following static methods: + +| Method | Description | +| ---------------------------- | -------------------------------------------------------- | +| [ImageList.fromImages][safeds.data.image.containers.ImageList.fromImages] | Create an ImageList from a list of Images. | +| [ImageList.fromFiles][safeds.data.image.containers.ImageList.fromFiles] | Create an ImageList from a directory or a list of files. | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="15" + class ImageList { + /** + * Return the number of images in this image list. + */ + @PythonName("number_of_images") attr numberOfImages: Int + /** + * Return a list of all widths in this image list. + */ + attr widths: List + /** + * Return a list of all heights in this image list. + */ + attr heights: List + /** + * Return the channel of all images. + */ + attr channel: Int + /** + * Return the number of different sizes of images in this image list. + */ + @PythonName("number_of_sizes") attr numberOfSizes: Int + + /** + * Create an ImageList from a list of images. + * + * @param images the list of images + * + * @result imageList the image list + */ + @Pure + @PythonName("from_images") + static fun fromImages( + images: List + ) -> imageList: ImageList + + /** + * Create an ImageList from a directory or a list of files. + * + * If you provide a path to a directory the images will be sorted alphabetically while inner directories will be sorted after image files. + * + * @param path the path to the directory or a list of files + * + * @result imageList the image list + */ + @Impure([ImpurityReason.FileReadFromParameterizedPath("path")]) + @PythonName("from_files") + static fun fromFiles( + path: union, String> + ) -> imageList: ImageList + + /** + * Return the image at the given index. + * + * @param index the index for the image to return + * + * @result image the image at the given index + */ + @Pure + @PythonName("get_image") + fun getImage( + index: Int + ) -> image: Image + + /** + * Return a list of indexes of the given image. + * + * If the image has multiple occurrences, all indices will be returned + * + * @param image the image to search for occurrences + * + * @result indices all occurrences of the image + */ + @Pure + fun index( + image: Image + ) -> indices: List + + /** + * Return whether the given image is in this image list. + * + * @param image the image to check + * + * @result hasImage Weather the given image is in this image list + */ + @Pure + @PythonName("has_image") + fun hasImage( + image: Image + ) -> hasImage: Boolean + + /** + * Save all images as jpeg files. + * + * @param path Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created + */ + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_jpeg_files") + fun toJpegFiles( + path: union, String> + ) + + /** + * Save all images as png files. + * + * @param path Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created + */ + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_png_files") + fun toPngFiles( + path: union, String> + ) + + /** + * Return a list of all images in this image list. + * + * @param indices a list of all indices to include in the output. If None, all indices will be included + * + * @result images the list of all images + */ + @Pure + @PythonName("to_images") + fun toImages( + indices: List? = null + ) -> images: List + + /** + * Return a new `ImageList` that has the given number of channels. + * + * The original image list is not modified. + * + * @param channel The new number of channels. 1 will result in grayscale images + * + * @result imageList the image list with the given number of channels + */ + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given image added to the image list. + * + * The original image list is not modified. + * + * @param image The image to be added to the image list + * + * @result imageList the image list with the new image added + */ + @Pure + @PythonName("add_image") + fun addImage( + image: Image + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given images added to the image list. + * + * The original image list is not modified. + * + * @param images The images to be added to the image list + * + * @result imageList the image list with the new images added + */ + @Pure + @PythonName("add_images") + fun addImages( + images: union> + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given image removed from the image list. + * + * If the image has multiple occurrences, all occurrences will be removed. + * + * The original image list is not modified. + * + * @param image The image to be removed from the image list + * + * @result imageList the image list with the given image removed + */ + @Pure + @PythonName("remove_image") + fun removeImage( + image: Image + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given images removed from the image list. + * + * If one image has multiple occurrences, all occurrences will be removed. + * + * The original image list is not modified. + * + * @param images The images to be removed from the image list + * + * @result imageList the image list with the given images removed + */ + @Pure + @PythonName("remove_images") + fun removeImages( + images: List + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given indices removed from the image list. + * + * The original image list is not modified. + * + * @param index The index of the image to be removed from the image list + * + * @result imageList the image list with the without the removed image + */ + @Pure + @PythonName("remove_image_by_index") + fun removeImageByIndex( + index: union> + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the all images of the given size removed. + * + * The original image list is not modified. + * + * @param width The width of the images to be removed from the image list + * @param height The height of the images to be removed from the image list + * + * @result imageList the image list with the given images removed + */ + @Pure + @PythonName("remove_images_with_size") + fun removeImagesWithSize( + width: Int, + height: Int + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with all duplicate images removed. + * + * One occurrence of each image will stay in the image list. + * + * The original image list is not modified. + * + * @result imageList the image list with only unique images + */ + @Pure + @PythonName("remove_duplicate_images") + fun removeDuplicateImages() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images shuffled. + * + * The original image list is not modified. + * + * @result imageList the image list with shuffled images + */ + @Pure + @PythonName("shuffle_images") + fun shuffleImages() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images resized to a given size. + * + * The original image list is not modified. + * + * @param newWidth the new width of the images + * @param newHeight the new height of the images + * + * @result imageList The image list with all images resized to the given width and height. + */ + @Pure + fun resize( + @PythonName("new_width") const newWidth: Int, + @PythonName("new_height") const newHeight: Int + ) -> imageList: ImageList where { + newWidth >= 0, + newHeight >= 0 + } + + /** + * Return a new `ImageList` with all images converted to grayscale. + * + * The original image list is not modified. + * + * @result imageList The image list with all images converted to grayscale. + */ + @Pure + @PythonName("convert_to_grayscale") + fun convertToGrayscale() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images cropped to a given bounding rectangle. + * + * The original image list is not modified. + * + * @param x the x coordinate of the top-left corner of the bounding rectangle + * @param y the y coordinate of the top-left corner of the bounding rectangle + * @param width the width of the bounding rectangle + * @param height the height of the bounding rectangle + * + * @result imageList The image list with all images cropped + */ + @Pure + fun crop( + const x: Int, + const y: Int, + const width: Int, + const height: Int + ) -> imageList: ImageList where { + x >= 0, + y >= 0, + width >= 0, + height >= 0 + } + + /** + * Return a new `ImageList` with all images flipped vertically (horizontal axis, flips up-down and vice versa). + * + * The original image list is not modified. + * + * @result imageList The image list with all images flipped vertically + */ + @Pure + @PythonName("flip_vertically") + fun flipVertically() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images flipped horizontally (vertical axis, flips left-right and vice versa). + * + * The original image list is not modified. + * + * @result imageList The image list with all images flipped horizontally + */ + @Pure + @PythonName("flip_horizontally") + fun flipHorizontally() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have the adjusted brightness. + * + * The original image list is not modified. + * + * @param factor The brightness factor. + * 1.0 will not change the brightness. + * Below 1.0 will result in a darker images. + * Above 1.0 will resolut in a brighter images. + * Has to be bigger than or equal to 0 (black). + * + * @result imageList The image list with adjusted brightness + */ + @Pure + @PythonName("adjust_brightness") + fun adjustBrightness( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` with noise added to all images. + * + * The original image list is not modified. + * + * @param standardDeviation The standard deviation of the normal distribution. Has to be bigger than or equal to 0. + * + * @result imageList The image list with added noise + */ + @Pure + @PythonName("add_noise") + fun addNoise( + @PythonName("standard_deviation") const standardDeviation: Float + ) -> imageList: ImageList where { + standardDeviation >= 0.0 + } + + /** + * Return a new `ImageList` where all images have the adjusted contrast. + * + * The original image list is not modified. + * + * @param factor If factor > 1, increase contrast of images. + * If factor = 1, no changes will be made. + * If factor < 1, make images greyer. + * Has to be bigger than or equal to 0 (gray). + * + * @result imageList The image list with adjusted contrast + */ + @Pure + @PythonName("adjust_contrast") + fun adjustContrast( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have the adjusted color balance. + * + * The original image list is not modified. + * + * @param factor Has to be bigger than or equal to 0. + * If 0 <= factor < 1, make images greyer. + * If factor = 1, no changes will be made. + * If factor > 1, increase color balance of images. + * + * @result imageList The image list with adjusted color balance + */ + @Pure + @PythonName("adjust_color_balance") + fun adjustColorBalance( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have been blurred. + * + * The original image list is not modified. + * + * @param radius Radius is directly proportional to the blur value. The radius is equal to the amount of pixels united in + * each direction. A radius of 1 will result in a united box of 9 pixels. + * + * @result imageList The image list with blurred images + */ + @Pure + fun blur( + const radius: Int + ) -> imageList: ImageList where { + radius >= 0 + } + + /** + * Return a new `ImageList` where all images have been sharpened. + * + * The original image list is not modified. + * + * @param factor If factor > 1, increase the sharpness of the images. + * If factor = 1, no changes will be made. + * If factor < 1, blur the images. + * Has to be bigger than or equal to 0 (blurred). + * + * @result imageList The image list with sharpened images + */ + @Pure + fun sharpen( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have their colors inverted. + * + * The original image list is not modified. + * + * @result imageList The image list with inverted colors + */ + @Pure + @PythonName("invert_colors") + fun invertColors() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have been rotated 90 degrees clockwise. + * + * The original image list is not modified. + * + * @result imageList The image list with all images rotated + */ + @Pure + @PythonName("rotate_right") + fun rotateRight() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have been rotated 90 degrees counter-clockwise. + * + * The original image list is not modified. + * + * @result imageList The image list with all images rotated + */ + @Pure + @PythonName("rotate_left") + fun rotateLeft() -> imageList: ImageList + + /** + * Return a new `ImageList` with grayscale versions of the images with the edges highlighted. + * + * The original image list is not modified. + * + * @result imageList The image list with highlighted edges + */ + @Pure + @PythonName("find_edges") + fun findEdges() -> imageList: ImageList + } + ``` + +## `#!sds attr` channel {#safeds.data.image.containers.ImageList.channel data-toc-label='channel'} + +Return the channel of all images. + +**Type:** [`Int`][safeds.lang.Int] + +## `#!sds attr` heights {#safeds.data.image.containers.ImageList.heights data-toc-label='heights'} + +Return a list of all heights in this image list. + +**Type:** [`List`][safeds.lang.List] + +## `#!sds attr` numberOfImages {#safeds.data.image.containers.ImageList.numberOfImages data-toc-label='numberOfImages'} + +Return the number of images in this image list. + +**Type:** [`Int`][safeds.lang.Int] + +## `#!sds attr` numberOfSizes {#safeds.data.image.containers.ImageList.numberOfSizes data-toc-label='numberOfSizes'} + +Return the number of different sizes of images in this image list. + +**Type:** [`Int`][safeds.lang.Int] + +## `#!sds attr` widths {#safeds.data.image.containers.ImageList.widths data-toc-label='widths'} + +Return a list of all widths in this image list. + +**Type:** [`List`][safeds.lang.List] + +## `#!sds fun` addImage {#safeds.data.image.containers.ImageList.addImage data-toc-label='addImage'} + +Return a new `ImageList` with the given image added to the image list. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `image` | [`Image`][safeds.data.image.containers.Image] | The image to be added to the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the new image added | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="164" + @Pure + @PythonName("add_image") + fun addImage( + image: Image + ) -> imageList: ImageList + ``` + +## `#!sds fun` addImages {#safeds.data.image.containers.ImageList.addImages data-toc-label='addImages'} + +Return a new `ImageList` with the given images added to the image list. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `images` | `#!sds union>` | The images to be added to the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the new images added | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="179" + @Pure + @PythonName("add_images") + fun addImages( + images: union> + ) -> imageList: ImageList + ``` + +## `#!sds fun` addNoise {#safeds.data.image.containers.ImageList.addNoise data-toc-label='addNoise'} + +Return a new `ImageList` with noise added to all images. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `standardDeviation` | [`Float`][safeds.lang.Float] | The standard deviation of the normal distribution. Has to be bigger than or equal to 0. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with added noise | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="382" + @Pure + @PythonName("add_noise") + fun addNoise( + @PythonName("standard_deviation") const standardDeviation: Float + ) -> imageList: ImageList where { + standardDeviation >= 0.0 + } + ``` + +## `#!sds fun` adjustBrightness {#safeds.data.image.containers.ImageList.adjustBrightness data-toc-label='adjustBrightness'} + +Return a new `ImageList` where all images have the adjusted brightness. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `factor` | [`Float`][safeds.lang.Float] | The brightness factor. 1.0 will not change the brightness. Below 1.0 will result in a darker images. Above 1.0 will resolut in a brighter images. Has to be bigger than or equal to 0 (black). | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with adjusted brightness | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="365" + @Pure + @PythonName("adjust_brightness") + fun adjustBrightness( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + ``` + +## `#!sds fun` adjustColorBalance {#safeds.data.image.containers.ImageList.adjustColorBalance data-toc-label='adjustColorBalance'} + +Return a new `ImageList` where all images have the adjusted color balance. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `factor` | [`Float`][safeds.lang.Float] | Has to be bigger than or equal to 0. If 0 <= factor < 1, make images greyer. If factor = 1, no changes will be made. If factor > 1, increase color balance of images. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with adjusted color balance | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="422" + @Pure + @PythonName("adjust_color_balance") + fun adjustColorBalance( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + ``` + +## `#!sds fun` adjustContrast {#safeds.data.image.containers.ImageList.adjustContrast data-toc-label='adjustContrast'} + +Return a new `ImageList` where all images have the adjusted contrast. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `factor` | [`Float`][safeds.lang.Float] | If factor > 1, increase contrast of images. If factor = 1, no changes will be made. If factor < 1, make images greyer. Has to be bigger than or equal to 0 (gray). | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with adjusted contrast | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="402" + @Pure + @PythonName("adjust_contrast") + fun adjustContrast( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + ``` + +## `#!sds fun` blur {#safeds.data.image.containers.ImageList.blur data-toc-label='blur'} + +Return a new `ImageList` where all images have been blurred. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `radius` | [`Int`][safeds.lang.Int] | Radius is directly proportional to the blur value. The radius is equal to the amount of pixels united in each direction. A radius of 1 will result in a united box of 9 pixels. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with blurred images | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="440" + @Pure + fun blur( + const radius: Int + ) -> imageList: ImageList where { + radius >= 0 + } + ``` + +## `#!sds fun` changeChannel {#safeds.data.image.containers.ImageList.changeChannel data-toc-label='changeChannel'} + +Return a new `ImageList` that has the given number of channels. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `channel` | [`Int`][safeds.lang.Int] | The new number of channels. 1 will result in grayscale images | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the given number of channels | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="149" + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> imageList: ImageList + ``` + +## `#!sds fun` convertToGrayscale {#safeds.data.image.containers.ImageList.convertToGrayscale data-toc-label='convertToGrayscale'} + +Return a new `ImageList` with all images converted to grayscale. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images converted to grayscale. | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="301" + @Pure + @PythonName("convert_to_grayscale") + fun convertToGrayscale() -> imageList: ImageList + ``` + +## `#!sds fun` crop {#safeds.data.image.containers.ImageList.crop data-toc-label='crop'} + +Return a new `ImageList` with all images cropped to a given bounding rectangle. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `x` | [`Int`][safeds.lang.Int] | the x coordinate of the top-left corner of the bounding rectangle | - | +| `y` | [`Int`][safeds.lang.Int] | the y coordinate of the top-left corner of the bounding rectangle | - | +| `width` | [`Int`][safeds.lang.Int] | the width of the bounding rectangle | - | +| `height` | [`Int`][safeds.lang.Int] | the height of the bounding rectangle | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images cropped | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="317" + @Pure + fun crop( + const x: Int, + const y: Int, + const width: Int, + const height: Int + ) -> imageList: ImageList where { + x >= 0, + y >= 0, + width >= 0, + height >= 0 + } + ``` + +## `#!sds fun` findEdges {#safeds.data.image.containers.ImageList.findEdges data-toc-label='findEdges'} + +Return a new `ImageList` with grayscale versions of the images with the edges highlighted. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with highlighted edges | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="506" + @Pure + @PythonName("find_edges") + fun findEdges() -> imageList: ImageList + ``` + +## `#!sds fun` flipHorizontally {#safeds.data.image.containers.ImageList.flipHorizontally data-toc-label='flipHorizontally'} + +Return a new `ImageList` with all images flipped horizontally (vertical axis, flips left-right and vice versa). + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images flipped horizontally | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="348" + @Pure + @PythonName("flip_horizontally") + fun flipHorizontally() -> imageList: ImageList + ``` + +## `#!sds fun` flipVertically {#safeds.data.image.containers.ImageList.flipVertically data-toc-label='flipVertically'} + +Return a new `ImageList` with all images flipped vertically (horizontal axis, flips up-down and vice versa). + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images flipped vertically | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="337" + @Pure + @PythonName("flip_vertically") + fun flipVertically() -> imageList: ImageList + ``` + +## `#!sds fun` getImage {#safeds.data.image.containers.ImageList.getImage data-toc-label='getImage'} + +Return the image at the given index. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `index` | [`Int`][safeds.lang.Int] | the index for the image to return | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `image` | [`Image`][safeds.data.image.containers.Image] | the image at the given index | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="72" + @Pure + @PythonName("get_image") + fun getImage( + index: Int + ) -> image: Image + ``` + +## `#!sds fun` hasImage {#safeds.data.image.containers.ImageList.hasImage data-toc-label='hasImage'} + +Return whether the given image is in this image list. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `image` | [`Image`][safeds.data.image.containers.Image] | the image to check | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `hasImage` | [`Boolean`][safeds.lang.Boolean] | Weather the given image is in this image list | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="99" + @Pure + @PythonName("has_image") + fun hasImage( + image: Image + ) -> hasImage: Boolean + ``` + +## `#!sds fun` index {#safeds.data.image.containers.ImageList.index data-toc-label='index'} + +Return a list of indexes of the given image. + +If the image has multiple occurrences, all indices will be returned + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `image` | [`Image`][safeds.data.image.containers.Image] | the image to search for occurrences | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `indices` | [`List`][safeds.lang.List] | all occurrences of the image | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="87" + @Pure + fun index( + image: Image + ) -> indices: List + ``` + +## `#!sds fun` invertColors {#safeds.data.image.containers.ImageList.invertColors data-toc-label='invertColors'} + +Return a new `ImageList` where all images have their colors inverted. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with inverted colors | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="473" + @Pure + @PythonName("invert_colors") + fun invertColors() -> imageList: ImageList + ``` + +## `#!sds fun` removeDuplicateImages {#safeds.data.image.containers.ImageList.removeDuplicateImages data-toc-label='removeDuplicateImages'} + +Return a new `ImageList` with all duplicate images removed. + +One occurrence of each image will stay in the image list. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with only unique images | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="260" + @Pure + @PythonName("remove_duplicate_images") + fun removeDuplicateImages() -> imageList: ImageList + ``` + +## `#!sds fun` removeImage {#safeds.data.image.containers.ImageList.removeImage data-toc-label='removeImage'} + +Return a new `ImageList` with the given image removed from the image list. + +If the image has multiple occurrences, all occurrences will be removed. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `image` | [`Image`][safeds.data.image.containers.Image] | The image to be removed from the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the given image removed | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="196" + @Pure + @PythonName("remove_image") + fun removeImage( + image: Image + ) -> imageList: ImageList + ``` + +## `#!sds fun` removeImageByIndex {#safeds.data.image.containers.ImageList.removeImageByIndex data-toc-label='removeImageByIndex'} + +Return a new `ImageList` with the given indices removed from the image list. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `index` | `#!sds union>` | The index of the image to be removed from the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the without the removed image | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="228" + @Pure + @PythonName("remove_image_by_index") + fun removeImageByIndex( + index: union> + ) -> imageList: ImageList + ``` + +## `#!sds fun` removeImages {#safeds.data.image.containers.ImageList.removeImages data-toc-label='removeImages'} + +Return a new `ImageList` with the given images removed from the image list. + +If one image has multiple occurrences, all occurrences will be removed. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `images` | [`List`][safeds.lang.List] | The images to be removed from the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the given images removed | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="213" + @Pure + @PythonName("remove_images") + fun removeImages( + images: List + ) -> imageList: ImageList + ``` + +## `#!sds fun` removeImagesWithSize {#safeds.data.image.containers.ImageList.removeImagesWithSize data-toc-label='removeImagesWithSize'} + +Return a new `ImageList` with the all images of the given size removed. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `width` | [`Int`][safeds.lang.Int] | The width of the images to be removed from the image list | - | +| `height` | [`Int`][safeds.lang.Int] | The height of the images to be removed from the image list | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with the given images removed | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="244" + @Pure + @PythonName("remove_images_with_size") + fun removeImagesWithSize( + width: Int, + height: Int + ) -> imageList: ImageList + ``` + +## `#!sds fun` resize {#safeds.data.image.containers.ImageList.resize data-toc-label='resize'} + +Return a new `ImageList` with all images resized to a given size. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `newWidth` | [`Int`][safeds.lang.Int] | the new width of the images | - | +| `newHeight` | [`Int`][safeds.lang.Int] | the new height of the images | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images resized to the given width and height. | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="285" + @Pure + fun resize( + @PythonName("new_width") const newWidth: Int, + @PythonName("new_height") const newHeight: Int + ) -> imageList: ImageList where { + newWidth >= 0, + newHeight >= 0 + } + ``` + +## `#!sds fun` rotateLeft {#safeds.data.image.containers.ImageList.rotateLeft data-toc-label='rotateLeft'} + +Return a new `ImageList` where all images have been rotated 90 degrees counter-clockwise. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images rotated | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="495" + @Pure + @PythonName("rotate_left") + fun rotateLeft() -> imageList: ImageList + ``` + +## `#!sds fun` rotateRight {#safeds.data.image.containers.ImageList.rotateRight data-toc-label='rotateRight'} + +Return a new `ImageList` where all images have been rotated 90 degrees clockwise. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with all images rotated | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="484" + @Pure + @PythonName("rotate_right") + fun rotateRight() -> imageList: ImageList + ``` + +## `#!sds fun` sharpen {#safeds.data.image.containers.ImageList.sharpen data-toc-label='sharpen'} + +Return a new `ImageList` where all images have been sharpened. + +The original image list is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `factor` | [`Float`][safeds.lang.Float] | If factor > 1, increase the sharpness of the images. If factor = 1, no changes will be made. If factor < 1, blur the images. Has to be bigger than or equal to 0 (blurred). | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | The image list with sharpened images | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="459" + @Pure + fun sharpen( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + ``` + +## `#!sds fun` shuffleImages {#safeds.data.image.containers.ImageList.shuffleImages data-toc-label='shuffleImages'} + +Return a new `ImageList` with all images shuffled. + +The original image list is not modified. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list with shuffled images | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="271" + @Pure + @PythonName("shuffle_images") + fun shuffleImages() -> imageList: ImageList + ``` + +## `#!sds fun` toImages {#safeds.data.image.containers.ImageList.toImages data-toc-label='toImages'} + +Return a list of all images in this image list. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `indices` | [`List?`][safeds.lang.List] | a list of all indices to include in the output. If None, all indices will be included | `#!sds null` | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `images` | [`List`][safeds.lang.List] | the list of all images | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="134" + @Pure + @PythonName("to_images") + fun toImages( + indices: List? = null + ) -> images: List + ``` + +## `#!sds fun` toJpegFiles {#safeds.data.image.containers.ImageList.toJpegFiles data-toc-label='toJpegFiles'} + +Save all images as jpeg files. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `path` | `#!sds union, String>` | Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created | - | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="110" + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_jpeg_files") + fun toJpegFiles( + path: union, String> + ) + ``` + +## `#!sds fun` toPngFiles {#safeds.data.image.containers.ImageList.toPngFiles data-toc-label='toPngFiles'} + +Save all images as png files. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `path` | `#!sds union, String>` | Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created | - | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="121" + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_png_files") + fun toPngFiles( + path: union, String> + ) + ``` + +## `#!sds static fun` fromFiles {#safeds.data.image.containers.ImageList.fromFiles data-toc-label='fromFiles'} + +Create an ImageList from a directory or a list of files. + +If you provide a path to a directory the images will be sorted alphabetically while inner directories will be sorted after image files. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `path` | `#!sds union, String>` | the path to the directory or a list of files | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="59" + @Impure([ImpurityReason.FileReadFromParameterizedPath("path")]) + @PythonName("from_files") + static fun fromFiles( + path: union, String> + ) -> imageList: ImageList + ``` + +## `#!sds static fun` fromImages {#safeds.data.image.containers.ImageList.fromImages data-toc-label='fromImages'} + +Create an ImageList from a list of images. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `images` | [`List`][safeds.lang.List] | the list of images | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `imageList` | [`ImageList`][safeds.data.image.containers.ImageList] | the image list | + +??? quote "Stub code in `image_list.sdsstub`" + + ```sds linenums="44" + @Pure + @PythonName("from_images") + static fun fromImages( + images: List + ) -> imageList: ImageList + ``` diff --git a/docs/api/safeds/data/tabular/containers/Table.md b/docs/api/safeds/data/tabular/containers/Table.md index 08d45d983..f98d671d3 100644 --- a/docs/api/safeds/data/tabular/containers/Table.md +++ b/docs/api/safeds/data/tabular/containers/Table.md @@ -5,7 +5,7 @@ A table is a two-dimensional collection of data. It can either be seen as a list To create a `Table` call the constructor or use one of the following static methods: | Method | Description | -| ---------------------------| -------------------------------------- | +| -------------------------- | -------------------------------------- | | [Table.fromCsvFile][safeds.data.tabular.containers.Table.fromCsvFile] | Create a table from a CSV file. | | [Table.fromJsonFile][safeds.data.tabular.containers.Table.fromJsonFile] | Create a table from a JSON file. | | [Table.fromDict][safeds.data.tabular.containers.Table.fromDict] | Create a table from a dictionary. | diff --git a/docs/api/safeds/ml/classical/regression/ArimaRegressor.md b/docs/api/safeds/ml/classical/regression/ArimaRegressor.md new file mode 100644 index 000000000..350548448 --- /dev/null +++ b/docs/api/safeds/ml/classical/regression/ArimaRegressor.md @@ -0,0 +1,153 @@ +# `#!sds class` ArimaRegressor {#safeds.ml.classical.regression.ArimaRegressor data-toc-label='ArimaRegressor'} + +Auto Regressive Integrated Moving Average Model. + +??? quote "Stub code in `arima.sdsstub`" + + ```sds linenums="7" + class ArimaRegressor() { + /** + * Create a copy of this ARIMA Model and fit it with the given training data. + * + * This ARIMA Model is not modified. + * + * @param timeSeries The time series containing the target column, which will be used. + * + * @result fittedArima The fitted ARIMA Model. + */ + @Pure + fun fit( + @PythonName("time_series") timeSeries: TimeSeries + ) -> fittedArima: ArimaRegressor + + /** + * Predict a target vector using a time series target column. The model has to be trained first. + * + * @param timeSeries The test dataset of the time series. + * + * @result timeSeries A timeseries containing the predicted target vector and a time dummy as time column. + */ + @Pure + fun predict( + @PythonName("time_series") timeSeries: TimeSeries + ) -> timeSeries: TimeSeries + + /** + * Plot the predictions of the trained model to the given target of the time series. So you can see the predictions and the actual values in one plot. + * + * @param testSeries The time series containing the target vector. + * + * @result image Plots predictions of the given time series to the given target Column + */ + @Pure + @PythonName("plot_predictions") + fun plotPredictions( + @PythonName("test_series") testSeries: TimeSeries + ) -> image: Image + + /** + * Check if the classifier is fitted. + * + * @result isFitted Whether the regressor is fitted. + */ + @Pure + @PythonName("is_fitted") + fun isFitted() -> isFitted: Boolean + } + ``` + +## `#!sds fun` fit {#safeds.ml.classical.regression.ArimaRegressor.fit data-toc-label='fit'} + +Create a copy of this ARIMA Model and fit it with the given training data. + +This ARIMA Model is not modified. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `timeSeries` | [`TimeSeries`][safeds.data.tabular.containers.TimeSeries] | The time series containing the target column, which will be used. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `fittedArima` | [`ArimaRegressor`][safeds.ml.classical.regression.ArimaRegressor] | The fitted ARIMA Model. | + +??? quote "Stub code in `arima.sdsstub`" + + ```sds linenums="17" + @Pure + fun fit( + @PythonName("time_series") timeSeries: TimeSeries + ) -> fittedArima: ArimaRegressor + ``` + +## `#!sds fun` isFitted {#safeds.ml.classical.regression.ArimaRegressor.isFitted data-toc-label='isFitted'} + +Check if the classifier is fitted. + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `isFitted` | [`Boolean`][safeds.lang.Boolean] | Whether the regressor is fitted. | + +??? quote "Stub code in `arima.sdsstub`" + + ```sds linenums="52" + @Pure + @PythonName("is_fitted") + fun isFitted() -> isFitted: Boolean + ``` + +## `#!sds fun` plotPredictions {#safeds.ml.classical.regression.ArimaRegressor.plotPredictions data-toc-label='plotPredictions'} + +Plot the predictions of the trained model to the given target of the time series. So you can see the predictions and the actual values in one plot. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `testSeries` | [`TimeSeries`][safeds.data.tabular.containers.TimeSeries] | The time series containing the target vector. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `image` | [`Image`][safeds.data.image.containers.Image] | Plots predictions of the given time series to the given target Column | + +??? quote "Stub code in `arima.sdsstub`" + + ```sds linenums="41" + @Pure + @PythonName("plot_predictions") + fun plotPredictions( + @PythonName("test_series") testSeries: TimeSeries + ) -> image: Image + ``` + +## `#!sds fun` predict {#safeds.ml.classical.regression.ArimaRegressor.predict data-toc-label='predict'} + +Predict a target vector using a time series target column. The model has to be trained first. + +**Parameters:** + +| Name | Type | Description | Default | +|------|------|-------------|---------| +| `timeSeries` | [`TimeSeries`][safeds.data.tabular.containers.TimeSeries] | The test dataset of the time series. | - | + +**Results:** + +| Name | Type | Description | +|------|------|-------------| +| `timeSeries` | [`TimeSeries`][safeds.data.tabular.containers.TimeSeries] | A timeseries containing the predicted target vector and a time dummy as time column. | + +??? quote "Stub code in `arima.sdsstub`" + + ```sds linenums="29" + @Pure + fun predict( + @PythonName("time_series") timeSeries: TimeSeries + ) -> timeSeries: TimeSeries + ``` diff --git a/docs/api/safeds/ml/nn/FNNLayer.md b/docs/api/safeds/ml/nn/ForwardLayer.md similarity index 51% rename from docs/api/safeds/ml/nn/FNNLayer.md rename to docs/api/safeds/ml/nn/ForwardLayer.md index 5cd6d0ae7..27888bef9 100644 --- a/docs/api/safeds/ml/nn/FNNLayer.md +++ b/docs/api/safeds/ml/nn/ForwardLayer.md @@ -1,4 +1,6 @@ -# `#!sds class` FNNLayer {#safeds.ml.nn.FNNLayer data-toc-label='FNNLayer'} +# `#!sds class` ForwardLayer {#safeds.ml.nn.ForwardLayer data-toc-label='ForwardLayer'} + +**Parent type:** [`Layer`][safeds.ml.nn.Layer] **Parameters:** @@ -7,21 +9,22 @@ | `outputSize` | [`Int`][safeds.lang.Int] | The number of neurons in this layer | - | | `inputSize` | [`Int?`][safeds.lang.Int] | The number of neurons in the previous layer | `#!sds null` | -??? quote "Stub code in `layer.sdsstub`" +??? quote "Stub code in `forward_layer.sdsstub`" ```sds linenums="7" - class FNNLayer( + class ForwardLayer( @PythonName("output_size") outputSize: Int, @PythonName("input_size") inputSize: Int? = null - ) { - /** - * Get the output_size of this layer. - */ - @PythonName("output_size") attr outputSize: Int - } + ) sub Layer ``` -## `#!sds attr` outputSize {#safeds.ml.nn.FNNLayer.outputSize data-toc-label='outputSize'} +## `#!sds attr` inputSize {#safeds.ml.nn.ForwardLayer.inputSize data-toc-label='inputSize'} + +Get the input_size of this layer. + +**Type:** [`Int`][safeds.lang.Int] + +## `#!sds attr` outputSize {#safeds.ml.nn.ForwardLayer.outputSize data-toc-label='outputSize'} Get the output_size of this layer. diff --git a/docs/api/safeds/ml/nn/Layer.md b/docs/api/safeds/ml/nn/Layer.md new file mode 100644 index 000000000..abe47ae81 --- /dev/null +++ b/docs/api/safeds/ml/nn/Layer.md @@ -0,0 +1,37 @@ +--- +search: + boost: 0.5 +--- + +# `#!sds abstract class` Layer {#safeds.ml.nn.Layer data-toc-label='Layer'} + +**Inheritors:** + +- [`ForwardLayer`][safeds.ml.nn.ForwardLayer] + +??? quote "Stub code in `_layer.sdsstub`" + + ```sds linenums="3" + class Layer { + /** + * Get the input_size of this layer. + */ + @PythonName("input_size") attr inputSize: Int + /** + * Get the output_size of this layer. + */ + @PythonName("output_size") attr outputSize: Int + } + ``` + +## `#!sds attr` inputSize {#safeds.ml.nn.Layer.inputSize data-toc-label='inputSize'} + +Get the input_size of this layer. + +**Type:** [`Int`][safeds.lang.Int] + +## `#!sds attr` outputSize {#safeds.ml.nn.Layer.outputSize data-toc-label='outputSize'} + +Get the output_size of this layer. + +**Type:** [`Int`][safeds.lang.Int] diff --git a/docs/api/safeds/ml/nn/NeuralNetworkClassifier.md b/docs/api/safeds/ml/nn/NeuralNetworkClassifier.md index 24c87826f..a70ef3532 100644 --- a/docs/api/safeds/ml/nn/NeuralNetworkClassifier.md +++ b/docs/api/safeds/ml/nn/NeuralNetworkClassifier.md @@ -4,13 +4,13 @@ | Name | Type | Description | Default | |------|------|-------------|---------| -| `layers` | [`List`][safeds.lang.List] | - | - | +| `layers` | [`List`][safeds.lang.List] | - | - | ??? quote "Stub code in `classifier.sdsstub`" ```sds linenums="6" class NeuralNetworkClassifier( - layers: List + layers: List ) { /** * Check if the model is fitted. @@ -25,6 +25,7 @@ * @param trainData The data the network should be trained on. * @param epochSize The number of times the training cycle should be done. * @param batchSize The size of data batches that should be loaded at one time. + * @param learningRate The learning rate of the neural network. * @param callbackOnBatchCompletion Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. * @param callbackOnEpochCompletion Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. * @@ -35,6 +36,7 @@ @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> fittedClassifier: NeuralNetworkClassifier where { @@ -77,6 +79,7 @@ The original model is not modified. | `trainData` | [`TaggedTable`][safeds.data.tabular.containers.TaggedTable] | The data the network should be trained on. | - | | `epochSize` | [`Int`][safeds.lang.Int] | The number of times the training cycle should be done. | `#!sds 25` | | `batchSize` | [`Int`][safeds.lang.Int] | The size of data batches that should be loaded at one time. | `#!sds 1` | +| `learningRate` | [`Float`][safeds.lang.Float] | The learning rate of the neural network. | `#!sds 0.001` | | `callbackOnBatchCompletion` | `#!sds (param1: Int, param2: Float) -> ()` | Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. | `#!sds (param1, param2) {}` | | `callbackOnEpochCompletion` | `#!sds (param1: Int, param2: Float) -> ()` | Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. | `#!sds (param1, param2) {}` | @@ -88,12 +91,13 @@ The original model is not modified. ??? quote "Stub code in `classifier.sdsstub`" - ```sds linenums="27" + ```sds linenums="28" @Pure fun fit( @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> fittedClassifier: NeuralNetworkClassifier where { @@ -122,7 +126,7 @@ The original Model is not modified. ??? quote "Stub code in `classifier.sdsstub`" - ```sds linenums="48" + ```sds linenums="50" @Pure fun predict( @PythonName("test_data") testData: Table diff --git a/docs/api/safeds/ml/nn/NeuralNetworkRegressor.md b/docs/api/safeds/ml/nn/NeuralNetworkRegressor.md index a923f1097..eb59b7a00 100644 --- a/docs/api/safeds/ml/nn/NeuralNetworkRegressor.md +++ b/docs/api/safeds/ml/nn/NeuralNetworkRegressor.md @@ -4,13 +4,13 @@ | Name | Type | Description | Default | |------|------|-------------|---------| -| `layers` | [`List`][safeds.lang.List] | - | - | +| `layers` | [`List`][safeds.lang.List] | - | - | ??? quote "Stub code in `regressor.sdsstub`" ```sds linenums="6" class NeuralNetworkRegressor( - layers: List + layers: List ) { /** * Check if the model is fitted. @@ -25,6 +25,7 @@ * @param trainData The data the network should be trained on. * @param epochSize The number of times the training cycle should be done. * @param batchSize The size of data batches that should be loaded at one time. + * @param learningRate The learning rate of the neural network. * @param callbackOnBatchCompletion Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. * @param callbackOnEpochCompletion Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. * @@ -35,6 +36,7 @@ @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> trainedRegressor: NeuralNetworkRegressor where { @@ -77,6 +79,7 @@ The original model is not modified. | `trainData` | [`TaggedTable`][safeds.data.tabular.containers.TaggedTable] | The data the network should be trained on. | - | | `epochSize` | [`Int`][safeds.lang.Int] | The number of times the training cycle should be done. | `#!sds 25` | | `batchSize` | [`Int`][safeds.lang.Int] | The size of data batches that should be loaded at one time. | `#!sds 1` | +| `learningRate` | [`Float`][safeds.lang.Float] | The learning rate of the neural network. | `#!sds 0.001` | | `callbackOnBatchCompletion` | `#!sds (param1: Int, param2: Float) -> ()` | Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. | `#!sds (param1, param2) {}` | | `callbackOnEpochCompletion` | `#!sds (param1: Int, param2: Float) -> ()` | Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. | `#!sds (param1, param2) {}` | @@ -88,12 +91,13 @@ The original model is not modified. ??? quote "Stub code in `regressor.sdsstub`" - ```sds linenums="27" + ```sds linenums="28" @Pure fun fit( @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> trainedRegressor: NeuralNetworkRegressor where { @@ -122,7 +126,7 @@ The original Model is not modified. ??? quote "Stub code in `regressor.sdsstub`" - ```sds linenums="48" + ```sds linenums="50" @Pure fun predict( @PythonName("test_data") testData: Table diff --git a/package.json b/package.json index 11181140e..32bb351e9 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "watch": "concurrently -n tsc,cli,lang,vscode,eda -c blue,yellow,red,green \"tsc -b tsconfig.json\" \"npm run watch -w=@safe-ds/cli\" \"npm run watch -w=@safe-ds/lang\" \"npm run watch -w=safe-ds\" \"npm run watch -w=@safe-ds/eda\"", "test": "vitest", "test-with-coverage": "vitest --coverage", - "docs:api": "safe-ds document packages/safe-ds-lang/src/resources/builtins -o docs/api" + "docs:api": "shx rm -rf dist docs/api && safe-ds document packages/safe-ds-lang/src/resources/builtins -o docs/api" }, "devDependencies": { "@lars-reimann/eslint-config-svelte": "^7.0.0", diff --git a/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts b/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts index eb429716f..4c64394bf 100644 --- a/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts +++ b/packages/safe-ds-lang/src/language/runner/safe-ds-runner.ts @@ -27,8 +27,8 @@ export const RPC_RUNNER_START = 'runner/start'; export const RPC_RUNNER_STARTED = 'runner/started'; export const RPC_RUNNER_UPDATE = 'runner/update'; -const LOWEST_SUPPORTED_RUNNER_VERSION = '0.10.0'; -const LOWEST_UNSUPPORTED_RUNNER_VERSION = '0.11.0'; +const LOWEST_SUPPORTED_RUNNER_VERSION = '0.11.0'; +const LOWEST_UNSUPPORTED_RUNNER_VERSION = '0.12.0'; const npmVersionRange = `>=${LOWEST_SUPPORTED_RUNNER_VERSION} <${LOWEST_UNSUPPORTED_RUNNER_VERSION}`; export const pipVersionRange = `>=${LOWEST_SUPPORTED_RUNNER_VERSION},<${LOWEST_UNSUPPORTED_RUNNER_VERSION}`; diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image.sdsstub index 2309efd01..0acb0f43a 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image.sdsstub @@ -53,6 +53,21 @@ class Image { path: String ) + /** + * Return a new `Image` that has the given number of channels. + * + * The original image is not modified. + * + * @param channel The new number of channels. 1 will result in a grayscale image. + * + * @result result1 The image with the given number of channels. + */ + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> result1: Image + /** * Return a new `Image` that has been resized to a given size. * diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image_list.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image_list.sdsstub new file mode 100644 index 000000000..4cd0f0967 --- /dev/null +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/image/containers/image_list.sdsstub @@ -0,0 +1,509 @@ +package safeds.data.image.containers + +from safeds.data.image.containers import Image + +/** + * An ImageList is a list of different images. It can hold different sizes of Images. The channel of all images is the same. + * + * To create an `ImageList` call one of the following static methods: + * + * | Method | Description | + * | ---------------------------- | -------------------------------------------------------- | + * | {@link ImageList.fromImages} | Create an ImageList from a list of Images. | + * | {@link ImageList.fromFiles} | Create an ImageList from a directory or a list of files. | + */ +class ImageList { + /** + * Return the number of images in this image list. + */ + @PythonName("number_of_images") attr numberOfImages: Int + /** + * Return a list of all widths in this image list. + */ + attr widths: List + /** + * Return a list of all heights in this image list. + */ + attr heights: List + /** + * Return the channel of all images. + */ + attr channel: Int + /** + * Return the number of different sizes of images in this image list. + */ + @PythonName("number_of_sizes") attr numberOfSizes: Int + + /** + * Create an ImageList from a list of images. + * + * @param images the list of images + * + * @result imageList the image list + */ + @Pure + @PythonName("from_images") + static fun fromImages( + images: List + ) -> imageList: ImageList + + /** + * Create an ImageList from a directory or a list of files. + * + * If you provide a path to a directory the images will be sorted alphabetically while inner directories will be sorted after image files. + * + * @param path the path to the directory or a list of files + * + * @result imageList the image list + */ + @Impure([ImpurityReason.FileReadFromParameterizedPath("path")]) + @PythonName("from_files") + static fun fromFiles( + path: union, String> + ) -> imageList: ImageList + + /** + * Return the image at the given index. + * + * @param index the index for the image to return + * + * @result image the image at the given index + */ + @Pure + @PythonName("get_image") + fun getImage( + index: Int + ) -> image: Image + + /** + * Return a list of indexes of the given image. + * + * If the image has multiple occurrences, all indices will be returned + * + * @param image the image to search for occurrences + * + * @result indices all occurrences of the image + */ + @Pure + fun index( + image: Image + ) -> indices: List + + /** + * Return whether the given image is in this image list. + * + * @param image the image to check + * + * @result hasImage Weather the given image is in this image list + */ + @Pure + @PythonName("has_image") + fun hasImage( + image: Image + ) -> hasImage: Boolean + + /** + * Save all images as jpeg files. + * + * @param path Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created + */ + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_jpeg_files") + fun toJpegFiles( + path: union, String> + ) + + /** + * Save all images as png files. + * + * @param path Either the path to a directory or a list of directories which has directories for either all different sizes or all different images. Any non-existant path will be created + */ + @Impure([ImpurityReason.FileWriteToParameterizedPath("path")]) + @PythonName("to_png_files") + fun toPngFiles( + path: union, String> + ) + + /** + * Return a list of all images in this image list. + * + * @param indices a list of all indices to include in the output. If None, all indices will be included + * + * @result images the list of all images + */ + @Pure + @PythonName("to_images") + fun toImages( + indices: List? = null + ) -> images: List + + /** + * Return a new `ImageList` that has the given number of channels. + * + * The original image list is not modified. + * + * @param channel The new number of channels. 1 will result in grayscale images + * + * @result imageList the image list with the given number of channels + */ + @Pure + @PythonName("change_channel") + fun changeChannel( + channel: Int + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given image added to the image list. + * + * The original image list is not modified. + * + * @param image The image to be added to the image list + * + * @result imageList the image list with the new image added + */ + @Pure + @PythonName("add_image") + fun addImage( + image: Image + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given images added to the image list. + * + * The original image list is not modified. + * + * @param images The images to be added to the image list + * + * @result imageList the image list with the new images added + */ + @Pure + @PythonName("add_images") + fun addImages( + images: union> + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given image removed from the image list. + * + * If the image has multiple occurrences, all occurrences will be removed. + * + * The original image list is not modified. + * + * @param image The image to be removed from the image list + * + * @result imageList the image list with the given image removed + */ + @Pure + @PythonName("remove_image") + fun removeImage( + image: Image + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given images removed from the image list. + * + * If one image has multiple occurrences, all occurrences will be removed. + * + * The original image list is not modified. + * + * @param images The images to be removed from the image list + * + * @result imageList the image list with the given images removed + */ + @Pure + @PythonName("remove_images") + fun removeImages( + images: List + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the given indices removed from the image list. + * + * The original image list is not modified. + * + * @param index The index of the image to be removed from the image list + * + * @result imageList the image list with the without the removed image + */ + @Pure + @PythonName("remove_image_by_index") + fun removeImageByIndex( + index: union> + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with the all images of the given size removed. + * + * The original image list is not modified. + * + * @param width The width of the images to be removed from the image list + * @param height The height of the images to be removed from the image list + * + * @result imageList the image list with the given images removed + */ + @Pure + @PythonName("remove_images_with_size") + fun removeImagesWithSize( + width: Int, + height: Int + ) -> imageList: ImageList + + /** + * Return a new `ImageList` with all duplicate images removed. + * + * One occurrence of each image will stay in the image list. + * + * The original image list is not modified. + * + * @result imageList the image list with only unique images + */ + @Pure + @PythonName("remove_duplicate_images") + fun removeDuplicateImages() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images shuffled. + * + * The original image list is not modified. + * + * @result imageList the image list with shuffled images + */ + @Pure + @PythonName("shuffle_images") + fun shuffleImages() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images resized to a given size. + * + * The original image list is not modified. + * + * @param newWidth the new width of the images + * @param newHeight the new height of the images + * + * @result imageList The image list with all images resized to the given width and height. + */ + @Pure + fun resize( + @PythonName("new_width") const newWidth: Int, + @PythonName("new_height") const newHeight: Int + ) -> imageList: ImageList where { + newWidth >= 0, + newHeight >= 0 + } + + /** + * Return a new `ImageList` with all images converted to grayscale. + * + * The original image list is not modified. + * + * @result imageList The image list with all images converted to grayscale. + */ + @Pure + @PythonName("convert_to_grayscale") + fun convertToGrayscale() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images cropped to a given bounding rectangle. + * + * The original image list is not modified. + * + * @param x the x coordinate of the top-left corner of the bounding rectangle + * @param y the y coordinate of the top-left corner of the bounding rectangle + * @param width the width of the bounding rectangle + * @param height the height of the bounding rectangle + * + * @result imageList The image list with all images cropped + */ + @Pure + fun crop( + const x: Int, + const y: Int, + const width: Int, + const height: Int + ) -> imageList: ImageList where { + x >= 0, + y >= 0, + width >= 0, + height >= 0 + } + + /** + * Return a new `ImageList` with all images flipped vertically (horizontal axis, flips up-down and vice versa). + * + * The original image list is not modified. + * + * @result imageList The image list with all images flipped vertically + */ + @Pure + @PythonName("flip_vertically") + fun flipVertically() -> imageList: ImageList + + /** + * Return a new `ImageList` with all images flipped horizontally (vertical axis, flips left-right and vice versa). + * + * The original image list is not modified. + * + * @result imageList The image list with all images flipped horizontally + */ + @Pure + @PythonName("flip_horizontally") + fun flipHorizontally() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have the adjusted brightness. + * + * The original image list is not modified. + * + * @param factor The brightness factor. + * 1.0 will not change the brightness. + * Below 1.0 will result in a darker images. + * Above 1.0 will resolut in a brighter images. + * Has to be bigger than or equal to 0 (black). + * + * @result imageList The image list with adjusted brightness + */ + @Pure + @PythonName("adjust_brightness") + fun adjustBrightness( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` with noise added to all images. + * + * The original image list is not modified. + * + * @param standardDeviation The standard deviation of the normal distribution. Has to be bigger than or equal to 0. + * + * @result imageList The image list with added noise + */ + @Pure + @PythonName("add_noise") + fun addNoise( + @PythonName("standard_deviation") const standardDeviation: Float + ) -> imageList: ImageList where { + standardDeviation >= 0.0 + } + + /** + * Return a new `ImageList` where all images have the adjusted contrast. + * + * The original image list is not modified. + * + * @param factor If factor > 1, increase contrast of images. + * If factor = 1, no changes will be made. + * If factor < 1, make images greyer. + * Has to be bigger than or equal to 0 (gray). + * + * @result imageList The image list with adjusted contrast + */ + @Pure + @PythonName("adjust_contrast") + fun adjustContrast( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have the adjusted color balance. + * + * The original image list is not modified. + * + * @param factor Has to be bigger than or equal to 0. + * If 0 <= factor < 1, make images greyer. + * If factor = 1, no changes will be made. + * If factor > 1, increase color balance of images. + * + * @result imageList The image list with adjusted color balance + */ + @Pure + @PythonName("adjust_color_balance") + fun adjustColorBalance( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have been blurred. + * + * The original image list is not modified. + * + * @param radius Radius is directly proportional to the blur value. The radius is equal to the amount of pixels united in + * each direction. A radius of 1 will result in a united box of 9 pixels. + * + * @result imageList The image list with blurred images + */ + @Pure + fun blur( + const radius: Int + ) -> imageList: ImageList where { + radius >= 0 + } + + /** + * Return a new `ImageList` where all images have been sharpened. + * + * The original image list is not modified. + * + * @param factor If factor > 1, increase the sharpness of the images. + * If factor = 1, no changes will be made. + * If factor < 1, blur the images. + * Has to be bigger than or equal to 0 (blurred). + * + * @result imageList The image list with sharpened images + */ + @Pure + fun sharpen( + const factor: Float + ) -> imageList: ImageList where { + factor >= 0.0 + } + + /** + * Return a new `ImageList` where all images have their colors inverted. + * + * The original image list is not modified. + * + * @result imageList The image list with inverted colors + */ + @Pure + @PythonName("invert_colors") + fun invertColors() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have been rotated 90 degrees clockwise. + * + * The original image list is not modified. + * + * @result imageList The image list with all images rotated + */ + @Pure + @PythonName("rotate_right") + fun rotateRight() -> imageList: ImageList + + /** + * Return a new `ImageList` where all images have been rotated 90 degrees counter-clockwise. + * + * The original image list is not modified. + * + * @result imageList The image list with all images rotated + */ + @Pure + @PythonName("rotate_left") + fun rotateLeft() -> imageList: ImageList + + /** + * Return a new `ImageList` with grayscale versions of the images with the edges highlighted. + * + * The original image list is not modified. + * + * @result imageList The image list with highlighted edges + */ + @Pure + @PythonName("find_edges") + fun findEdges() -> imageList: ImageList +} diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/table.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/table.sdsstub index 0027400c3..e54bdaf32 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/table.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/data/tabular/containers/table.sdsstub @@ -11,7 +11,7 @@ from safeds.data.tabular.typing import ColumnType, Schema * To create a `Table` call the constructor or use one of the following static methods: * * | Method | Description | - * | ---------------------------| -------------------------------------- | + * | -------------------------- | -------------------------------------- | * | {@link Table.fromCsvFile} | Create a table from a CSV file. | * | {@link Table.fromJsonFile} | Create a table from a JSON file. | * | {@link Table.fromDict} | Create a table from a dictionary. | diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/classical/regression/arima.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/classical/regression/arima.sdsstub new file mode 100644 index 000000000..2480b5a26 --- /dev/null +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/classical/regression/arima.sdsstub @@ -0,0 +1,55 @@ +package safeds.ml.classical.regression + +/** + * Auto Regressive Integrated Moving Average Model. + */ + @PythonName("ArimaModelRegressor") +class ArimaRegressor() { + /** + * Create a copy of this ARIMA Model and fit it with the given training data. + * + * This ARIMA Model is not modified. + * + * @param timeSeries The time series containing the target column, which will be used. + * + * @result fittedArima The fitted ARIMA Model. + */ + @Pure + fun fit( + @PythonName("time_series") timeSeries: TimeSeries + ) -> fittedArima: ArimaRegressor + + /** + * Predict a target vector using a time series target column. The model has to be trained first. + * + * @param timeSeries The test dataset of the time series. + * + * @result timeSeries A timeseries containing the predicted target vector and a time dummy as time column. + */ + @Pure + fun predict( + @PythonName("time_series") timeSeries: TimeSeries + ) -> timeSeries: TimeSeries + + /** + * Plot the predictions of the trained model to the given target of the time series. So you can see the predictions and the actual values in one plot. + * + * @param testSeries The time series containing the target vector. + * + * @result image Plots predictions of the given time series to the given target Column + */ + @Pure + @PythonName("plot_predictions") + fun plotPredictions( + @PythonName("test_series") testSeries: TimeSeries + ) -> image: Image + + /** + * Check if the classifier is fitted. + * + * @result isFitted Whether the regressor is fitted. + */ + @Pure + @PythonName("is_fitted") + fun isFitted() -> isFitted: Boolean +} diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/_layer.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/_layer.sdsstub new file mode 100644 index 000000000..09460d245 --- /dev/null +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/_layer.sdsstub @@ -0,0 +1,12 @@ +package safeds.ml.nn + +class Layer { + /** + * Get the input_size of this layer. + */ + @PythonName("input_size") attr inputSize: Int + /** + * Get the output_size of this layer. + */ + @PythonName("output_size") attr outputSize: Int +} diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/classifier.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/classifier.sdsstub index 6eeeb73b7..3008703b9 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/classifier.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/classifier.sdsstub @@ -1,10 +1,10 @@ package safeds.ml.nn from safeds.data.tabular.containers import Table, TaggedTable -from safeds.ml.nn import FNNLayer +from safeds.ml.nn import Layer class NeuralNetworkClassifier( - layers: List + layers: List ) { /** * Check if the model is fitted. @@ -19,6 +19,7 @@ class NeuralNetworkClassifier( * @param trainData The data the network should be trained on. * @param epochSize The number of times the training cycle should be done. * @param batchSize The size of data batches that should be loaded at one time. + * @param learningRate The learning rate of the neural network. * @param callbackOnBatchCompletion Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. * @param callbackOnEpochCompletion Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. * @@ -29,6 +30,7 @@ class NeuralNetworkClassifier( @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> fittedClassifier: NeuralNetworkClassifier where { diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/layer.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/forward_layer.sdsstub similarity index 65% rename from packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/layer.sdsstub rename to packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/forward_layer.sdsstub index dff9e8e6e..eb2aaacd3 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/layer.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/forward_layer.sdsstub @@ -4,12 +4,7 @@ package safeds.ml.nn * @param outputSize The number of neurons in this layer * @param inputSize The number of neurons in the previous layer */ -class FNNLayer( +class ForwardLayer( @PythonName("output_size") outputSize: Int, @PythonName("input_size") inputSize: Int? = null -) { - /** - * Get the output_size of this layer. - */ - @PythonName("output_size") attr outputSize: Int -} +) sub Layer diff --git a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/regressor.sdsstub b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/regressor.sdsstub index 2df191f69..6f82163eb 100644 --- a/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/regressor.sdsstub +++ b/packages/safe-ds-lang/src/resources/builtins/safeds/ml/nn/regressor.sdsstub @@ -1,10 +1,10 @@ package safeds.ml.nn from safeds.data.tabular.containers import Table, TaggedTable -from safeds.ml.nn import FNNLayer +from safeds.ml.nn import Layer class NeuralNetworkRegressor( - layers: List + layers: List ) { /** * Check if the model is fitted. @@ -19,6 +19,7 @@ class NeuralNetworkRegressor( * @param trainData The data the network should be trained on. * @param epochSize The number of times the training cycle should be done. * @param batchSize The size of data batches that should be loaded at one time. + * @param learningRate The learning rate of the neural network. * @param callbackOnBatchCompletion Function used to view metrics while training. Gets called after a batch is completed with the index of the last batch and the overall loss average. * @param callbackOnEpochCompletion Function used to view metrics while training. Gets called after an epoch is completed with the index of the last epoch and the overall loss average. * @@ -29,6 +30,7 @@ class NeuralNetworkRegressor( @PythonName("train_data") trainData: TaggedTable, @PythonName("epoch_size") const epochSize: Int = 25, @PythonName("batch_size") const batchSize: Int = 1, + @PythonName("learning_rate") learningRate: Float = 0.001, @PythonName("callback_on_batch_completion") callbackOnBatchCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {}, @PythonName("callback_on_epoch_completion") callbackOnEpochCompletion: (param1: Int, param2: Float) -> () = (param1, param2) {} ) -> trainedRegressor: NeuralNetworkRegressor where {