.titanic-page * { box-sizing: border-box; }
.titanic-page h1, .titanic-page h2, .titanic-page h3, .titanic-page h4, .titanic-page h5, .titanic-page h6, .titanic-page p, .titanic-page ul, .titanic-page ol, .titanic-page li, .titanic-page pre, .titanic-page blockquote, .titanic-page table, .titanic-page td, .titanic-page th { margin: 0; padding: 0; }
.titanic-page {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: var(--el-text-color-primary);
background: var(--el-bg-color);
line-height: 1.6;
}
.titanic-page a { text-decoration: none; color: inherit; }
.titanic-page a:hover { text-decoration: none; }
.titanic-page ul { list-style: none; }
.markdown-body .titanic-page a { color: inherit !important; text-decoration: none !important; }
.markdown-body .titanic-page a:hover { text-decoration: none !important; }
.markdown-body .titanic-page a.s-btn-primary,
.markdown-body .titanic-page a.btn-cta-light { color: #ffffff !important; }
.markdown-body .titanic-page a.s-btn-secondary { color: var(--el-text-color-primary) !important; }
.markdown-body .titanic-page a.btn-cta-ghost { color: #94a3b8 !important; }
.markdown-body .titanic-page a.btn-cta-ghost:hover { color: #e2e8f0 !important; }
.markdown-body .titanic-page h1, .markdown-body .titanic-page h2 { border-bottom: none !important; padding-bottom: 0 !important; }
.titanic-page .s-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.titanic-page .s-container-narrow { max-width: 800px; margin: 0 auto; padding: 0 24px; }
.titanic-page .s-container-wide { max-width: 1100px; margin: 0 auto; padding: 0 32px; }
.titanic-page .s-section { padding: 80px 0; }
.titanic-page .s-section-lg { padding: 100px 0; }
.titanic-page .s-section-sm { padding: 48px 0; }
.titanic-page .s-bg-white { background: var(--el-bg-color); }
.titanic-page .s-bg-gray { background: var(--el-bg-color-page); }
.titanic-page .s-bg-dark { background: #0f172a; color: #f8fafc; }
.titanic-page .s-header { text-align: center; margin-bottom: 64px; }
.titanic-page .s-header h2 {
font-size: clamp(28px, 4vw, 40px);
font-weight: 700;
color: var(--el-text-color-primary);
letter-spacing: normal;
margin-bottom: 20px;
line-height: 1.15;
}
.titanic-page .s-header p {
font-size: clamp(16px, 2vw, 18px);
color: var(--el-text-color-regular);
max-width: 640px;
margin: 0 auto;
line-height: 1.6;
}
.titanic-page .s-bg-dark .s-header h2 { color: #f8fafc; }
.titanic-page .s-bg-dark .s-header p { color: var(--el-text-color-secondary); }
.titanic-page .s-btn-primary {
display: inline-flex; align-items: center; gap: 6px;
padding: 14px 28px;
background: #1e40af; color: #ffffff !important;
border-radius: 9999px; font-size: 15px; font-weight: 600;
transition: background 0.2s, transform 0.15s;
border: none; cursor: pointer;
text-decoration: none !important;
}
.titanic-page .s-btn-primary:hover { background: #1e3a8a; transform: translateY(-1px); text-decoration: none !important; }
.titanic-page .s-btn-secondary {
display: inline-flex; align-items: center; gap: 6px;
padding: 14px 28px;
background: var(--el-bg-color); color: var(--el-text-color-primary) !important;
border: 1px solid var(--el-border-color-light);
border-radius: 9999px; font-size: 15px; font-weight: 600;
transition: border-color 0.2s, background 0.2s;
cursor: pointer;
text-decoration: none !important;
}
.titanic-page .s-btn-secondary:hover { background: var(--el-bg-color-page); text-decoration: none !important; }
.titanic-hero {
padding: 100px 0 80px;
text-align: center;
background: var(--el-bg-color);
position: relative;
overflow: hidden;
}
.titanic-hero::before {
content: '';
position: absolute;
top: -200px; left: 50%;
transform: translateX(-50%);
width: 900px; height: 500px;
background: radial-gradient(ellipse, rgba(30, 64, 175, 0.06) 0%, transparent 70%);
pointer-events: none;
}
.titanic-page .hero-badge {
display: inline-flex; align-items: center; gap: 8px;
padding: 6px 16px;
background: var(--el-bg-color-page); border: 1px solid var(--el-border-color-light);
border-radius: 9999px; font-size: 13px; font-weight: 600; color: var(--el-text-color-regular);
margin-bottom: 28px;
}
.titanic-page .hero-badge .badge-dot {
width: 6px; height: 6px; background: #10b981; border-radius: 50%;
display: inline-block;
}
.titanic-hero h1 {
font-size: clamp(36px, 5vw, 60px);
font-weight: 700; line-height: 1.05;
letter-spacing: normal; color: var(--el-text-color-primary);
margin-bottom: 20px;
position: relative;
}
.titanic-hero h1 span { color: #1e40af; }
.titanic-page .hero-subtitle {
font-size: clamp(16px, 2vw, 20px);
color: var(--el-text-color-regular); line-height: 1.6;
max-width: 620px; margin: 0 auto 56px;
position: relative;
}
.titanic-page .hero-actions {
display: flex; gap: 12px; justify-content: center;
flex-wrap: wrap; margin-bottom: 56px; position: relative;
}
.titanic-page .hero-highlights {
display: flex; align-items: center; justify-content: center;
gap: 16px; flex-wrap: wrap; position: relative;
}
.titanic-page .hero-highlights .h-item { font-size: 14px; color: var(--el-text-color-regular); font-weight: 500; }
.titanic-page .hero-highlights .h-div { width: 1px; height: 16px; background: var(--el-border-color-light); }
.titanic-page .hero-cover {
max-width: 480px; margin: 0 auto 40px; border-radius: 16px;
overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.10);
}
.titanic-page .hero-cover img {
width: 100%; height: auto; display: block;
}
@media (max-width: 640px) 

{ .titanic-page .hero-highlights .h-div { display: none; } .titanic-page .hero-highlights { gap: 8px 16px; } .titanic-page .hero-actions { flex-direction: column; align-items: center; } .titanic-page .hero-actions a { width: 100%; max-width: 280px; justify-content: center; } } .titanic-stats { padding: 48px 0; background: var(--el-bg-color-page); border-top: 1px solid var(--el-border-color-lighter); border-bottom: 1px solid var(--el-border-color-lighter); } .titanic-page .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; text-align: center; } .titanic-page .stat-icon { font-size: 28px; margin-bottom: 12px; } .titanic-page .stat-val { font-size: clamp(28px, 4vw, 40px); font-weight: 700; color: var(--el-text-color-primary); letter-spacing: normal; margin-bottom: 4px; } .titanic-page .stat-lbl { font-size: 14px; color: var(--el-text-color-secondary); font-weight: 500; } @media (max-width: 768px) { .titanic-page .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; } } @media (max-width: 480px) { .titanic-page .stats-grid { grid-template-columns: 1fr; gap: 20px; } } .titanic-page .features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; } .titanic-page .feat-card { padding: 32px 28px; border: none; border-radius: 20px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.08); background: var(--el-bg-color); transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s; } .titanic-page .feat-card:hover { box-shadow: 0 8px 24px 0 rgba(0,0,0,0.12); transform: translateY(-2px); } .titanic-page .feat-icon { font-size: 32px; margin-bottom: 16px; } .titanic-page .feat-card h3 { font-size: 18px; font-weight: 700; color: var(--el-text-color-primary); margin-bottom: 8px; } .titanic-page .feat-card p { font-size: 15px; color: var(--el-text-color-regular); line-height: 1.6; } @media (max-width: 1024px) { .titanic-page .features-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 640px) { .titanic-page .features-grid { grid-template-columns: 1fr; } } .titanic-page .usecases-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; } .titanic-page .uc-card { padding: 28px 24px; background: var(--el-bg-color); border: none; border-radius: 20px; box-shadow: 0 2px 12px 0 rgba(0,0,0,0.08); text-align: center; transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s; } .titanic-page .uc-card:hover { box-shadow: 0 8px 24px 0 rgba(0,0,0,0.12); transform: translateY(-2px); } .titanic-page .uc-icon { font-size: 36px; margin-bottom: 16px; } .titanic-page .uc-card h3 { font-size: 17px; font-weight: 700; color: var(--el-text-color-primary); margin-bottom: 8px; } .titanic-page .uc-card p { font-size: 14px; color: var(--el-text-color-regular); line-height: 1.6; } @media (max-width: 1024px) { .titanic-page .usecases-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 480px) { .titanic-page .usecases-grid { grid-template-columns: 1fr; } } .titanic-page .code-wrap { border-radius: 16px !important; overflow: hidden !important; border: 1px solid #334155 !important; background: #0f172a !important; } .markdown-body .titanic-page .code-wrap { border-radius: 16px !important; overflow: hidden !important; border: 1px solid #334155 !important; background: #0f172a !important; } .titanic-page .code-bar { display: flex !important; align-items: center !important; justify-content: space-between !important; padding: 12px 20px !important; background: #1e293b !important; border-bottom: 1px solid #334155 !important; } .titanic-page .code-dots { display: flex; gap: 6px; } .titanic-page .code-dots i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; } .titanic-page .code-dots .r { background: #ef4444; } .titanic-page .code-dots .y { background: #f59e0b; } .titanic-page .code-dots .g { background: #10b981; } .titanic-page .code-lang { font-size: 12px; color: var(--el-text-color-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; } .titanic-page .code-block { padding: 24px !important; margin: 0 !important; overflow-x: auto !important; font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace !important; font-size: 13.5px !important; line-height: 1.7 !important; color: #e2e8f0 !important; white-space: pre !important; background: transparent !important; border: none !important; border-radius: 0 !important; } .markdown-body .titanic-page .code-block { padding: 24px !important; margin: 0 !important; overflow-x: auto !important; font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace !important; font-size: 13.5px !important; line-height: 1.7 !important; color: #e2e8f0 !important; white-space: pre !important; background: transparent !important; border: none !important; border-radius: 0 !important; } .titanic-page .steps-row { display: flex; align-items: flex-start; justify-content: center; margin-bottom: 48px; } .titanic-page .stp-card { flex: 1; max-width: 320px; text-align: center; padding: 0 24px; } .titanic-page .stp-num { font-size: clamp(48px, 6vw, 72px); font-weight: 700; color: #e2e8f0; letter-spacing: -0.04em; line-height: 1; margin-bottom: 20px; } .titanic-page .stp-card h3 { font-size: 18px; font-weight: 700; color: var(--el-text-color-primary); margin-bottom: 10px; } .titanic-page .stp-card p { font-size: 15px; color: var(--el-text-color-regular); line-height: 1.6; } .titanic-page .stp-conn { width: 60px; height: 2px; background: var(--el-border-color-light); margin-top: 36px; flex-shrink: 0; } .titanic-page .steps-cta { text-align: center; } @media (max-width: 768px) { .titanic-page .steps-row { flex-direction: column; align-items: center; gap: 32px; } .titanic-page .stp-conn { width: 2px; height: 32px; margin: 0; } .titanic-page .stp-card { max-width: 100%; } } .titanic-page .code-split { display: flex; gap: 48px; align-items: center; } .titanic-page .code-left { flex: 1; min-width: 0; } .titanic-page .code-right { flex: 1; } .titanic-page .code-right h2 { font-size: clamp(24px, 3vw, 32px); font-weight: 700; color: var(--el-text-color-primary); margin-bottom: 12px; letter-spacing: normal; } .titanic-page .code-right > p { font-size: 16px; color: var(--el-text-color-regular); line-height: 1.6; margin-bottom: 32px; } .titanic-page .explain-steps { display: flex; flex-direction: column; gap: 20px; } .titanic-page .explain-step { display: flex; gap: 16px; align-items: flex-start; } .titanic-page .step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--el-bg-color-page); border: 1px solid var(--el-border-color-light); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--el-text-color-regular); flex-shrink: 0; } .titanic-page .step-text h4 { font-size: 15px; font-weight: 700; color: var(--el-text-color-primary); margin-bottom: 2px; } .titanic-page .step-text p { font-size: 14px; color: var(--el-text-color-secondary); line-height: 1.5; } @media (max-width: 768px) { .titanic-page .code-split { flex-direction: column; } .titanic-page .code-left { order: 2; } .titanic-page .code-right { order: 1; } } .titanic-cta { padding: 100px 0; background: #0f172a; text-align: center; position: relative; overflow: hidden; } .titanic-cta::before { content: ''; position: absolute; top: -100px; left: 50%; transform: translateX(-50%); width: 700px; height: 400px; background: radial-gradient(ellipse, rgba(30, 64, 175, 0.12) 0%, transparent 70%); pointer-events: none; } .titanic-cta h2 { font-size: clamp(28px, 4vw, 44px); font-weight: 700; color: #f8fafc; letter-spacing: normal; margin-bottom: 28px; position: relative; } .titanic-cta > div > p { font-size: clamp(16px, 2vw, 18px); color: var(--el-text-color-secondary); max-width: 520px; margin: 0 auto 56px; line-height: 1.6; position: relative; } .titanic-page .cta-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; position: relative; } .titanic-page .btn-cta-light { display: inline-flex; align-items: center; gap: 6px; padding: 14px 32px; background: #1e40af; color: #ffffff !important; border-radius: 9999px; font-size: 15px; font-weight: 700; transition: background 0.2s, transform 0.15s; text-decoration: none !important; } .titanic-page .btn-cta-light:hover { background: #1e3a8a; transform: translateY(-1px); text-decoration: none !important; } .titanic-page .btn-cta-ghost { display: inline-flex; align-items: center; padding: 14px 32px; background: transparent; color: #94a3b8 !important; border: 1px solid #334155; border-radius: 9999px; font-size: 15px; font-weight: 600; transition: border-color 0.2s, color 0.2s; text-decoration: none !important; } .titanic-page .btn-cta-ghost:hover { border-color: var(--el-text-color-regular); color: #e2e8f0 !important; text-decoration: none !important; } .titanic-page code { background: #dbeafe !important; padding: 2px 8px !important; border-radius: 5px !important; font-size: 13px !important; font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace !important; color: #1e3a8a !important; border: 1px solid #93c5fd !important; } .titanic-page .s-text-dark { color: var(--el-text-color-primary); } .titanic-page .s-text-brand { color: #1e40af; } .titanic-page .s-section-body { font-size: 16px; color: var(--el-text-color-regular); line-height: 1.8; text-align: center; max-width: 680px; margin: 0 auto; } .titanic-page .s-section-body p + p { margin-top: 16px; } .titanic-page .tag-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 16px; } .titanic-page .tag-item

{
padding: 4px 12px; background: var(--el-bg-color-page);
border: 1px solid var(--el-border-color-light); border-radius: 9999px;
font-size: 12px; font-weight: 600; color: var(--el-text-color-regular);
}
html.dark .titanic-page { background: var(--el-bg-color); color: var(--el-text-color-primary); }
html.dark .titanic-page a { color: inherit; }
html.dark .markdown-body .titanic-page a { color: inherit !important; }
html.dark .markdown-body .titanic-page a.s-btn-primary,
html.dark .markdown-body .titanic-page a.btn-cta-light { color: #ffffff !important; }
html.dark .markdown-body .titanic-page a.s-btn-secondary { color: var(--el-text-color-primary) !important; }
html.dark .markdown-body .titanic-page a.btn-cta-ghost { color: #94a3b8 !important; }
html.dark .markdown-body .titanic-page a.btn-cta-ghost:hover { color: var(--el-text-color-primary) !important; }
html.dark .titanic-page .s-bg-white { background: var(--el-bg-color); }
html.dark .titanic-page .s-bg-gray { background: var(--el-bg-color-page); }
html.dark .titanic-page .s-bg-dark { background: var(--el-bg-color); }
html.dark .titanic-page .s-header h2 { color: var(--el-text-color-primary); }
html.dark .titanic-page .s-header p { color: var(--el-text-color-secondary); }
html.dark .titanic-page .s-btn-primary { background: #1e40af; color: #ffffff !important; }
html.dark .titanic-page .s-btn-primary:hover { background: #1e3a8a; }
html.dark .titanic-page .s-btn-secondary {
background: #1e293b; color: var(--el-text-color-primary) !important;
border-color: #475569;
}
html.dark .titanic-page .s-btn-secondary:hover { background: var(--el-border-color); border-color: var(--el-text-color-regular); }
html.dark .titanic-hero { background: var(--el-bg-color); }
html.dark .titanic-hero::before {
background: radial-gradient(ellipse, rgba(30, 64, 175, 0.15) 0%, transparent 70%);
}
html.dark .titanic-page .hero-badge { background: var(--el-bg-color-page); border-color: var(--el-border-color); color: var(--el-text-color-secondary); }
html.dark .titanic-hero h1 { color: var(--el-text-color-primary); }
html.dark .titanic-hero h1 span { color: #60a5fa; }
html.dark .titanic-page .hero-subtitle { color: var(--el-text-color-secondary); }
html.dark .titanic-page .hero-highlights .h-item { color: var(--el-text-color-secondary); }
html.dark .titanic-page .hero-highlights .h-div { background: var(--el-border-color); }
html.dark .titanic-stats { background: var(--el-bg-color-page); border-color: var(--el-border-color); }
html.dark .titanic-page .stat-val { color: var(--el-text-color-primary); }
html.dark .titanic-page .stat-lbl { color: var(--el-text-color-regular); }
html.dark .titanic-page .feat-card {
background: var(--el-bg-color-page); border-color: var(--el-border-color);
}
html.dark .titanic-page .feat-card:hover { border-color: var(--el-text-color-regular); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
html.dark .titanic-page .feat-card h3 { color: var(--el-text-color-primary); }
html.dark .titanic-page .feat-card p { color: var(--el-text-color-secondary); }
html.dark .titanic-page .uc-card { background: var(--el-bg-color-page); border-color: var(--el-border-color); }
html.dark .titanic-page .uc-card:hover { border-color: var(--el-text-color-regular); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
html.dark .titanic-page .uc-card h3 { color: var(--el-text-color-primary); }
html.dark .titanic-page .uc-card p { color: var(--el-text-color-secondary); }
html.dark .titanic-page .stp-num { color: #334155; }
html.dark .titanic-page .stp-card h3 { color: var(--el-text-color-primary); }
html.dark .titanic-page .stp-card p { color: var(--el-text-color-secondary); }
html.dark .titanic-page .stp-conn { background: var(--el-border-color); }
html.dark .titanic-page .code-right h2 { color: var(--el-text-color-primary); }
html.dark .titanic-page .code-right > p { color: var(--el-text-color-secondary); }
html.dark .titanic-page .step-num { background: var(--el-border-color); border-color: var(--el-text-color-regular); color: var(--el-text-color-secondary); }
html.dark .titanic-page .step-text h4 { color: var(--el-text-color-primary); }
html.dark .titanic-page .step-text p { color: var(--el-text-color-regular); }
html.dark .titanic-page code {
background: #1e3a5f !important; color: #93c5fd !important; border-color: #1e40af !important;
}
html.dark .titanic-page .s-text-dark { color: var(--el-text-color-primary); }
html.dark .titanic-page .s-text-brand { color: #60a5fa; }
html.dark .titanic-page .s-section-body { color: var(--el-text-color-secondary); }
html.dark .titanic-cta { background: #020617; }
html.dark .titanic-cta::before {
background: radial-gradient(ellipse, rgba(30, 64, 175, 0.2) 0%, transparent 70%);
}
html.dark .titanic-page .tag-item { background: var(--el-border-color); border-color: var(--el-text-color-regular); color: var(--el-text-color-secondary); }
html.dark .titanic-page .btn-cta-light { color: #ffffff !important; }
html.dark .titanic-page .btn-cta-ghost { color: #94a3b8 !important; }
html.dark .titanic-page .btn-cta-ghost:hover { color: var(--el-text-color-primary) !important; }
</style>
<div class="titanic-page">
<section class="titanic-hero">
<div class="s-container-narrow">
<div class="hero-badge">
<span class="badge-dot"></span>
Titanic Dataset · Ace Data Cloud
</div>
<h1>
Titanic Passenger Dataset:<br/>
A <span>Classic Challenge</span> in Machine Learning
</h1>
<p class="hero-subtitle">
Based on the real passenger data from the 1912 Titanic sinking. 887 samples, 12 features—covering numerical, categorical, and text features, making it an ideal dataset for learning binary classification, feature engineering, and data preprocessing.

Titanic Passenger Dataset
CSV Format · 44 KB Public Domain License Based on real historical data from 1912
📊
887
Number of Samples
📐
12
Number of Features
🏷️
2
Number of Categories
📦
44KB
File Size

Dataset Highlights

The Titanic dataset has good reasons to be the most popular beginner dataset in the global ML community.

🎯

Classic Binary Classification

A classic survival prediction binary classification problem with a clear goal—predicting whether passengers survived the sinking, making it an excellent starting point for learning classification algorithms.

🔢

Rich Features

Includes numerical, categorical, and text features, covering multidimensional information such as age, fare, gender, and cabin class, suitable for various feature processing methods.

📜

Real Data

Based on real historical data from the Titanic in 1912, each record corresponds to a real passenger, giving deeper meaning to data analysis.

🧹

Data Cleaning

Contains missing values (such as age, cabin number), suitable for data preprocessing practice, learning practical skills like filling missing values and handling outliers.

🌍

Widely Used

One of the most commonly used beginner datasets in the global ML community, a classic competition topic on Kaggle, with a wealth of tutorials and reference solutions.

📁

Compact and Portable

A 44KB CSV file that contains all the data, supports quick offline loading, no worries about storage or bandwidth issues, start analyzing anytime, anywhere.

Use Cases

From classroom exercises to Kaggle competitions—the common uses of the Titanic dataset.

🚢

Survival Prediction

Use algorithms like logistic regression, random forests, and XGBoost to predict passenger survival probabilities, a classic binary classification introductory task.

🔧

Feature Engineering

Extract titles from names, combine family size, bin age and fare, practice feature creation and transformation skills.

📊

Data Visualization

Plot charts showing the relationship between survival rates and gender, class, age, to intuitively understand data distribution and feature correlations.

🎓

Machine Learning Teaching

Covers the complete process of data cleaning, feature engineering, model training, and evaluation, suitable for teaching and self-study.

Data Preview

Some sample examples from the Titanic dataset (CSV format).

CSV
Survived,Pclass,Name,Sex,Age,SiblingsSpouses,ParentsChildren,Fare
0,3,Mr. Owen Harris Braund,male,22,1,0,7.25
1,1,Mrs. John Bradley Cumings,female,38,1,0,71.28
1,3,Miss.
Laina Heikkinen,female,26,0,0,7.93  
1,1,Mrs. Jacques Heath Futrelle,female,35,1,0,53.10  
0,3,Mr. William Henry Allen,male,35,0,0,8.05
Survived 是否幸存 Pclass 舱位等级 Name 姓名 Sex 性别 Age 年龄 SiblingsSpouses 兄弟姐妹/配偶数 ParentsChildren 父母/子女数 Fare 票价

3 Steps to Get Started Quickly

It only takes a few minutes from browsing to using

01

Browse the Dataset

View detailed descriptions, field definitions, and data previews of the Titanic dataset on the Ace Data Cloud platform.

02

Download the CSV File

Download a 44 KB CSV file to your local machine with one click, no registration, no payment, get it immediately.

03

Load and Use

Load the data using Python, R, or any data analysis tool, and start training models or creating visualizations.

Python
import pandas as pd  
from sklearn.model_selection import train_test_split  
from sklearn.ensemble import RandomForestClassifier  
from sklearn.metrics import accuracy_score, classification_report  

Load data

df = pd.read_csv("titanic.csv")

Feature engineering: extract titles, calculate family size

df["Title"] = df["Name"].str.extract(r" ([A-Za-z]+).")
df["FamilySize"] = df["SiblingsSpouses"] + df["ParentsChildren"] + 1

Select features and process

features = ["Pclass", "Sex", "Age", "Fare", "FamilySize"]
df["Sex"] = df["Sex"].map({"male": 0, "female": 1})
df["Age"].fillna(df["Age"].median(), inplace=True)

Split into training and testing sets

X = df[features]
y = df["Survived"]
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.3, random_state=42
)

Train the random forest classifier

clf = RandomForestClassifier(n_estimators=100, random_state=42)
clf.fit(X_train, y_train)

Evaluate the model

y_pred = clf.predict(X_test)
print(f"Accuracy: {accuracy_score(y_test, y_pred):.2%}")
print(classification_report(y_test, y_pred, target_names=["Did not survive", "Survived"]))

Start Your Machine Learning Journey

The Titanic dataset is a classic challenge for millions of developers worldwide to learn machine learning. Download for free and start exploring immediately.