Skip to content

Commit d44a2ec

Browse files
authored
Merge pull request #1832 from Kotlin/titanic-example
moving titanic example to examples/projects and enabling compiler plugin
2 parents 38956ba + 3c96b9b commit d44a2ec

29 files changed

Lines changed: 4485 additions & 64 deletions

File tree

build-logic/src/main/kotlin/dfbuild.buildExampleProjects.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ val versionsToSync =
3030
"kotlinDatetime",
3131
"log4j",
3232
"spark4",
33+
"kotlin-dl",
3334
)
3435

3536
val syncAllExampleFolders by tasks.registering {

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* [android example](projects/android-example) A minimal Android project showcasing integration with Kotlin DataFrame.
99
Also includes [Kotlin DataFrame Compiler Plugin](https://kotlin.github.io/dataframe/compiler-plugin.html).
1010
* [movies](projects/movies) Using extension properties [Access API](https://kotlin.github.io/dataframe/apilevels.html) to perform a data cleaning task
11-
* [titanic](idea-examples/titanic)
11+
* [titanic](projects/titanic)
1212
* [youtube](projects/youtube)
1313
* [json](idea-examples/json) Using OpenAPI support in DataFrame's Gradle and KSP plugins to access data from [API guru](https://apis.guru/) in a type-safe manner
1414
* [imdb sql database](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples) This project prominently showcases how to convert data from an SQL table to a Kotlin DataFrame

examples/idea-examples/titanic/build.gradle.kts

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
max_line_length = 120
10+
11+
[*.json]
12+
indent_size = 2
13+
14+
[{*.yaml,*.yml}]
15+
indent_size = 2
16+
17+
[*.ipynb]
18+
insert_final_newline = false
19+
20+
[*.{kt,kts}]
21+
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
22+
23+
# Disable wildcard imports entirely
24+
ij_kotlin_name_count_to_use_star_import = 2147483647
25+
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
26+
ij_kotlin_packages_to_use_import_on_demand = unset
27+
28+
ktlint_code_style = ktlint_official
29+
ktlint_experimental = enabled
30+
ktlint_standard_filename = disabled
31+
ktlint_standard_no-empty-first-line-in-class-body = disabled
32+
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 4
33+
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 4
34+
ktlint_standard_chain-method-continuation = disabled
35+
ktlint_ignore_back_ticked_identifier = true
36+
ktlint_standard_multiline-expression-wrapping = disabled
37+
ktlint_standard_when-entry-bracing = disabled
38+
ktlint_standard_expression-operand-wrapping = disabled
39+
40+
[{*/build/**/*,**/*keywords*/**,**/*.Generated.kt,**/*$Extensions.kt,**/BuildConfig.kt}]
41+
ktlint = disabled
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Titanic Example
2+
3+
This is an example project for using DataFrame and [KotlinDL](https://github.com/Kotlin/kotlindl).
4+
(While said library has become slightly outdated,
5+
this example still showcases the power of DataFrame in combination with deep-learning techniques.)
6+
7+
This project uses the
8+
[Kotlin DataFrame Compiler Plugin](https://kotlin.github.io/dataframe/compiler-plugin.html).
9+
10+
We recommend using an up-to-date IntelliJ IDEA for the best experience,
11+
as well as the latest Kotlin plugin version.
12+
13+
> [!WARNING]
14+
> For proper functionality in IntelliJ IDEA requires version 2025.2 or newer.
15+
16+
[Download this Example](https://github.com/Kotlin/dataframe/raw/example-projects-archives/titanic.zip)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.kotlin.dataframe)
4+
alias(libs.plugins.ktlint.gradle)
5+
6+
application
7+
}
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
application.mainClass = "org.jetbrains.kotlinx.dataframe.examples.titanic.ml.TitanicKt"
14+
15+
dependencies {
16+
// Add general `dataframe` dependency
17+
implementation(libs.dataframe)
18+
19+
// note: needs to target java 11 for these dependencies
20+
implementation(libs.kotlin.dl.api)
21+
implementation(libs.kotlin.dl.impl)
22+
implementation(libs.kotlin.dl.tensorflow)
23+
implementation(libs.kotlin.dl.dataset)
24+
}
25+
26+
tasks.test {
27+
useJUnitPlatform()
28+
}
29+
kotlin {
30+
jvmToolchain(11)
31+
}
32+
33+
ktlint {
34+
version = libs.versions.ktlint.asProvider()
35+
// rules are set up through .editorconfig
36+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
org.gradle.jvmargs=-Xmx1g -Dfile.encoding=UTF-8
2+
kotlin.code.style=official
3+
# Disabling incremental compilation will no longer be necessary
4+
# when https://youtrack.jetbrains.com/issue/KT-66735 is resolved.
5+
kotlin.incremental=false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[versions]
2+
kotlin = "2.3.21"
3+
dataframe = "1.0.0-Beta5"
4+
ktlint-gradle = "14.0.1"
5+
ktlint = "1.8.0"
6+
kotlin-dl = "0.5.2"
7+
8+
[libraries]
9+
dataframe = { module = "org.jetbrains.kotlinx:dataframe", version.ref = "dataframe" }
10+
kotlin-dl-api = { module = "org.jetbrains.kotlinx:kotlin-deeplearning-api", version.ref = "kotlin-dl" }
11+
kotlin-dl-impl = { module = "org.jetbrains.kotlinx:kotlin-deeplearning-impl", version.ref = "kotlin-dl" }
12+
kotlin-dl-tensorflow = { module = "org.jetbrains.kotlinx:kotlin-deeplearning-tensorflow", version.ref = "kotlin-dl" }
13+
kotlin-dl-dataset = { module = "org.jetbrains.kotlinx:kotlin-deeplearning-dataset", version.ref = "kotlin-dl" }
14+
15+
[plugins]
16+
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
17+
ktlint-gradle = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-gradle" }
18+
19+
20+
# The Kotlin DataFrame Compiler plugin is the same version as the Kotlin plugin.
21+
kotlin-dataframe = { id = "org.jetbrains.kotlin.plugin.dataframe", version.ref = "kotlin" }
57.8 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)