Statistics and Linear Algebra 1

Posted 阿难的机器学习计划

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Statistics and Linear Algebra 1相关的知识,希望对你有一定的参考价值。

1. Add a value to each element in a list:

  degrees_zero = [f + 459.67 for f in fahrenheit_degrees]

2. Assign the index of a list into the list:

  survey_responses = ["none", "some", "a lot", "none", "a few", "none", "none"]

  survey_scale = ["none", "a few", "some", "a lot"]

  survey_numbers = [survey_scale.index(response) for response in survey_responses]

  average_smoking = sum(smoke_dic)/len(smoke_dic)

3. Categorize scales: here we need to filter gender list into categorizes and find the corresponse saving.  

  gender = ["male", "female", "female", "male", "male", "female"]
  savings = [1200, 5000, 3400, 2400, 2800, 4100]

//////////////////////////////////Solutions one////////////////////////////////////////

  male_saving_list = []

  for i in range(len(gender)):
    if gender[i] == "male":
      male_saving_list.append(savings[i])
      male_savings = sum(male_savings_list)/ len(male_savings_list)

//////////////////////////////////Solutions two////////////////////////////////////////

  female_saving_list = [savings[i] for i in range(len(gender)) if gender[i] == "female"] # Here we use square bracket to replace append function. savings[i] is the value we want, if conditions have to follow the for loop like solution one.
  female_savings = sum(female_saving_list)/len(female_saving_list)

4. 

以上是关于Statistics and Linear Algebra 1的主要内容,如果未能解决你的问题,请参考以下文章

Statistics and Linear Algebra 5

Statistics and Linear Algebra 6

Statistics and Linear Algebra 2

Statistics and Linear Algebra 3

The implementation and experimental research on an S-curve acceleration and deceleration control alg

Statistics gathering and SQL Tuning Advisor