文档章节

Random Forests 随机森林

hblt-j
 hblt-j
发布于 2017/08/29 14:50
字数 11358
阅读 24
收藏 0
点赞 0
评论 0

 随机森林是决策树的集合。 随机森林结合许多决策树,以减少过度拟合的风险。 spark.ml实现支持随机森林,使用连续和分类特征,做二分类和多分类以及回归。

导入包

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

import org.apache.spark.sql.SparkSession

import org.apache.spark.sql.Dataset

import org.apache.spark.sql.Row

import org.apache.spark.sql.DataFrame

import org.apache.spark.sql.Column

import org.apache.spark.sql.DataFrameReader

import org.apache.spark.rdd.RDD

import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder

import org.apache.spark.sql.Encoder

import org.apache.spark.sql.DataFrameStatFunctions

import org.apache.spark.sql.functions._

 

import org.apache.spark.ml.linalg.Vectors

import org.apache.spark.ml.feature.{ IndexToString, StringIndexer, VectorIndexer }

import org.apache.spark.ml.feature.VectorAssembler

import org.apache.spark.ml.Pipeline

import org.apache.spark.ml.classification.{ RandomForestClassificationModel, RandomForestClassifier }

import org.apache.spark.ml.evaluation.BinaryClassificationEvaluator

import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator

import org.apache.spark.ml.tuning.{ ParamGridBuilder, CrossValidator }

 

导入源数据

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

// affairs:一年来婚外情的频率  

// gender:性别  

// age:年龄  

// yearsmarried:婚龄  

// children:是否有小孩  

// religiousness:宗教信仰程度(5分制,1分表示反对,5分表示非常信仰) 

// education:学历 

// occupation:职业(逆向编号的戈登7种分类)  

// rating:对婚姻的自我评分(5分制,1表示非常不幸福,5表示非常幸福)

 

val spark = SparkSession.builder().appName("Spark Random Forest Classifier").config("spark.some.config.option", "some-value").getOrCreate()

 

// For implicit conversions like converting RDDs to DataFrames

import spark.implicits._

 

val dataList: List[(Double, String, Double, Double, String, Double, Double, Double, Double)] = List( 

      (0, "male", 37, 10, "no", 3, 18, 7, 4), 

      (0, "female", 27, 4, "no", 4, 14, 6, 4), 

      (0, "female", 32, 15, "yes", 1, 12, 1, 4), 

      (0, "male", 57, 15, "yes", 5, 18, 6, 5), 

      (0, "male", 22, 0.75, "no", 2, 17, 6, 3), 

      (0, "female", 32, 1.5, "no", 2, 17, 5, 5), 

      (0, "female", 22, 0.75, "no", 2, 12, 1, 3), 

      (0, "male", 57, 15, "yes", 2, 14, 4, 4), 

      (0, "female", 32, 15, "yes", 4, 16, 1, 2), 

      (0, "male", 22, 1.5, "no", 4, 14, 4, 5), 

      (0, "male", 37, 15, "yes", 2, 20, 7, 2), 

      (0, "male", 27, 4, "yes", 4, 18, 6, 4), 

      (0, "male", 47, 15, "yes", 5, 17, 6, 4), 

      (0, "female", 22, 1.5, "no", 2, 17, 5, 4), 

      (0, "female", 27, 4, "no", 4, 14, 5, 4), 

      (0, "female", 37, 15, "yes", 1, 17, 5, 5), 

      (0, "female", 37, 15, "yes", 2, 18, 4, 3), 

      (0, "female", 22, 0.75, "no", 3, 16, 5, 4), 

      (0, "female", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "female", 27, 10, "yes", 2, 14, 1, 5), 

      (0, "female", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "female", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "female", 27, 10, "yes", 4, 16, 5, 4), 

      (0, "female", 32, 10, "yes", 3, 14, 1, 5), 

      (0, "male", 37, 4, "yes", 2, 20, 6, 4), 

      (0, "female", 22, 1.5, "no", 2, 18, 5, 5), 

      (0, "female", 27, 7, "no", 4, 16, 1, 5), 

      (0, "male", 42, 15, "yes", 5, 20, 6, 4), 

      (0, "male", 27, 4, "yes", 3, 16, 5, 5), 

      (0, "female", 27, 4, "yes", 3, 17, 5, 4), 

      (0, "male", 42, 15, "yes", 4, 20, 6, 3), 

      (0, "female", 22, 1.5, "no", 3, 16, 5, 5), 

      (0, "male", 27, 0.417, "no", 4, 17, 6, 4), 

      (0, "female", 42, 15, "yes", 5, 14, 5, 4), 

      (0, "male", 32, 4, "yes", 1, 18, 6, 4), 

      (0, "female", 22, 1.5, "no", 4, 16, 5, 3), 

      (0, "female", 42, 15, "yes", 3, 12, 1, 4), 

      (0, "female", 22, 4, "no", 4, 17, 5, 5), 

      (0, "male", 22, 1.5, "yes", 1, 14, 3, 5), 

      (0, "female", 22, 0.75, "no", 3, 16, 1, 5), 

      (0, "male", 32, 10, "yes", 5, 20, 6, 5), 

      (0, "male", 52, 15, "yes", 5, 18, 6, 3), 

      (0, "female", 22, 0.417, "no", 5, 14, 1, 4), 

      (0, "female", 27, 4, "yes", 2, 18, 6, 1), 

      (0, "female", 32, 7, "yes", 5, 17, 5, 3), 

      (0, "male", 22, 4, "no", 3, 16, 5, 5), 

      (0, "female", 27, 7, "yes", 4, 18, 6, 5), 

      (0, "female", 42, 15, "yes", 2, 18, 5, 4), 

      (0, "male", 27, 1.5, "yes", 4, 16, 3, 5), 

      (0, "male", 42, 15, "yes", 2, 20, 6, 4), 

      (0, "female", 22, 0.75, "no", 5, 14, 3, 5), 

      (0, "male", 32, 7, "yes", 2, 20, 6, 4), 

      (0, "male", 27, 4, "yes", 5, 20, 6, 5), 

      (0, "male", 27, 10, "yes", 4, 20, 6, 4), 

      (0, "male", 22, 4, "no", 1, 18, 5, 5), 

      (0, "female", 37, 15, "yes", 4, 14, 3, 1), 

      (0, "male", 22, 1.5, "yes", 5, 16, 4, 4), 

      (0, "female", 37, 15, "yes", 4, 17, 1, 5), 

      (0, "female", 27, 0.75, "no", 4, 17, 5, 4), 

      (0, "male", 32, 10, "yes", 4, 20, 6, 4), 

      (0, "female", 47, 15, "yes", 5, 14, 7, 2), 

      (0, "male", 37, 10, "yes", 3, 20, 6, 4), 

      (0, "female", 22, 0.75, "no", 2, 16, 5, 5), 

      (0, "male", 27, 4, "no", 2, 18, 4, 5), 

      (0, "male", 32, 7, "no", 4, 20, 6, 4), 

      (0, "male", 42, 15, "yes", 2, 17, 3, 5), 

      (0, "male", 37, 10, "yes", 4, 20, 6, 4), 

      (0, "female", 47, 15, "yes", 3, 17, 6, 5), 

      (0, "female", 22, 1.5, "no", 5, 16, 5, 5), 

      (0, "female", 27, 1.5, "no", 2, 16, 6, 4), 

      (0, "female", 27, 4, "no", 3, 17, 5, 5), 

      (0, "female", 32, 10, "yes", 5, 14, 4, 5), 

      (0, "female", 22, 0.125, "no", 2, 12, 5, 5), 

      (0, "male", 47, 15, "yes", 4, 14, 4, 3), 

      (0, "male", 32, 15, "yes", 1, 14, 5, 5), 

      (0, "male", 27, 7, "yes", 4, 16, 5, 5), 

      (0, "female", 22, 1.5, "yes", 3, 16, 5, 5), 

      (0, "male", 27, 4, "yes", 3, 17, 6, 5), 

      (0, "female", 22, 1.5, "no", 3, 16, 5, 5), 

      (0, "male", 57, 15, "yes", 2, 14, 7, 2), 

      (0, "male", 17.5, 1.5, "yes", 3, 18, 6, 5), 

      (0, "male", 57, 15, "yes", 4, 20, 6, 5), 

      (0, "female", 22, 0.75, "no", 2, 16, 3, 4), 

      (0, "male", 42, 4, "no", 4, 17, 3, 3), 

      (0, "female", 22, 1.5, "yes", 4, 12, 1, 5), 

      (0, "female", 22, 0.417, "no", 1, 17, 6, 4), 

      (0, "female", 32, 15, "yes", 4, 17, 5, 5), 

      (0, "female", 27, 1.5, "no", 3, 18, 5, 2), 

      (0, "female", 22, 1.5, "yes", 3, 14, 1, 5), 

      (0, "female", 37, 15, "yes", 3, 14, 1, 4), 

      (0, "female", 32, 15, "yes", 4, 14, 3, 4), 

      (0, "male", 37, 10, "yes", 2, 14, 5, 3), 

      (0, "male", 37, 10, "yes", 4, 16, 5, 4), 

      (0, "male", 57, 15, "yes", 5, 20, 5, 3), 

      (0, "male", 27, 0.417, "no", 1, 16, 3, 4), 

      (0, "female", 42, 15, "yes", 5, 14, 1, 5), 

      (0, "male", 57, 15, "yes", 3, 16, 6, 1), 

      (0, "male", 37, 10, "yes", 1, 16, 6, 4), 

      (0, "male", 37, 15, "yes", 3, 17, 5, 5), 

      (0, "male", 37, 15, "yes", 4, 20, 6, 5), 

      (0, "female", 27, 10, "yes", 5, 14, 1, 5), 

      (0, "male", 37, 10, "yes", 2, 18, 6, 4), 

      (0, "female", 22, 0.125, "no", 4, 12, 4, 5), 

      (0, "male", 57, 15, "yes", 5, 20, 6, 5), 

      (0, "female", 37, 15, "yes", 4, 18, 6, 4), 

      (0, "male", 22, 4, "yes", 4, 14, 6, 4), 

      (0, "male", 27, 7, "yes", 4, 18, 5, 4), 

      (0, "male", 57, 15, "yes", 4, 20, 5, 4), 

      (0, "male", 32, 15, "yes", 3, 14, 6, 3), 

      (0, "female", 22, 1.5, "no", 2, 14, 5, 4), 

      (0, "female", 32, 7, "yes", 4, 17, 1, 5), 

      (0, "female", 37, 15, "yes", 4, 17, 6, 5), 

      (0, "female", 32, 1.5, "no", 5, 18, 5, 5), 

      (0, "male", 42, 10, "yes", 5, 20, 7, 4), 

      (0, "female", 27, 7, "no", 3, 16, 5, 4), 

      (0, "male", 37, 15, "no", 4, 20, 6, 5), 

      (0, "male", 37, 15, "yes", 4, 14, 3, 2), 

      (0, "male", 32, 10, "no", 5, 18, 6, 4), 

      (0, "female", 22, 0.75, "no", 4, 16, 1, 5), 

      (0, "female", 27, 7, "yes", 4, 12, 2, 4), 

      (0, "female", 27, 7, "yes", 2, 16, 2, 5), 

      (0, "female", 42, 15, "yes", 5, 18, 5, 4), 

      (0, "male", 42, 15, "yes", 4, 17, 5, 3), 

      (0, "female", 27, 7, "yes", 2, 16, 1, 2), 

      (0, "female", 22, 1.5, "no", 3, 16, 5, 5), 

      (0, "male", 37, 15, "yes", 5, 20, 6, 5), 

      (0, "female", 22, 0.125, "no", 2, 14, 4, 5), 

      (0, "male", 27, 1.5, "no", 4, 16, 5, 5), 

      (0, "male", 32, 1.5, "no", 2, 18, 6, 5), 

      (0, "male", 27, 1.5, "no", 2, 17, 6, 5), 

      (0, "female", 27, 10, "yes", 4, 16, 1, 3), 

      (0, "male", 42, 15, "yes", 4, 18, 6, 5), 

      (0, "female", 27, 1.5, "no", 2, 16, 6, 5), 

      (0, "male", 27, 4, "no", 2, 18, 6, 3), 

      (0, "female", 32, 10, "yes", 3, 14, 5, 3), 

      (0, "female", 32, 15, "yes", 3, 18, 5, 4), 

      (0, "female", 22, 0.75, "no", 2, 18, 6, 5), 

      (0, "female", 37, 15, "yes", 2, 16, 1, 4), 

      (0, "male", 27, 4, "yes", 4, 20, 5, 5), 

      (0, "male", 27, 4, "no", 1, 20, 5, 4), 

      (0, "female", 27, 10, "yes", 2, 12, 1, 4), 

      (0, "female", 32, 15, "yes", 5, 18, 6, 4), 

      (0, "male", 27, 7, "yes", 5, 12, 5, 3), 

      (0, "male", 52, 15, "yes", 2, 18, 5, 4), 

      (0, "male", 27, 4, "no", 3, 20, 6, 3), 

      (0, "male", 37, 4, "yes", 1, 18, 5, 4), 

      (0, "male", 27, 4, "yes", 4, 14, 5, 4), 

      (0, "female", 52, 15, "yes", 5, 12, 1, 3), 

      (0, "female", 57, 15, "yes", 4, 16, 6, 4), 

      (0, "male", 27, 7, "yes", 1, 16, 5, 4), 

      (0, "male", 37, 7, "yes", 4, 20, 6, 3), 

      (0, "male", 22, 0.75, "no", 2, 14, 4, 3), 

      (0, "male", 32, 4, "yes", 2, 18, 5, 3), 

      (0, "male", 37, 15, "yes", 4, 20, 6, 3), 

      (0, "male", 22, 0.75, "yes", 2, 14, 4, 3), 

      (0, "male", 42, 15, "yes", 4, 20, 6, 3), 

      (0, "female", 52, 15, "yes", 5, 17, 1, 1), 

      (0, "female", 37, 15, "yes", 4, 14, 1, 2), 

      (0, "male", 27, 7, "yes", 4, 14, 5, 3), 

      (0, "male", 32, 4, "yes", 2, 16, 5, 5), 

      (0, "female", 27, 4, "yes", 2, 18, 6, 5), 

      (0, "female", 27, 4, "yes", 2, 18, 5, 5), 

      (0, "male", 37, 15, "yes", 5, 18, 6, 5), 

      (0, "female", 47, 15, "yes", 5, 12, 5, 4), 

      (0, "female", 32, 10, "yes", 3, 17, 1, 4), 

      (0, "female", 27, 1.5, "yes", 4, 17, 1, 2), 

      (0, "female", 57, 15, "yes", 2, 18, 5, 2), 

      (0, "female", 22, 1.5, "no", 4, 14, 5, 4), 

      (0, "male", 42, 15, "yes", 3, 14, 3, 4), 

      (0, "male", 57, 15, "yes", 4, 9, 2, 2), 

      (0, "male", 57, 15, "yes", 4, 20, 6, 5), 

      (0, "female", 22, 0.125, "no", 4, 14, 4, 5), 

      (0, "female", 32, 10, "yes", 4, 14, 1, 5), 

      (0, "female", 42, 15, "yes", 3, 18, 5, 4), 

      (0, "female", 27, 1.5, "no", 2, 18, 6, 5), 

      (0, "male", 32, 0.125, "yes", 2, 18, 5, 2), 

      (0, "female", 27, 4, "no", 3, 16, 5, 4), 

      (0, "female", 27, 10, "yes", 2, 16, 1, 4), 

      (0, "female", 32, 7, "yes", 4, 16, 1, 3), 

      (0, "female", 37, 15, "yes", 4, 14, 5, 4), 

      (0, "female", 42, 15, "yes", 5, 17, 6, 2), 

      (0, "male", 32, 1.5, "yes", 4, 14, 6, 5), 

      (0, "female", 32, 4, "yes", 3, 17, 5, 3), 

      (0, "female", 37, 7, "no", 4, 18, 5, 5), 

      (0, "female", 22, 0.417, "yes", 3, 14, 3, 5), 

      (0, "female", 27, 7, "yes", 4, 14, 1, 5), 

      (0, "male", 27, 0.75, "no", 3, 16, 5, 5), 

      (0, "male", 27, 4, "yes", 2, 20, 5, 5), 

      (0, "male", 32, 10, "yes", 4, 16, 4, 5), 

      (0, "male", 32, 15, "yes", 1, 14, 5, 5), 

      (0, "male", 22, 0.75, "no", 3, 17, 4, 5), 

      (0, "female", 27, 7, "yes", 4, 17, 1, 4), 

      (0, "male", 27, 0.417, "yes", 4, 20, 5, 4), 

      (0, "male", 37, 15, "yes", 4, 20, 5, 4), 

      (0, "female", 37, 15, "yes", 2, 14, 1, 3), 

      (0, "male", 22, 4, "yes", 1, 18, 5, 4), 

      (0, "male", 37, 15, "yes", 4, 17, 5, 3), 

      (0, "female", 22, 1.5, "no", 2, 14, 4, 5), 

      (0, "male", 52, 15, "yes", 4, 14, 6, 2), 

      (0, "female", 22, 1.5, "no", 4, 17, 5, 5), 

      (0, "male", 32, 4, "yes", 5, 14, 3, 5), 

      (0, "male", 32, 4, "yes", 2, 14, 3, 5), 

      (0, "female", 22, 1.5, "no", 3, 16, 6, 5), 

      (0, "male", 27, 0.75, "no", 2, 18, 3, 3), 

      (0, "female", 22, 7, "yes", 2, 14, 5, 2), 

      (0, "female", 27, 0.75, "no", 2, 17, 5, 3), 

      (0, "female", 37, 15, "yes", 4, 12, 1, 2), 

      (0, "female", 22, 1.5, "no", 1, 14, 1, 5), 

      (0, "female", 37, 10, "no", 2, 12, 4, 4), 

      (0, "female", 37, 15, "yes", 4, 18, 5, 3), 

      (0, "female", 42, 15, "yes", 3, 12, 3, 3), 

      (0, "male", 22, 4, "no", 2, 18, 5, 5), 

      (0, "male", 52, 7, "yes", 2, 20, 6, 2), 

      (0, "male", 27, 0.75, "no", 2, 17, 5, 5), 

      (0, "female", 27, 4, "no", 2, 17, 4, 5), 

      (0, "male", 42, 1.5, "no", 5, 20, 6, 5), 

      (0, "male", 22, 1.5, "no", 4, 17, 6, 5), 

      (0, "male", 22, 4, "no", 4, 17, 5, 3), 

      (0, "female", 22, 4, "yes", 1, 14, 5, 4), 

      (0, "male", 37, 15, "yes", 5, 20, 4, 5), 

      (0, "female", 37, 10, "yes", 3, 16, 6, 3), 

      (0, "male", 42, 15, "yes", 4, 17, 6, 5), 

      (0, "female", 47, 15, "yes", 4, 17, 5, 5), 

      (0, "male", 22, 1.5, "no", 4, 16, 5, 4), 

      (0, "female", 32, 10, "yes", 3, 12, 1, 4), 

      (0, "female", 22, 7, "yes", 1, 14, 3, 5), 

      (0, "female", 32, 10, "yes", 4, 17, 5, 4), 

      (0, "male", 27, 1.5, "yes", 2, 16, 2, 4), 

      (0, "male", 37, 15, "yes", 4, 14, 5, 5), 

      (0, "male", 42, 4, "yes", 3, 14, 4, 5), 

      (0, "female", 37, 15, "yes", 5, 14, 5, 4), 

      (0, "female", 32, 7, "yes", 4, 17, 5, 5), 

      (0, "female", 42, 15, "yes", 4, 18, 6, 5), 

      (0, "male", 27, 4, "no", 4, 18, 6, 4), 

      (0, "male", 22, 0.75, "no", 4, 18, 6, 5), 

      (0, "male", 27, 4, "yes", 4, 14, 5, 3), 

      (0, "female", 22, 0.75, "no", 5, 18, 1, 5), 

      (0, "female", 52, 15, "yes", 5, 9, 5, 5), 

      (0, "male", 32, 10, "yes", 3, 14, 5, 5), 

      (0, "female", 37, 15, "yes", 4, 16, 4, 4), 

      (0, "male", 32, 7, "yes", 2, 20, 5, 4), 

      (0, "female", 42, 15, "yes", 3, 18, 1, 4), 

      (0, "male", 32, 15, "yes", 1, 16, 5, 5), 

      (0, "male", 27, 4, "yes", 3, 18, 5, 5), 

      (0, "female", 32, 15, "yes", 4, 12, 3, 4), 

      (0, "male", 22, 0.75, "yes", 3, 14, 2, 4), 

      (0, "female", 22, 1.5, "no", 3, 16, 5, 3), 

      (0, "female", 42, 15, "yes", 4, 14, 3, 5), 

      (0, "female", 52, 15, "yes", 3, 16, 5, 4), 

      (0, "male", 37, 15, "yes", 5, 20, 6, 4), 

      (0, "female", 47, 15, "yes", 4, 12, 2, 3), 

      (0, "male", 57, 15, "yes", 2, 20, 6, 4), 

      (0, "male", 32, 7, "yes", 4, 17, 5, 5), 

      (0, "female", 27, 7, "yes", 4, 17, 1, 4), 

      (0, "male", 22, 1.5, "no", 1, 18, 6, 5), 

      (0, "female", 22, 4, "yes", 3, 9, 1, 4), 

      (0, "female", 22, 1.5, "no", 2, 14, 1, 5), 

      (0, "male", 42, 15, "yes", 2, 20, 6, 4), 

      (0, "male", 57, 15, "yes", 4, 9, 2, 4), 

      (0, "female", 27, 7, "yes", 2, 18, 1, 5), 

      (0, "female", 22, 4, "yes", 3, 14, 1, 5), 

      (0, "male", 37, 15, "yes", 4, 14, 5, 3), 

      (0, "male", 32, 7, "yes", 1, 18, 6, 4), 

      (0, "female", 22, 1.5, "no", 2, 14, 5, 5), 

      (0, "female", 22, 1.5, "yes", 3, 12, 1, 3), 

      (0, "male", 52, 15, "yes", 2, 14, 5, 5), 

      (0, "female", 37, 15, "yes", 2, 14, 1, 1), 

      (0, "female", 32, 10, "yes", 2, 14, 5, 5), 

      (0, "male", 42, 15, "yes", 4, 20, 4, 5), 

      (0, "female", 27, 4, "yes", 3, 18, 4, 5), 

      (0, "male", 37, 15, "yes", 4, 20, 6, 5), 

      (0, "male", 27, 1.5, "no", 3, 18, 5, 5), 

      (0, "female", 22, 0.125, "no", 2, 16, 6, 3), 

      (0, "male", 32, 10, "yes", 2, 20, 6, 3), 

      (0, "female", 27, 4, "no", 4, 18, 5, 4), 

      (0, "female", 27, 7, "yes", 2, 12, 5, 1), 

      (0, "male", 32, 4, "yes", 5, 18, 6, 3), 

      (0, "female", 37, 15, "yes", 2, 17, 5, 5), 

      (0, "male", 47, 15, "no", 4, 20, 6, 4), 

      (0, "male", 27, 1.5, "no", 1, 18, 5, 5), 

      (0, "male", 37, 15, "yes", 4, 20, 6, 4), 

      (0, "female", 32, 15, "yes", 4, 18, 1, 4), 

      (0, "female", 32, 7, "yes", 4, 17, 5, 4), 

      (0, "female", 42, 15, "yes", 3, 14, 1, 3), 

      (0, "female", 27, 7, "yes", 3, 16, 1, 4), 

      (0, "male", 27, 1.5, "no", 3, 16, 4, 2), 

      (0, "male", 22, 1.5, "no", 3, 16, 3, 5), 

      (0, "male", 27, 4, "yes", 3, 16, 4, 2), 

      (0, "female", 27, 7, "yes", 3, 12, 1, 2), 

      (0, "female", 37, 15, "yes", 2, 18, 5, 4), 

      (0, "female", 37, 7, "yes", 3, 14, 4, 4), 

      (0, "male", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "male", 37, 15, "yes", 5, 20, 5, 4), 

      (0, "female", 22, 1.5, "no", 4, 16, 5, 3), 

      (0, "female", 32, 10, "yes", 4, 16, 1, 5), 

      (0, "male", 27, 4, "no", 2, 17, 5, 3), 

      (0, "female", 22, 0.417, "no", 4, 14, 5, 5), 

      (0, "female", 27, 4, "no", 2, 18, 5, 5), 

      (0, "male", 37, 15, "yes", 4, 18, 5, 3), 

      (0, "male", 37, 10, "yes", 5, 20, 7, 4), 

      (0, "female", 27, 7, "yes", 2, 14, 4, 2), 

      (0, "male", 32, 4, "yes", 2, 16, 5, 5), 

      (0, "male", 32, 4, "yes", 2, 16, 6, 4), 

      (0, "male", 22, 1.5, "no", 3, 18, 4, 5), 

      (0, "female", 22, 4, "yes", 4, 14, 3, 4), 

      (0, "female", 17.5, 0.75, "no", 2, 18, 5, 4), 

      (0, "male", 32, 10, "yes", 4, 20, 4, 5), 

      (0, "female", 32, 0.75, "no", 5, 14, 3, 3), 

      (0, "male", 37, 15, "yes", 4, 17, 5, 3), 

      (0, "male", 32, 4, "no", 3, 14, 4, 5), 

      (0, "female", 27, 1.5, "no", 2, 17, 3, 2), 

      (0, "female", 22, 7, "yes", 4, 14, 1, 5), 

      (0, "male", 47, 15, "yes", 5, 14, 6, 5), 

      (0, "male", 27, 4, "yes", 1, 16, 4, 4), 

      (0, "female", 37, 15, "yes", 5, 14, 1, 3), 

      (0, "male", 42, 4, "yes", 4, 18, 5, 5), 

      (0, "female", 32, 4, "yes", 2, 14, 1, 5), 

      (0, "male", 52, 15, "yes", 2, 14, 7, 4), 

      (0, "female", 22, 1.5, "no", 2, 16, 1, 4), 

      (0, "male", 52, 15, "yes", 4, 12, 2, 4), 

      (0, "female", 22, 0.417, "no", 3, 17, 1, 5), 

      (0, "female", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "male", 27, 4, "yes", 4, 20, 6, 4), 

      (0, "female", 32, 15, "yes", 4, 14, 1, 5), 

      (0, "female", 27, 1.5, "no", 2, 16, 3, 5), 

      (0, "male", 32, 4, "no", 1, 20, 6, 5), 

      (0, "male", 37, 15, "yes", 3, 20, 6, 4), 

      (0, "female", 32, 10, "no", 2, 16, 6, 5), 

      (0, "female", 32, 10, "yes", 5, 14, 5, 5), 

      (0, "male", 37, 1.5, "yes", 4, 18, 5, 3), 

      (0, "male", 32, 1.5, "no", 2, 18, 4, 4), 

      (0, "female", 32, 10, "yes", 4, 14, 1, 4), 

      (0, "female", 47, 15, "yes", 4, 18, 5, 4), 

      (0, "female", 27, 10, "yes", 5, 12, 1, 5), 

      (0, "male", 27, 4, "yes", 3, 16, 4, 5), 

      (0, "female", 37, 15, "yes", 4, 12, 4, 2), 

      (0, "female", 27, 0.75, "no", 4, 16, 5, 5), 

      (0, "female", 37, 15, "yes", 4, 16, 1, 5), 

      (0, "female", 32, 15, "yes", 3, 16, 1, 5), 

      (0, "female", 27, 10, "yes", 2, 16, 1, 5), 

      (0, "male", 27, 7, "no", 2, 20, 6, 5), 

      (0, "female", 37, 15, "yes", 2, 14, 1, 3), 

      (0, "male", 27, 1.5, "yes", 2, 17, 4, 4), 

      (0, "female", 22, 0.75, "yes", 2, 14, 1, 5), 

      (0, "male", 22, 4, "yes", 4, 14, 2, 4), 

      (0, "male", 42, 0.125, "no", 4, 17, 6, 4), 

      (0, "male", 27, 1.5, "yes", 4, 18, 6, 5), 

      (0, "male", 27, 7, "yes", 3, 16, 6, 3), 

      (0, "female", 52, 15, "yes", 4, 14, 1, 3), 

      (0, "male", 27, 1.5, "no", 5, 20, 5, 2), 

      (0, "female", 27, 1.5, "no", 2, 16, 5, 5), 

      (0, "female", 27, 1.5, "no", 3, 17, 5, 5), 

      (0, "male", 22, 0.125, "no", 5, 16, 4, 4), 

      (0, "female", 27, 4, "yes", 4, 16, 1, 5), 

      (0, "female", 27, 4, "yes", 4, 12, 1, 5), 

      (0, "female", 47, 15, "yes", 2, 14, 5, 5), 

      (0, "female", 32, 15, "yes", 3, 14, 5, 3), 

      (0, "male", 42, 7, "yes", 2, 16, 5, 5), 

      (0, "male", 22, 0.75, "no", 4, 16, 6, 4), 

      (0, "male", 27, 0.125, "no", 3, 20, 6, 5), 

      (0, "male", 32, 10, "yes", 3, 20, 6, 5), 

      (0, "female", 22, 0.417, "no", 5, 14, 4, 5), 

      (0, "female", 47, 15, "yes", 5, 14, 1, 4), 

      (0, "female", 32, 10, "yes", 3, 14, 1, 5), 

      (0, "male", 57, 15, "yes", 4, 17, 5, 5), 

      (0, "male", 27, 4, "yes", 3, 20, 6, 5), 

      (0, "female", 32, 7, "yes", 4, 17, 1, 5), 

      (0, "female", 37, 10, "yes", 4, 16, 1, 5), 

      (0, "female", 32, 10, "yes", 1, 18, 1, 4), 

      (0, "female", 22, 4, "no", 3, 14, 1, 4), 

      (0, "female", 27, 7, "yes", 4, 14, 3, 2), 

      (0, "male", 57, 15, "yes", 5, 18, 5, 2), 

      (0, "male", 32, 7, "yes", 2, 18, 5, 5), 

      (0, "female", 27, 1.5, "no", 4, 17, 1, 3), 

      (0, "male", 22, 1.5, "no", 4, 14, 5, 5), 

      (0, "female", 22, 1.5, "yes", 4, 14, 5, 4), 

      (0, "female", 32, 7, "yes", 3, 16, 1, 5), 

      (0, "female", 47, 15, "yes", 3, 16, 5, 4), 

      (0, "female", 22, 0.75, "no", 3, 16, 1, 5), 

      (0, "female", 22, 1.5, "yes", 2, 14, 5, 5), 

      (0, "female", 27, 4, "yes", 1, 16, 5, 5), 

      (0, "male", 52, 15, "yes", 4, 16, 5, 5), 

      (0, "male", 32, 10, "yes", 4, 20, 6, 5), 

      (0, "male", 47, 15, "yes", 4, 16, 6, 4), 

      (0, "female", 27, 7, "yes", 2, 14, 1, 2), 

      (0, "female", 22, 1.5, "no", 4, 14, 4, 5), 

      (0, "female", 32, 10, "yes", 2, 16, 5, 4), 

      (0, "female", 22, 0.75, "no", 2, 16, 5, 4), 

      (0, "female", 22, 1.5, "no", 2, 16, 5, 5), 

      (0, "female", 42, 15, "yes", 3, 18, 6, 4), 

      (0, "female", 27, 7, "yes", 5, 14, 4, 5), 

      (0, "male", 42, 15, "yes", 4, 16, 4, 4), 

      (0, "female", 57, 15, "yes", 3, 18, 5, 2), 

      (0, "male", 42, 15, "yes", 3, 18, 6, 2), 

      (0, "female", 32, 7, "yes", 2, 14, 1, 2), 

      (0, "male", 22, 4, "no", 5, 12, 4, 5), 

      (0, "female", 22, 1.5, "no", 1, 16, 6, 5), 

      (0, "female", 22, 0.75, "no", 1, 14, 4, 5), 

      (0, "female", 32, 15, "yes", 4, 12, 1, 5), 

      (0, "male", 22, 1.5, "no", 2, 18, 5, 3), 

      (0, "male", 27, 4, "yes", 5, 17, 2, 5), 

      (0, "female", 27, 4, "yes", 4, 12, 1, 5), 

      (0, "male", 42, 15, "yes", 5, 18, 5, 4), 

      (0, "male", 32, 1.5, "no", 2, 20, 7, 3), 

      (0, "male", 57, 15, "no", 4, 9, 3, 1), 

      (0, "male", 37, 7, "no", 4, 18, 5, 5), 

      (0, "male", 52, 15, "yes", 2, 17, 5, 4), 

      (0, "male", 47, 15, "yes", 4, 17, 6, 5), 

      (0, "female", 27, 7, "no", 2, 17, 5, 4), 

      (0, "female", 27, 7, "yes", 4, 14, 5, 5), 

      (0, "female", 22, 4, "no", 2, 14, 3, 3), 

      (0, "male", 37, 7, "yes", 2, 20, 6, 5), 

      (0, "male", 27, 7, "no", 4, 12, 4, 3), 

      (0, "male", 42, 10, "yes", 4, 18, 6, 4), 

      (0, "female", 22, 1.5, "no", 3, 14, 1, 5), 

      (0, "female", 22, 4, "yes", 2, 14, 1, 3), 

      (0, "female", 57, 15, "no", 4, 20, 6, 5), 

      (0, "male", 37, 15, "yes", 4, 14, 4, 3), 

      (0, "female", 27, 7, "yes", 3, 18, 5, 5), 

      (0, "female", 17.5, 10, "no", 4, 14, 4, 5), 

      (0, "male", 22, 4, "yes", 4, 16, 5, 5), 

      (0, "female", 27, 4, "yes", 2, 16, 1, 4), 

      (0, "female", 37, 15, "yes", 2, 14, 5, 1), 

      (0, "female", 22, 1.5, "no", 5, 14, 1, 4), 

      (0, "male", 27, 7, "yes", 2, 20, 5, 4), 

      (0, "male", 27, 4, "yes", 4, 14, 5, 5), 

      (0, "male", 22, 0.125, "no", 1, 16, 3, 5), 

      (0, "female", 27, 7, "yes", 4, 14, 1, 4), 

      (0, "female", 32, 15, "yes", 5, 16, 5, 3), 

      (0, "male", 32, 10, "yes", 4, 18, 5, 4), 

      (0, "female", 32, 15, "yes", 2, 14, 3, 4), 

      (0, "female", 22, 1.5, "no", 3, 17, 5, 5), 

      (0, "male", 27, 4, "yes", 4, 17, 4, 4), 

      (0, "female", 52, 15, "yes", 5, 14, 1, 5), 

      (0, "female", 27, 7, "yes", 2, 12, 1, 2), 

      (0, "female", 27, 7, "yes", 3, 12, 1, 4), 

      (0, "female", 42, 15, "yes", 2, 14, 1, 4), 

      (0, "female", 42, 15, "yes", 4, 14, 5, 4), 

      (0, "male", 27, 7, "yes", 4, 14, 3, 3), 

      (0, "male", 27, 7, "yes", 2, 20, 6, 2), 

      (0, "female", 42, 15, "yes", 3, 12, 3, 3), 

      (0, "male", 27, 4, "yes", 3, 16, 3, 5), 

      (0, "female", 27, 7, "yes", 3, 14, 1, 4), 

      (0, "female", 22, 1.5, "no", 2, 14, 4, 5), 

      (0, "female", 27, 4, "yes", 4, 14, 1, 4), 

      (0, "female", 22, 4, "no", 4, 14, 5, 5), 

      (0, "female", 22, 1.5, "no", 2, 16, 4, 5), 

      (0, "male", 47, 15, "no", 4, 14, 5, 4), 

      (0, "male", 37, 10, "yes", 2, 18, 6, 2), 

      (0, "male", 37, 15, "yes", 3, 17, 5, 4), 

      (0, "female", 27, 4, "yes", 2, 16, 1, 4), 

      (3, "male", 27, 1.5, "no", 3, 18, 4, 4), 

      (3, "female", 27, 4, "yes", 3, 17, 1, 5), 

      (7, "male", 37, 15, "yes", 5, 18, 6, 2), 

      (12, "female", 32, 10, "yes", 3, 17, 5, 2), 

      (1, "male", 22, 0.125, "no", 4, 16, 5, 5), 

      (1, "female", 22, 1.5, "yes", 2, 14, 1, 5), 

      (12, "male", 37, 15, "yes", 4, 14, 5, 2), 

      (7, "female", 22, 1.5, "no", 2, 14, 3, 4), 

      (2, "male", 37, 15, "yes", 2, 18, 6, 4), 

      (3, "female", 32, 15, "yes", 4, 12, 3, 2), 

      (1, "female", 37, 15, "yes", 4, 14, 4, 2), 

      (7, "female", 42, 15, "yes", 3, 17, 1, 4), 

      (12, "female", 42, 15, "yes", 5, 9, 4, 1), 

      (12, "male", 37, 10, "yes", 2, 20, 6, 2), 

      (12, "female", 32, 15, "yes", 3, 14, 1, 2), 

      (3, "male", 27, 4, "no", 1, 18, 6, 5), 

      (7, "male", 37, 10, "yes", 2, 18, 7, 3), 

      (7, "female", 27, 4, "no", 3, 17, 5, 5), 

      (1, "male", 42, 15, "yes", 4, 16, 5, 5), 

      (1, "female", 47, 15, "yes", 5, 14, 4, 5), 

      (7, "female", 27, 4, "yes", 3, 18, 5, 4), 

      (1, "female", 27, 7, "yes", 5, 14, 1, 4), 

      (12, "male", 27, 1.5, "yes", 3, 17, 5, 4), 

      (12, "female", 27, 7, "yes", 4, 14, 6, 2), 

      (3, "female", 42, 15, "yes", 4, 16, 5, 4), 

      (7, "female", 27, 10, "yes", 4, 12, 7, 3), 

      (1, "male", 27, 1.5, "no", 2, 18, 5, 2), 

      (1, "male", 32, 4, "no", 4, 20, 6, 4), 

      (1, "female", 27, 7, "yes", 3, 14, 1, 3), 

      (3, "female", 32, 10, "yes", 4, 14, 1, 4), 

      (3, "male", 27, 4, "yes", 2, 18, 7, 2), 

      (1, "female", 17.5, 0.75, "no", 5, 14, 4, 5), 

      (1, "female", 32, 10, "yes", 4, 18, 1, 5), 

      (7, "female", 32, 7, "yes", 2, 17, 6, 4), 

      (7, "male", 37, 15, "yes", 2, 20, 6, 4), 

      (7, "female", 37, 10, "no", 1, 20, 5, 3), 

      (12, "female", 32, 10, "yes", 2, 16, 5, 5), 

      (7, "male", 52, 15, "yes", 2, 20, 6, 4), 

      (7, "female", 42, 15, "yes", 1, 12, 1, 3), 

      (1, "male", 52, 15, "yes", 2, 20, 6, 3), 

      (2, "male", 37, 15, "yes", 3, 18, 6, 5), 

      (12, "female", 22, 4, "no", 3, 12, 3, 4), 

      (12, "male", 27, 7, "yes", 1, 18, 6, 2), 

      (1, "male", 27, 4, "yes", 3, 18, 5, 5), 

      (12, "male", 47, 15, "yes", 4, 17, 6, 5), 

      (12, "female", 42, 15, "yes", 4, 12, 1, 1), 

      (7, "male", 27, 4, "no", 3, 14, 3, 4), 

      (7, "female", 32, 7, "yes", 4, 18, 4, 5), 

      (1, "male", 32, 0.417, "yes", 3, 12, 3, 4), 

      (3, "male", 47, 15, "yes", 5, 16, 5, 4), 

      (12, "male", 37, 15, "yes", 2, 20, 5, 4), 

      (7, "male", 22, 4, "yes", 2, 17, 6, 4), 

      (1, "male", 27, 4, "no", 2, 14, 4, 5), 

      (7, "female", 52, 15, "yes", 5, 16, 1, 3), 

      (1, "male", 27, 4, "no", 3, 14, 3, 3), 

      (1, "female", 27, 10, "yes", 4, 16, 1, 4), 

      (1, "male", 32, 7, "yes", 3, 14, 7, 4), 

      (7, "male", 32, 7, "yes", 2, 18, 4, 1), 

      (3, "male", 22, 1.5, "no", 1, 14, 3, 2), 

      (7, "male", 22, 4, "yes", 3, 18, 6, 4), 

      (7, "male", 42, 15, "yes", 4, 20, 6, 4), 

      (2, "female", 57, 15, "yes", 1, 18, 5, 4), 

      (7, "female", 32, 4, "yes", 3, 18, 5, 2), 

      (1, "male", 27, 4, "yes", 1, 16, 4, 4), 

      (7, "male", 32, 7, "yes", 4, 16, 1, 4), 

      (2, "male", 57, 15, "yes", 1, 17, 4, 4), 

      (7, "female", 42, 15, "yes", 4, 14, 5, 2), 

      (7, "male", 37, 10, "yes", 1, 18, 5, 3), 

      (3, "male", 42, 15, "yes", 3, 17, 6, 1), 

      (1, "female", 52, 15, "yes", 3, 14, 4, 4), 

      (2, "female", 27, 7, "yes", 3, 17, 5, 3), 

      (12, "male", 32, 7, "yes", 2, 12, 4, 2), 

      (1, "male", 22, 4, "no", 4, 14, 2, 5), 

      (3, "male", 27, 7, "yes", 3, 18, 6, 4), 

      (12, "female", 37, 15, "yes", 1, 18, 5, 5), 

      (7, "female", 32, 15, "yes", 3, 17, 1, 3), 

      (7, "female", 27, 7, "no", 2, 17, 5, 5), 

      (1, "female", 32, 7, "yes", 3, 17, 5, 3), 

      (1, "male", 32, 1.5, "yes", 2, 14, 2, 4), 

      (12, "female", 42, 15, "yes", 4, 14, 1, 2), 

      (7, "male", 32, 10, "yes", 3, 14, 5, 4), 

      (7, "male", 37, 4, "yes", 1, 20, 6, 3), 

      (1, "female", 27, 4, "yes", 2, 16, 5, 3), 

      (12, "female", 42, 15, "yes", 3, 14, 4, 3), 

      (1, "male", 27, 10, "yes", 5, 20, 6, 5), 

      (12, "male", 37, 10, "yes", 2, 20, 6, 2), 

      (12, "female", 27, 7, "yes", 1, 14, 3, 3), 

      (3, "female", 27, 7, "yes", 4, 12, 1, 2), 

      (3, "male", 32, 10, "yes", 2, 14, 4, 4), 

      (12, "female", 17.5, 0.75, "yes", 2, 12, 1, 3), 

      (12, "female", 32, 15, "yes", 3, 18, 5, 4), 

      (2, "female", 22, 7, "no", 4, 14, 4, 3), 

      (1, "male", 32, 7, "yes", 4, 20, 6, 5), 

      (7, "male", 27, 4, "yes", 2, 18, 6, 2), 

      (1, "female", 22, 1.5, "yes", 5, 14, 5, 3), 

      (12, "female", 32, 15, "no", 3, 17, 5, 1), 

      (12, "female", 42, 15, "yes", 2, 12, 1, 2), 

      (7, "male", 42, 15, "yes", 3, 20, 5, 4), 

      (12, "male", 32, 10, "no", 2, 18, 4, 2), 

      (12, "female", 32, 15, "yes", 3, 9, 1, 1), 

      (7, "male", 57, 15, "yes", 5, 20, 4, 5), 

      (12, "male", 47, 15, "yes", 4, 20, 6, 4), 

      (2, "female", 42, 15, "yes", 2, 17, 6, 3), 

      (12, "male", 37, 15, "yes", 3, 17, 6, 3), 

      (12, "male", 37, 15, "yes", 5, 17, 5, 2), 

      (7, "male", 27, 10, "yes", 2, 20, 6, 4), 

      (2, "male", 37, 15, "yes", 2, 16, 5, 4), 

      (12, "female", 32, 15, "yes", 1, 14, 5, 2), 

      (7, "male", 32, 10, "yes", 3, 17, 6, 3), 

      (2, "male", 37, 15, "yes", 4, 18, 5, 1), 

      (7, "female", 27, 1.5, "no", 2, 17, 5, 5), 

      (3, "female", 47, 15, "yes", 2, 17, 5, 2), 

      (12, "male", 37, 15, "yes", 2, 17, 5, 4), 

      (12, "female", 27, 4, "no", 2, 14, 5, 5), 

      (2, "female", 27, 10, "yes", 4, 14, 1, 5), 

      (1, "female", 22, 4, "yes", 3, 16, 1, 3), 

      (12, "male", 52, 7, "no", 4, 16, 5, 5), 

      (2, "female", 27, 4, "yes", 1, 16, 3, 5), 

      (7, "female", 37, 15, "yes", 2, 17, 6, 4), 

      (2, "female", 27, 4, "no", 1, 17, 3, 1), 

      (12, "female", 17.5, 0.75, "yes", 2, 12, 3, 5), 

      (7, "female", 32, 15, "yes", 5, 18, 5, 4), 

      (7, "female", 22, 4, "no", 1, 16, 3, 5), 

      (2, "male", 32, 4, "yes", 4, 18, 6, 4), 

      (1, "female", 22, 1.5, "yes", 3, 18, 5, 2), 

      (3, "female", 42, 15, "yes", 2, 17, 5, 4), 

      (1, "male", 32, 7, "yes", 4, 16, 4, 4), 

      (12, "male", 37, 15, "no", 3, 14, 6, 2), 

      (1, "male", 42, 15, "yes", 3, 16, 6, 3), 

      (1, "male", 27, 4, "yes", 1, 18, 5, 4), 

      (2, "male", 37, 15, "yes", 4, 20, 7, 3), 

      (7, "male", 37, 15, "yes", 3, 20, 6, 4), 

      (3, "male", 22, 1.5, "no", 2, 12, 3, 3), 

      (3, "male", 32, 4, "yes", 3, 20, 6, 2), 

      (2, "male", 32, 15, "yes", 5, 20, 6, 5), 

      (12, "female", 52, 15, "yes", 1, 18, 5, 5), 

      (12, "male", 47, 15, "no", 1, 18, 6, 5), 

      (3, "female", 32, 15, "yes", 4, 16, 4, 4), 

      (7, "female", 32, 15, "yes", 3, 14, 3, 2), 

      (7, "female", 27, 7, "yes", 4, 16, 1, 2), 

      (12, "male", 42, 15, "yes", 3, 18, 6, 2), 

      (7, "female", 42, 15, "yes", 2, 14, 3, 2), 

      (12, "male", 27, 7, "yes", 2, 17, 5, 4), 

      (3, "male", 32, 10, "yes", 4, 14, 4, 3), 

      (7, "male", 47, 15, "yes", 3, 16, 4, 2), 

      (1, "male", 22, 1.5, "yes", 1, 12, 2, 5), 

      (7, "female", 32, 10, "yes", 2, 18, 5, 4), 

      (2, "male", 32, 10, "yes", 2, 17, 6, 5), 

      (2, "male", 22, 7, "yes", 3, 18, 6, 2), 

      (1, "female", 32, 15, "yes", 3, 14, 1, 5))

       

val data = dataList.toDF("affairs", "gender", "age", "yearsmarried", "children", "religiousness", "education", "occupation", "rating")

 

随机森林建模

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

data.createOrReplaceTempView("data")

   

// 字符类型转换成数值 

val labelWhere = "case when affairs=0 then 0 else cast(1 as double) end as label"

val genderWhere = "case when gender='female' then 0 else cast(1 as double) end as gender"

val childrenWhere = "case when children='no' then 0 else cast(1 as double) end as children"

   

val dataLabelDF = spark.sql(s"select $labelWhere, $genderWhere,age,yearsmarried,$childrenWhere,religiousness,education,occupation,rating from data")

   

val featuresArray = Array("gender", "age", "yearsmarried", "children", "religiousness", "education", "occupation", "rating")

   

// 字段转换成特征向量 

val assembler = new VectorAssembler().setInputCols(featuresArray).setOutputCol("features")

val vecDF: DataFrame = assembler.transform(dataLabelDF)

vecDF.show(10, truncate = false)

   

// 将数据分为训练和测试集(30%进行测试)

val Array(trainingDF, testDF) = vecDF.randomSplit(Array(0.7, 0.3))

   

// 索引标签,将元数据添加到标签列中 

val labelIndexer = new StringIndexer().setInputCol("label").setOutputCol("indexedLabel").fit(vecDF)

//labelIndexer.transform(vecDF).show(10, truncate = false)

   

// 自动识别分类的特征,并对它们进行索引 

// 具有大于5个不同的值的特征被视为连续。 

val featureIndexer = new VectorIndexer().setInputCol("features").setOutputCol("indexedFeatures").setMaxCategories(5).fit(vecDF)

//featureIndexer.transform(vecDF).show(10, truncate = false)

   

// 训练随机森林模型

val rf = new RandomForestClassifier().setLabelCol("indexedLabel").setFeaturesCol("indexedFeatures").setNumTrees(10)

   

// 将索引标签转换回原始标签 

val labelConverter = new IndexToString().setInputCol("prediction").setOutputCol("predictedLabel").setLabels(labelIndexer.labels)

   

// Chain indexers and forest in a Pipeline.

val pipeline = new Pipeline().setStages(Array(labelIndexer, featureIndexer, rf, labelConverter))

   

// Train model. This also runs the indexers.

val model = pipeline.fit(trainingDF)

 

// 输出随机森林模型的全部参数值

model.stages(2).extractParamMap()

   

// 作出预测 

val predictions = model.transform(testDF)

   

// Select example rows to display.

predictions.select("predictedLabel", "label", "features").show(10, false)

   

// 选择(预测标签,实际标签),并计算测试误差

val evaluator = new MulticlassClassificationEvaluator().setLabelCol("indexedLabel").setPredictionCol("prediction").setMetricName("accuracy")

val accuracy = evaluator.evaluate(predictions)

println("Test Error = " + (1.0 - accuracy))

   

// 这里的stages(2)中的“2”对应pipeline中的“rf”,将model强制转换为RandomForestClassificationModel类型

val rfModel = model.stages(2).asInstanceOf[RandomForestClassificationModel]

println("Learned classification forest model:\n" + rfModel.toDebugString)

 

代码执行结果

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

vecDF.show(10, truncate = false)

+-----+------+----+------------+--------+-------------+---------+----------+------+------------------------------------+

|label|gender|age |yearsmarried|children|religiousness|education|occupation|rating|features                            |

+-----+------+----+------------+--------+-------------+---------+----------+------+------------------------------------+

|0.0  |1.0   |37.0|10.0        |0.0     |3.0          |18.0     |7.0       |4.0   |[1.0,37.0,10.0,0.0,3.0,18.0,7.0,4.0]|

|0.0  |0.0   |27.0|4.0         |0.0     |4.0          |14.0     |6.0       |4.0   |[0.0,27.0,4.0,0.0,4.0,14.0,6.0,4.0] |

|0.0  |0.0   |32.0|15.0        |1.0     |1.0          |12.0     |1.0       |4.0   |[0.0,32.0,15.0,1.0,1.0,12.0,1.0,4.0]|

|0.0  |1.0   |57.0|15.0        |1.0     |5.0          |18.0     |6.0       |5.0   |[1.0,57.0,15.0,1.0,5.0,18.0,6.0,5.0]|

|0.0  |1.0   |22.0|0.75        |0.0     |2.0          |17.0     |6.0       |3.0   |[1.0,22.0,0.75,0.0,2.0,17.0,6.0,3.0]|

|0.0  |0.0   |32.0|1.5         |0.0     |2.0          |17.0     |5.0       |5.0   |[0.0,32.0,1.5,0.0,2.0,17.0,5.0,5.0] |

|0.0  |0.0   |22.0|0.75        |0.0     |2.0          |12.0     |1.0       |3.0   |[0.0,22.0,0.75,0.0,2.0,12.0,1.0,3.0]|

|0.0  |1.0   |57.0|15.0        |1.0     |2.0          |14.0     |4.0       |4.0   |[1.0,57.0,15.0,1.0,2.0,14.0,4.0,4.0]|

|0.0  |0.0   |32.0|15.0        |1.0     |4.0          |16.0     |1.0       |2.0   |[0.0,32.0,15.0,1.0,4.0,16.0,1.0,2.0]|

|0.0  |1.0   |22.0|1.5         |0.0     |4.0          |14.0     |4.0       |5.0   |[1.0,22.0,1.5,0.0,4.0,14.0,4.0,5.0] |

+-----+------+----+------------+--------+-------------+---------+----------+------+------------------------------------+

only showing top 10 rows

   

// 将数据分为训练和测试集(30%进行测试)

val Array(trainingDF, testDF) = vecDF.randomSplit(Array(0.7, 0.3))

trainingDF: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [label: double, gender: double ... 8 more fields]

testDF: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [label: double, gender: double ... 8 more fields]

   

// 索引标签,将元数据添加到标签列中 

val labelIndexer = new StringIndexer().setInputCol("label").setOutputCol("indexedLabel").fit(vecDF)

labelIndexer: org.apache.spark.ml.feature.StringIndexerModel = strIdx_37df210602df

//labelIndexer.transform(vecDF).show(10, truncate = false)

   

// 自动识别分类的特征,并对它们进行索引 

// 具有大于5个不同的值的特征被视为连续。 

val featureIndexer = new VectorIndexer().setInputCol("features").setOutputCol("indexedFeatures").setMaxCategories(5).fit(vecDF)

featureIndexer: org.apache.spark.ml.feature.VectorIndexerModel = vecIdx_9595c228f520

//featureIndexer.transform(vecDF).show(10, truncate = false)

   

// 训练随机森林模型

val rf = new RandomForestClassifier().setLabelCol("indexedLabel").setFeaturesCol("indexedFeatures").setNumTrees(10)

rf: org.apache.spark.ml.classification.RandomForestClassifier = rfc_d0e7623d0b10

   

// 将索引标签转换回原始标签 

val labelConverter = new IndexToString().setInputCol("prediction").setOutputCol("predictedLabel").setLabels(labelIndexer.labels)

labelConverter: org.apache.spark.ml.feature.IndexToString = idxToStr_32d6938f2c94

   

// Chain indexers and forest in a Pipeline.

val pipeline = new Pipeline().setStages(Array(labelIndexer, featureIndexer, rf, labelConverter))

pipeline: org.apache.spark.ml.Pipeline = pipeline_97716da42fed

   

// Train model. This also runs the indexers.

val model = pipeline.fit(trainingDF)

model: org.apache.spark.ml.PipelineModel = pipeline_97716da42fed

 

// 输出随机森林模型的全部参数值

model.stages(2).extractParamMap()

res10: org.apache.spark.ml.param.ParamMap =

{

    rfc_0d830180d598-cacheNodeIds: false,

    rfc_0d830180d598-checkpointInterval: 10,

    rfc_0d830180d598-featureSubsetStrategy: auto,

    rfc_0d830180d598-featuresCol: indexedFeatures,

    rfc_0d830180d598-impurity: gini,

    rfc_0d830180d598-labelCol: indexedLabel,

    rfc_0d830180d598-maxBins: 32,

    rfc_0d830180d598-maxDepth: 5,

    rfc_0d830180d598-maxMemoryInMB: 256,

    rfc_0d830180d598-minInfoGain: 0.0,

    rfc_0d830180d598-minInstancesPerNode: 1,

    rfc_0d830180d598-predictionCol: prediction,

    rfc_0d830180d598-probabilityCol: probability,

    rfc_0d830180d598-rawPredictionCol: rawPrediction,

    rfc_0d830180d598-seed: 207336481,

    rfc_0d830180d598-subsamplingRate: 1.0

}

 

   

// 作出预测 

val predictions = model.transform(testDF)

predictions: org.apache.spark.sql.DataFrame = [label: double, gender: double ... 14 more fields]

   

predictions.select("predictedLabel", "label", "features").show(10,false)

+--------------+-----+-------------------------------------+

|predictedLabel|label|features                             |

+--------------+-----+-------------------------------------+

|0.0           |0.0  |[0.0,22.0,0.125,0.0,4.0,12.0,4.0,5.0]|

|0.0           |0.0  |[0.0,22.0,0.125,0.0,4.0,14.0,4.0,5.0]|

|0.0           |0.0  |[0.0,22.0,0.417,0.0,1.0,17.0,6.0,4.0]|

|0.0           |0.0  |[0.0,22.0,0.417,0.0,4.0,14.0,5.0,5.0]|

|0.0           |0.0  |[0.0,22.0,0.417,1.0,3.0,14.0,3.0,5.0]|

|0.0           |0.0  |[0.0,22.0,0.75,0.0,5.0,18.0,1.0,5.0] |

|0.0           |0.0  |[0.0,22.0,1.5,0.0,1.0,14.0,1.0,5.0]  |

|0.0           |0.0  |[0.0,22.0,1.5,0.0,4.0,16.0,5.0,3.0]  |

|0.0           |0.0  |[0.0,22.0,1.5,0.0,4.0,17.0,5.0,5.0]  |

|0.0           |0.0  |[0.0,22.0,1.5,1.0,3.0,12.0,1.0,3.0]  |

+--------------+-----+-------------------------------------+

only showing top 10 rows

   

// 选择(预测标签,实际标签),并计算测试误差

val evaluator = new MulticlassClassificationEvaluator().setLabelCol("indexedLabel").setPredictionCol("prediction").setMetricName("accuracy")

evaluator: org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator = mcEval_13a195abc422

   

val accuracy = evaluator.evaluate(predictions)

accuracy: Double = 0.7365591397849462

   

println("Test Error = " + (1.0 - accuracy))

Test Error = 0.26344086021505375

   

// 这里的stages(2)中的“2”对应pipeline中的“rf”,将model强制转换为RandomForestClassificationModel类型

val rfModel = model.stages(2).asInstanceOf[RandomForestClassificationModel]

rfModel: org.apache.spark.ml.classification.RandomForestClassificationModel = RandomForestClassificationModel (uid=rfc_f7bb5e488533) with 10 trees

   

println("Learned classification forest model:\n" + rfModel.toDebugString)

Learned classification forest model:

RandomForestClassificationModel (uid=rfc_f7bb5e488533) with 10 trees

  Tree 0 (weight 1.0):

    If (feature 2 <= 1.5)

     If (feature 5 <= 12.0)

      If (feature 6 <= 1.0)

       Predict: 0.0

      Else (feature 6 > 1.0)

       If (feature 2 <= 0.125)

        Predict: 0.0

       Else (feature 2 > 0.125)

        Predict: 1.0

     Else (feature 5 > 12.0)

      If (feature 0 in {0.0})

       If (feature 5 <= 16.0)

        Predict: 0.0

       Else (feature 5 > 16.0)

        If (feature 1 <= 22.0)

         Predict: 0.0

        Else (feature 1 > 22.0)

         Predict: 0.0

      Else (feature 0 not in {0.0})

       If (feature 2 <= 0.75)

        If (feature 4 in {0.0,1.0,2.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {0.0,1.0,2.0,4.0})

         Predict: 0.0

       Else (feature 2 > 0.75)

        If (feature 1 <= 22.0)

         Predict: 0.0

        Else (feature 1 > 22.0)

         Predict: 1.0

    Else (feature 2 > 1.5)

     If (feature 1 <= 42.0)

      If (feature 1 <= 27.0)

       If (feature 5 <= 16.0)

        If (feature 6 <= 5.0)

         Predict: 0.0

        Else (feature 6 > 5.0)

         Predict: 1.0

       Else (feature 5 > 16.0)

        If (feature 4 in {3.0})

         Predict: 0.0

        Else (feature 4 not in {3.0})

         Predict: 0.0

      Else (feature 1 > 27.0)

       If (feature 4 in {0.0,3.0,4.0})

        If (feature 2 <= 4.0)

         Predict: 1.0

        Else (feature 2 > 4.0)

         Predict: 0.0

       Else (feature 4 not in {0.0,3.0,4.0})

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 1.0

     Else (feature 1 > 42.0)

      If (feature 4 in {2.0,4.0})

       Predict: 0.0

      Else (feature 4 not in {2.0,4.0})

       If (feature 4 in {0.0})

        Predict: 1.0

       Else (feature 4 not in {0.0})

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 0.0

  Tree 1 (weight 1.0):

    If (feature 7 in {0.0,2.0,4.0})

     If (feature 7 in {0.0})

      If (feature 1 <= 42.0)

       If (feature 4 in {1.0})

        Predict: 0.0

       Else (feature 4 not in {1.0})

        Predict: 1.0

      Else (feature 1 > 42.0)

       Predict: 0.0

     Else (feature 7 not in {0.0})

      If (feature 1 <= 17.5)

       If (feature 4 in {3.0})

        Predict: 0.0

       Else (feature 4 not in {3.0})

        Predict: 1.0

      Else (feature 1 > 17.5)

       If (feature 0 in {0.0})

        If (feature 4 in {1.0,3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {1.0,3.0,4.0})

         Predict: 0.0

       Else (feature 0 not in {0.0})

        If (feature 6 <= 2.0)

         Predict: 1.0

        Else (feature 6 > 2.0)

         Predict: 0.0

    Else (feature 7 not in {0.0,2.0,4.0})

     If (feature 3 in {0.0})

      If (feature 5 <= 14.0)

       If (feature 4 in {1.0,3.0})

        Predict: 0.0

       Else (feature 4 not in {1.0,3.0})

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 1.0

      Else (feature 5 > 14.0)

       If (feature 0 in {0.0})

        Predict: 0.0

       Else (feature 0 not in {0.0})

        If (feature 4 in {0.0,2.0,3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {0.0,2.0,3.0,4.0})

         Predict: 1.0

     Else (feature 3 not in {0.0})

      If (feature 5 <= 12.0)

       If (feature 0 in {1.0})

        Predict: 0.0

       Else (feature 0 not in {1.0})

        If (feature 6 <= 1.0)

         Predict: 0.0

        Else (feature 6 > 1.0)

         Predict: 0.0

      Else (feature 5 > 12.0)

       If (feature 4 in {0.0,2.0,3.0,4.0})

        If (feature 1 <= 47.0)

         Predict: 0.0

        Else (feature 1 > 47.0)

         Predict: 1.0

       Else (feature 4 not in {0.0,2.0,3.0,4.0})

        If (feature 1 <= 22.0)

         Predict: 1.0

        Else (feature 1 > 22.0)

         Predict: 0.0

  Tree 2 (weight 1.0):

    If (feature 7 in {0.0})

     If (feature 4 in {1.0})

      Predict: 0.0

     Else (feature 4 not in {1.0})

      If (feature 6 <= 5.0)

       If (feature 1 <= 42.0)

        Predict: 1.0

       Else (feature 1 > 42.0)

        Predict: 0.0

      Else (feature 6 > 5.0)

       Predict: 0.0

    Else (feature 7 not in {0.0})

     If (feature 5 <= 16.0)

      If (feature 7 in {1.0})

       If (feature 6 <= 4.0)

        If (feature 2 <= 7.0)

         Predict: 0.0

        Else (feature 2 > 7.0)

         Predict: 1.0

       Else (feature 6 > 4.0)

        Predict: 1.0

      Else (feature 7 not in {1.0})

       If (feature 3 in {1.0})

        If (feature 1 <= 17.5)

         Predict: 1.0

        Else (feature 1 > 17.5)

         Predict: 0.0

       Else (feature 3 not in {1.0})

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 0.0

     Else (feature 5 > 16.0)

      If (feature 3 in {0.0})

       If (feature 4 in {4.0})

        Predict: 0.0

       Else (feature 4 not in {4.0})

        If (feature 5 <= 18.0)

         Predict: 0.0

        Else (feature 5 > 18.0)

         Predict: 0.0

      Else (feature 3 not in {0.0})

       If (feature 4 in {0.0,3.0,4.0})

        If (feature 7 in {2.0})

         Predict: 0.0

        Else (feature 7 not in {2.0})

         Predict: 0.0

       Else (feature 4 not in {0.0,3.0,4.0})

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 1.0

  Tree 3 (weight 1.0):

    If (feature 3 in {0.0})

     If (feature 7 in {3.0})

      Predict: 0.0

     Else (feature 7 not in {3.0})

      If (feature 2 <= 10.0)

       If (feature 4 in {2.0,3.0,4.0})

        If (feature 4 in {4.0})

         Predict: 0.0

        Else (feature 4 not in {4.0})

         Predict: 0.0

       Else (feature 4 not in {2.0,3.0,4.0})

        If (feature 7 in {0.0,2.0,4.0})

         Predict: 0.0

        Else (feature 7 not in {0.0,2.0,4.0})

         Predict: 1.0

      Else (feature 2 > 10.0)

       Predict: 1.0

    Else (feature 3 not in {0.0})

     If (feature 6 <= 2.0)

      If (feature 5 <= 16.0)

       If (feature 7 in {0.0,1.0,2.0,4.0})

        If (feature 4 in {0.0,1.0,3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {0.0,1.0,3.0,4.0})

         Predict: 1.0

       Else (feature 7 not in {0.0,1.0,2.0,4.0})

        If (feature 1 <= 22.0)

         Predict: 0.0

        Else (feature 1 > 22.0)

         Predict: 0.0

      Else (feature 5 > 16.0)

       If (feature 7 in {0.0,1.0,3.0})

        Predict: 0.0

       Else (feature 7 not in {0.0,1.0,3.0})

        Predict: 1.0

     Else (feature 6 > 2.0)

      If (feature 4 in {0.0,3.0,4.0})

       If (feature 7 in {0.0,2.0,3.0,4.0})

        If (feature 4 in {3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {3.0,4.0})

         Predict: 0.0

       Else (feature 7 not in {0.0,2.0,3.0,4.0})

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 1.0

      Else (feature 4 not in {0.0,3.0,4.0})

       If (feature 1 <= 22.0)

        If (feature 5 <= 14.0)

         Predict: 1.0

        Else (feature 5 > 14.0)

         Predict: 1.0

       Else (feature 1 > 22.0)

        If (feature 6 <= 6.0)

         Predict: 0.0

        Else (feature 6 > 6.0)

         Predict: 1.0

  Tree 4 (weight 1.0):

    If (feature 7 in {0.0,2.0,4.0})

     If (feature 7 in {0.0})

      If (feature 6 <= 5.0)

       If (feature 3 in {0.0})

        Predict: 0.0

       Else (feature 3 not in {0.0})

        If (feature 4 in {2.0,4.0})

         Predict: 1.0

        Else (feature 4 not in {2.0,4.0})

         Predict: 1.0

      Else (feature 6 > 5.0)

       Predict: 0.0

     Else (feature 7 not in {0.0})

      If (feature 2 <= 1.5)

       If (feature 5 <= 12.0)

        If (feature 2 <= 0.125)

         Predict: 0.0

        Else (feature 2 > 0.125)

         Predict: 0.0

       Else (feature 5 > 12.0)

        If (feature 1 <= 17.5)

         Predict: 1.0

        Else (feature 1 > 17.5)

         Predict: 0.0

      Else (feature 2 > 1.5)

       If (feature 2 <= 7.0)

        If (feature 4 in {1.0,3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {1.0,3.0,4.0})

         Predict: 0.0

       Else (feature 2 > 7.0)

        If (feature 5 <= 16.0)

         Predict: 0.0

        Else (feature 5 > 16.0)

         Predict: 0.0

    Else (feature 7 not in {0.0,2.0,4.0})

     If (feature 5 <= 12.0)

      Predict: 0.0

     Else (feature 5 > 12.0)

      If (feature 4 in {0.0,3.0,4.0})

       If (feature 1 <= 47.0)

        If (feature 1 <= 22.0)

         Predict: 0.0

        Else (feature 1 > 22.0)

         Predict: 0.0

       Else (feature 1 > 47.0)

        Predict: 1.0

      Else (feature 4 not in {0.0,3.0,4.0})

       If (feature 1 <= 27.0)

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 0.0

       Else (feature 1 > 27.0)

        If (feature 5 <= 14.0)

         Predict: 1.0

        Else (feature 5 > 14.0)

         Predict: 1.0

  Tree 5 (weight 1.0):

    If (feature 7 in {0.0})

     If (feature 1 <= 42.0)

      If (feature 6 <= 4.0)

       Predict: 1.0

      Else (feature 6 > 4.0)

       If (feature 4 in {1.0})

        Predict: 0.0

       Else (feature 4 not in {1.0})

        Predict: 1.0

     Else (feature 1 > 42.0)

      Predict: 0.0

    Else (feature 7 not in {0.0})

     If (feature 2 <= 1.5)

      If (feature 4 in {0.0,2.0,3.0})

       If (feature 1 <= 22.0)

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 0.0

       Else (feature 1 > 22.0)

        Predict: 0.0

      Else (feature 4 not in {0.0,2.0,3.0})

       If (feature 1 <= 17.5)

        If (feature 6 <= 4.0)

         Predict: 1.0

        Else (feature 6 > 4.0)

         Predict: 0.0

       Else (feature 1 > 17.5)

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 0.0

     Else (feature 2 > 1.5)

      If (feature 6 <= 5.0)

       If (feature 5 <= 17.0)

        If (feature 7 in {2.0,4.0})

         Predict: 0.0

        Else (feature 7 not in {2.0,4.0})

         Predict: 0.0

       Else (feature 5 > 17.0)

        If (feature 6 <= 1.0)

         Predict: 0.0

        Else (feature 6 > 1.0)

         Predict: 0.0

      Else (feature 6 > 5.0)

       If (feature 4 in {0.0,3.0,4.0})

        If (feature 7 in {3.0,4.0})

         Predict: 0.0

        Else (feature 7 not in {3.0,4.0})

         Predict: 0.0

       Else (feature 4 not in {0.0,3.0,4.0})

        If (feature 6 <= 6.0)

         Predict: 0.0

        Else (feature 6 > 6.0)

         Predict: 0.0

  Tree 6 (weight 1.0):

    If (feature 4 in {0.0,3.0,4.0})

     If (feature 5 <= 12.0)

      If (feature 7 in {1.0,2.0,3.0,4.0})

       Predict: 0.0

      Else (feature 7 not in {1.0,2.0,3.0,4.0})

       If (feature 6 <= 3.0)

        Predict: 0.0

       Else (feature 6 > 3.0)

        Predict: 1.0

     Else (feature 5 > 12.0)

      If (feature 7 in {0.0,1.0,2.0})

       If (feature 6 <= 1.0)

        If (feature 7 in {0.0,2.0})

         Predict: 0.0

        Else (feature 7 not in {0.0,2.0})

         Predict: 0.0

       Else (feature 6 > 1.0)

        If (feature 1 <= 37.0)

         Predict: 1.0

        Else (feature 1 > 37.0)

         Predict: 0.0

      Else (feature 7 not in {0.0,1.0,2.0})

       If (feature 1 <= 17.5)

        If (feature 4 in {3.0})

         Predict: 0.0

        Else (feature 4 not in {3.0})

         Predict: 1.0

       Else (feature 1 > 17.5)

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 0.0

    Else (feature 4 not in {0.0,3.0,4.0})

     If (feature 7 in {0.0,4.0})

      If (feature 5 <= 12.0)

       If (feature 2 <= 0.125)

        Predict: 0.0

       Else (feature 2 > 0.125)

        If (feature 1 <= 17.5)

         Predict: 1.0

        Else (feature 1 > 17.5)

         Predict: 0.0

      Else (feature 5 > 12.0)

       If (feature 7 in {0.0})

        If (feature 1 <= 42.0)

         Predict: 1.0

        Else (feature 1 > 42.0)

         Predict: 0.0

       Else (feature 7 not in {0.0})

        If (feature 2 <= 1.5)

         Predict: 0.0

        Else (feature 2 > 1.5)

         Predict: 0.0

     Else (feature 7 not in {0.0,4.0})

      If (feature 6 <= 4.0)

       If (feature 7 in {3.0})

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 0.0

       Else (feature 7 not in {3.0})

        If (feature 5 <= 16.0)

         Predict: 0.0

        Else (feature 5 > 16.0)

         Predict: 1.0

      Else (feature 6 > 4.0)

       If (feature 6 <= 6.0)

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 1.0

       Else (feature 6 > 6.0)

        If (feature 5 <= 18.0)

         Predict: 1.0

        Else (feature 5 > 18.0)

         Predict: 0.0

  Tree 7 (weight 1.0):

    If (feature 7 in {0.0,2.0,4.0})

     If (feature 2 <= 1.5)

      If (feature 4 in {1.0,2.0,3.0})

       If (feature 1 <= 17.5)

        Predict: 1.0

       Else (feature 1 > 17.5)

        Predict: 0.0

      Else (feature 4 not in {1.0,2.0,3.0})

       If (feature 5 <= 14.0)

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 1.0

       Else (feature 5 > 14.0)

        Predict: 0.0

     Else (feature 2 > 1.5)

      If (feature 7 in {0.0,2.0})

       If (feature 4 in {1.0,3.0,4.0})

        If (feature 5 <= 16.0)

         Predict: 0.0

        Else (feature 5 > 16.0)

         Predict: 0.0

       Else (feature 4 not in {1.0,3.0,4.0})

        If (feature 6 <= 5.0)

         Predict: 1.0

        Else (feature 6 > 5.0)

         Predict: 0.0

      Else (feature 7 not in {0.0,2.0})

       If (feature 4 in {0.0,1.0,3.0})

        If (feature 1 <= 42.0)

         Predict: 0.0

        Else (feature 1 > 42.0)

         Predict: 0.0

       Else (feature 4 not in {0.0,1.0,3.0})

        If (feature 5 <= 16.0)

         Predict: 0.0

        Else (feature 5 > 16.0)

         Predict: 0.0

    Else (feature 7 not in {0.0,2.0,4.0})

     If (feature 2 <= 0.75)

      Predict: 0.0

     Else (feature 2 > 0.75)

      If (feature 4 in {4.0})

       If (feature 6 <= 5.0)

        If (feature 1 <= 37.0)

         Predict: 1.0

        Else (feature 1 > 37.0)

         Predict: 0.0

       Else (feature 6 > 5.0)

        Predict: 0.0

      Else (feature 4 not in {4.0})

       If (feature 5 <= 12.0)

        If (feature 1 <= 27.0)

         Predict: 0.0

        Else (feature 1 > 27.0)

         Predict: 0.0

       Else (feature 5 > 12.0)

        If (feature 7 in {1.0})

         Predict: 1.0

        Else (feature 7 not in {1.0})

         Predict: 0.0

  Tree 8 (weight 1.0):

    If (feature 5 <= 16.0)

     If (feature 4 in {0.0,1.0})

      If (feature 0 in {0.0})

       If (feature 2 <= 0.75)

        If (feature 1 <= 17.5)

         Predict: 1.0

        Else (feature 1 > 17.5)

         Predict: 0.0

       Else (feature 2 > 0.75)

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 0.0

      Else (feature 0 not in {0.0})

       If (feature 5 <= 12.0)

        Predict: 1.0

       Else (feature 5 > 12.0)

        If (feature 7 in {2.0,4.0})

         Predict: 0.0

        Else (feature 7 not in {2.0,4.0})

         Predict: 0.0

     Else (feature 4 not in {0.0,1.0})

      If (feature 7 in {0.0,2.0,3.0,4.0})

       If (feature 1 <= 22.0)

        If (feature 6 <= 3.0)

         Predict: 0.0

        Else (feature 6 > 3.0)

         Predict: 0.0

       Else (feature 1 > 22.0)

        If (feature 6 <= 6.0)

         Predict: 0.0

        Else (feature 6 > 6.0)

         Predict: 1.0

      Else (feature 7 not in {0.0,2.0,3.0,4.0})

       If (feature 1 <= 42.0)

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 1.0

       Else (feature 1 > 42.0)

        Predict: 0.0

    Else (feature 5 > 16.0)

     If (feature 5 <= 18.0)

      If (feature 4 in {3.0})

       If (feature 7 in {1.0,2.0,3.0})

        Predict: 0.0

       Else (feature 7 not in {1.0,2.0,3.0})

        If (feature 6 <= 5.0)

         Predict: 0.0

        Else (feature 6 > 5.0)

         Predict: 0.0

      Else (feature 4 not in {3.0})

       If (feature 2 <= 0.75)

        Predict: 0.0

       Else (feature 2 > 0.75)

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 1.0

     Else (feature 5 > 18.0)

      If (feature 1 <= 27.0)

       If (feature 7 in {3.0})

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 1.0

       Else (feature 7 not in {3.0})

        If (feature 2 <= 4.0)

         Predict: 0.0

        Else (feature 2 > 4.0)

         Predict: 1.0

      Else (feature 1 > 27.0)

       If (feature 6 <= 5.0)

        If (feature 6 <= 4.0)

         Predict: 0.0

        Else (feature 6 > 4.0)

         Predict: 0.0

       Else (feature 6 > 5.0)

        If (feature 4 in {3.0,4.0})

         Predict: 0.0

        Else (feature 4 not in {3.0,4.0})

         Predict: 0.0

  Tree 9 (weight 1.0):

    If (feature 5 <= 16.0)

     If (feature 6 <= 2.0)

      If (feature 1 <= 42.0)

       If (feature 6 <= 1.0)

        If (feature 5 <= 9.0)

         Predict: 1.0

        Else (feature 5 > 9.0)

         Predict: 0.0

       Else (feature 6 > 1.0)

        If (feature 1 <= 27.0)

         Predict: 0.0

        Else (feature 1 > 27.0)

         Predict: 1.0

      Else (feature 1 > 42.0)

       Predict: 0.0

     Else (feature 6 > 2.0)

      If (feature 1 <= 27.0)

       If (feature 5 <= 14.0)

        If (feature 6 <= 3.0)

         Predict: 0.0

        Else (feature 6 > 3.0)

         Predict: 0.0

       Else (feature 5 > 14.0)

        Predict: 0.0

      Else (feature 1 > 27.0)

       If (feature 4 in {1.0,2.0,4.0})

        If (feature 5 <= 9.0)

         Predict: 0.0

        Else (feature 5 > 9.0)

         Predict: 0.0

       Else (feature 4 not in {1.0,2.0,4.0})

        If (feature 7 in {2.0,3.0,4.0})

         Predict: 0.0

        Else (feature 7 not in {2.0,3.0,4.0})

         Predict: 1.0

    Else (feature 5 > 16.0)

     If (feature 6 <= 4.0)

      If (feature 4 in {3.0})

       Predict: 0.0

      Else (feature 4 not in {3.0})

       If (feature 1 <= 42.0)

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 0.0

       Else (feature 1 > 42.0)

        Predict: 1.0

     Else (feature 6 > 4.0)

      If (feature 4 in {3.0,4.0})

       If (feature 1 <= 37.0)

        If (feature 3 in {0.0})

         Predict: 0.0

        Else (feature 3 not in {0.0})

         Predict: 0.0

       Else (feature 1 > 37.0)

        If (feature 1 <= 42.0)

         Predict: 0.0

        Else (feature 1 > 42.0)

         Predict: 0.0

      Else (feature 4 not in {3.0,4.0})

       If (feature 4 in {0.0,2.0})

        If (feature 7 in {0.0,1.0,2.0})

         Predict: 1.0

        Else (feature 7 not in {0.0,1.0,2.0})

         Predict: 1.0

       Else (feature 4 not in {0.0,2.0})

        If (feature 0 in {0.0})

         Predict: 0.0

        Else (feature 0 not in {0.0})

         Predict: 0.0

 

随机森林模型调优

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

// 字段转换成特征向量

val assembler = new VectorAssembler().setInputCols(featuresArray).setOutputCol("features")

val vecDF: DataFrame = assembler.transform(dataLabelDF)

vecDF.show(10, truncate = false)

 

// 将数据分为训练和测试集(30%进行测试)

val Array(trainingDF, testDF) = vecDF.randomSplit(Array(0.7, 0.3))

 

// 索引标签,将元数据添加到标签列中

val labelIndexer = new StringIndexer().setInputCol("label").setOutputCol("indexedLabel").fit(vecDF)

//labelIndexer.transform(vecDF).show(10, truncate = false)

 

// 自动识别分类的特征,并对它们进行索引

// 具有大于5个不同的值的特征被视为连续。

val featureIndexer = new VectorIndexer().setInputCol("features").setOutputCol("indexedFeatures").setMaxCategories(5).fit(vecDF)

//featureIndexer.transform(vecDF).show(10, truncate = false)

 

// 训练随机森林模型

val rf = new RandomForestClassifier().setLabelCol("indexedLabel").setFeaturesCol("indexedFeatures")

 

// 将索引标签转换回原始标签

val labelConverter = new IndexToString().setInputCol("prediction").setOutputCol("predictedLabel").setLabels(labelIndexer.labels)

 

// Chain indexers and forest in a Pipeline.

val pipeline = new Pipeline().setStages(Array(labelIndexer, featureIndexer, rf, labelConverter))

 

// 设置参数网格

//impurity  不纯度

//maxBins  离散化"连续特征"的最大划分数

//maxDepth  树的最大深度

//minInfoGain 一个节点分裂的最小信息增益,值为[0,1]

//minInstancesPerNode 每个节点包含的最小样本数 >=1

//numTrees 树的数量

//featureSubsetStrategy // 在每个树节点处分割的特征数,参数值比较多,详细的请参考官方文档

//SubsamplingRate(1.0)  给每棵树分配“学习数据”的比例,范围(0, 1]

//maxMemoryInMB  如果太小,则每次迭代将拆分1个节点,其聚合可能超过此大小。

//checkpointInterval  设置检查点间隔(> = 1)或禁用检查点(-1)。 例如 10意味着,每10次迭代,缓存将获得检查点。

//cacheNodeIds  如果为false,则算法将树传递给执行器以将实例与节点匹配。 如果为true,算法将缓存每个实例的节点ID。 缓存可以加速更大深度的树的训练。 用户可以通过设置checkpointInterval来设置检查或禁用缓存的频率。(default = false)

//seed 种子

val paramGrid = new ParamGridBuilder()

  .addGrid(rf.impurity, Array("entropy", "gini"))

  .addGrid(rf.maxBins, Array(32, 64))

  .addGrid(rf.maxDepth, Array(5, 7, 10))

  .addGrid(rf.minInfoGain, Array(0, 0.5, 1))

  .addGrid(rf.minInstancesPerNode, Array(10, 20))

  .addGrid(rf.numTrees, Array(20, 50))

  .addGrid(rf.featureSubsetStrategy, Array("auto", "sqrt"))

  .addGrid(rf.subsamplingRate, Array(0.8, 1))

  .addGrid(rf.maxMemoryInMB, Array(256, 512))

  .addGrid(rf.checkpointInterval, Array(10, 20))

  .addGrid(rf.cacheNodeIds, Array(false, true))

  .addGrid(rf.seed, Array(123456L, 111L))

  .build()

 

// 选择(预测标签,实际标签),并计算测试误差。indexedLabel与prediction都是索引化的,因此可以直接比较

val classEvaluator = new MulticlassClassificationEvaluator().setLabelCol("indexedLabel").setPredictionCol("prediction").setMetricName("accuracy")

 

// 设置交叉验证

val cv = new CrossValidator().setEstimator(pipeline).setEvaluator(classEvaluator).setEstimatorParamMaps(paramGrid).setNumFolds(5)

 

// 执行交叉验证,并选择出最好的参数集合

val cvModel = cv.fit(trainingDF)

 

 

// 查看全部参数

cvModel.extractParamMap()

// cvModel.avgMetrics.length=cvModel.getEstimatorParamMaps.length

// cvModel.avgMetrics与cvModel.getEstimatorParamMaps中的元素一一对应

cvModel.avgMetrics.length

cvModel.avgMetrics // 参数对应的平均度量

 

cvModel.getEstimatorParamMaps.length

cvModel.getEstimatorParamMaps // 参数组合的集合

 

 

cvModel.getEvaluator.extractParamMap() // 评估的参数

 

cvModel.getEvaluator.isLargerBetter // 评估的度量值是大的好,还是小的好 ,根据评估度量,系统会自动识别

cvModel.getNumFolds // 交叉验证的折数

 

//################################

// 测试模型

val predictDF: DataFrame = cvModel.transform(testDF).selectExpr(

  //"race","poverty","smoke","alcohol","agemth","ybirth","yschool","pc3mth", "features",

  "predictedLabel", "label", "features")

predictDF.show(20, false)

 

本文转载自:http://www.cnblogs.com/wwxbi/p/6222356.html

共有 人打赏支持
hblt-j
粉丝 14
博文 92
码字总数 11113
作品 0
海淀
架构师
随机森林库--RF.go

在机器学习中,随机森林是一个包含多个决策树的分类器, 并且其输出的类别是由个别树输出的类别的众数而定。 Leo Breiman和Adele Cutler发展出推论出随机森林的算法。 而 "Random Forests" 是...

fxsjy ⋅ 2012/11/15 ⋅ 0

随机森林的泛化能力你给说说?

面试中问到随机森林模型都会说到模型的泛化能力比较好,但是为什么比较好呢,笔者在面美团的时候被问到,当时说的是因为随机森林的采样在样本随机性以及特征随机性上的随机保证了泛化能力,但...

李理 ⋅ 2017/11/04 ⋅ 0

机器学习预测2018年世界杯冠军队

参与文末话题讨论,每日赠送异步图书 ——异步小编 麻省理工学院报道,他们开发了一种新型人工智能,用以预测世界杯走势。而应用了一种名为random-forest的计算方法,通过结合机器自我学习和...

异步社区 ⋅ 06/19 ⋅ 0

随机森林入门

Random forest is a highly versatile machine learning method with numerous applications ranging from marketing to healthcare and insurance. It can be used to model the impact of ......

AC-carrot ⋅ 2016/06/03 ⋅ 0

[导读]不平衡数据的解决之道

概述 作者以募捐数据(正例:负例 < 1:20)为例,通过一系列实验比较了不平衡数据的多种处理方法。 如果不做任何处理,用随机森林可以达到97%的准确率,但实际上存在很多的false positives和f...

我爱机器学习 ⋅ 2016/10/07 ⋅ 0

mahout 算法集

本人博客开始迁移,博客整个架构自己搭建及编码http://www.cookqq.com/listBlog.action 算法类 算法名 中文名 分类算法 Logistic Regression 逻辑回归 Bayesian 贝叶斯 SVM 支持向量机 Perc...

cookqq ⋅ 2014/01/23 ⋅ 0

mahout基于用户推荐的简单例子(1)

mahout是机器学习的一个工具,里面封装了大量的机器学习的算法。 在Mahout实现的机器学习算法: 算法类 算法名 中文名 分类算法 Logistic Regression 逻辑回归 Bayesian 贝叶斯 SVM 支持向量...

刘新全 ⋅ 2016/01/04 ⋅ 0

疏而不漏:随机森林

本文作者:伯乐在线 -翱翔的翱 。未经作者许可,禁止转载! 欢迎加入伯乐在线专栏作者。 一、概述 在三生万物:决策树中我们提到当决策树和装袋法(Bagging)和提升法(Boosting)结合后会成为更...

伯乐在线 ⋅ 2017/11/24 ⋅ 0

Apache Mahout中的机器学习算法集

Apache Mahout中的机器学习算法集 Apache Mahout 是 ApacheSoftware Foundation (ASF) 旗下的一个开源项目,提供一些可扩展的机器学习领域经典算法的实现,旨在帮助开发人员更加方便快捷地创...

yuzh ⋅ 2012/12/27 ⋅ 0

Python机器学习(sklearn)——分类模型评估与调参总结(下)

前文传送门: Python机器学习(sklearn)——分类模型评估与调参总结(上) 21. 集成方法有随机森林(random forest)和梯度提升树(gradient boosted decision tree)GBDT 随机森林中树的随...

ID王大伟 ⋅ 06/03 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

看东方明珠新媒体如何基于阿里视频云,构建完整的视频OTT平台SaaS服务

摘要: 东方明珠新媒体如何基于阿里云,搭建了面向第三方的视频SaaS服务?6月8日,上海云栖大会视频专场中,东方明珠新媒体股份有限公司云计算中心的副总周少毅带来了《东方明珠视频云》为题...

阿里云云栖社区 ⋅ 18分钟前 ⋅ 0

C#调用WebService实例和开发 VS2013

简单的理解就是:webservice就是放在服务器上的函数,所有人都可以调用,然后返回信息。 Web Service的主要目标是跨平台的可互操作性。为了实现这一目标,Web Service 完全基于XML(可扩展标...

布衣大侠 ⋅ 21分钟前 ⋅ 0

基于FlumeNG+Kafka+ElasticSearch+Kibana的日志系统

环境准备 1.服务器概览 hostname ip 操作系统 说明 安装内容 node1.fek 192.168.2.161 centos 7 node1节点 nginx,jdk1.8, flumeNG, elasticsearch slave1 node2.fek 192.168.2.162 centos ......

张shieppp ⋅ 21分钟前 ⋅ 0

问答网站已成过去,深度问答社区才是当下

曾几何时,各类问答网站数不胜数,从百度知道这类综合型问答网站到各种垂直细分的问答网站,都有不少,但到了移动互联网时代,很明显的一大趋势是,网站整体的流量都在下滑,随着移动智能设备...

ThinkSNS账号 ⋅ 24分钟前 ⋅ 0

Android平台架构(ART)

Android平台架构(ART) 本文目的:准确表述Android平台架构 本文转载自[Android官网] 本文定位:学习笔记 学习过程记录,加深理解。也希望能给学习的同学一些灵感 本文更新时间:2018.06.22(...

lichuangnk ⋅ 26分钟前 ⋅ 0

看东方明珠新媒体如何基于阿里视频云,构建完整的视频OTT平台SaaS服务

摘要: 东方明珠新媒体如何基于阿里云,搭建了面向第三方的视频SaaS服务?6月8日,上海云栖大会视频专场中,东方明珠新媒体股份有限公司云计算中心的副总周少毅带来了《东方明珠视频云》为题...

猫耳m ⋅ 28分钟前 ⋅ 0

Java 动态代理 原理解析

概要 AOP的拦截功能是由java中的动态代理来实现的。说白了,就是在目标类的基础上增加切面逻辑,生成增强的目标类(该切面逻辑或者在目标类函数执行之前,或者目标类函数执行之后,或者在目标...

轨迹_ ⋅ 30分钟前 ⋅ 0

js 获取当前时间

var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1970-????)myDate.getMonth(); //获取当前月份(0-11,0代表1月)myDate...

夜醒者 ⋅ 36分钟前 ⋅ 0

windows删除或修改本地Git保存的账号密码

在win10或者win7都是一样的步骤: (一)进入控制面板(二)选择用户账户(三)选择管理你的凭据(四)选择Windows凭据(五)选择git保存的用户信息(六)选择编辑或者进...

果树啊 ⋅ 36分钟前 ⋅ 0

8个基本的Docker容器管理命令

前言: 在这篇文章中,我们将带你学习 8 个基本的 Docker 容器命令,它们操控着 Docker 容器的基本活动,例如 运行run、 列举list、 停止stop、 查看历史纪录logs、 删除delete 等等。文末福...

java高级架构牛人 ⋅ 38分钟前 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部