0

I need to predict the level of a certain index for a country (Scale of 1-100) which is the target feature based on 5 macro-economic and social features/indicators ( Life expectancy , infant mortality , % of GDP spent on military etc )

I need to use 3-nearest neighbor prediction model & weighted k-nn

I also need to predict after range normalization.

Im looking for some ideas on how I could achieve this in python

Thanks

5
  • 1
    Why do you want to avoid using scikit for this? Commented Apr 15, 2020 at 10:11
  • 2
    What have you tried so far? Also kindly asking: Is this for an assignment of somekind? Commented Apr 15, 2020 at 10:11
  • Also, do you know how the weighted knn and the manhattan distance work. And what kind of normalization do you want? Please add more details to the question Commented Apr 15, 2020 at 10:14
  • yes the requirement is specific. Im getting started in python so really dont have any direction at the moment . any suggestions would be welcome Commented Apr 15, 2020 at 10:15
  • yes i know how they work. standard or min-max normalization should be fine. Commented Apr 15, 2020 at 10:17

1 Answer 1

0

I think you should start by doing this with scikit-learn and get is to work.

Then you should work on a function for the manhattan distance, so just:

def dist_manhattan(point1, point2):
    ...

If you got this you need to implement your normalization function:

def normalize(dataset):
    ...

and then you can implement your weighted knn, like a function

def w_knn(dataset):
    ...

and if you have general struggel with python, I would suggest reading some books about it or watching/reading tutorials.

Sign up to request clarification or add additional context in comments.

2 Comments

so i was able to work with lists to find the CPI for russia using manhattan distance without normalization i now need to normalize the data before i need to find the Manhattan distance between the parameters for the countries against Russia so the thing is i need to normalize column wise (the parameters) and then i need to find the manhattan distance row wise any idea on how this could be achieved becuase it some point I think I will have to flip the data frame or if working with lists how can i get the first values from the 5 columns (lists) into 16 lists with 5 values each ?
@axel_p take a look at this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.