Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:28:09+00:00 2026-05-27T14:28:09+00:00

I trained a random forest: model <- randomForest(x, y, proximity=TRUE) When I want to

  • 0

I trained a random forest:

model <- randomForest(x, y, proximity=TRUE)

When I want to predict y for new objects, I use

y_pred <- predict(model, xnew)

How can I calculate the proximity between the new objects (xnew) and the training set (x) based on the already existing forest (model)?
The proximity option in the predict function gives only the proxmities among the new objects (xnew). I could run randomForest unsupervised again on a combined data set (x and xnew) to get the proximities, but I think there must be some way to avoid building the forest again and instead using the already existing one.

Thanks!
Kilian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:28:10+00:00Added an answer on May 27, 2026 at 2:28 pm

    I believe what you want is to specify your test observations in the randomForest call itself, something like this:

    set.seed(71)
    ind <- sample(1:150,140,replace = FALSE)
    train <- iris[ind,]
    test <- iris[-ind,]
    
    iris.rf1 <- randomForest(x = train[,1:4],
                             y = train[,5],
                             xtest = test[,1:4],
                             ytest = test[,5], 
                             importance=TRUE,
                             proximity=TRUE)
    
    dim(iris.rf1$test$prox)
    [1]  10 150
    

    So that gives you the proximity from the ten test cases to all 150.

    The only other option would be to call predict on your new case rbinded to the original training cases, I think. But that way you don’t need to have your test cases up front with the randomForest call.

    In that case, you’ll want to use keep.forest = TRUE in the randomForest call and of course set proximity = TRUE when you call predict.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any free/open source OCR available that can be trained for new symbols
I'm not trained in Linux, but I can muddle through with some doc lookups,
Using kernlab I've trained a model with code like the following: my.model <- ksvm(result
I have a trained and pickled NLTK tagger (Brill's transformational rule-based tagger). I want
I have a trained dataset with 125 records. I'm going to classify new instance
I am trying to use the pretrained parsing model for English of the MaltParser
I have trained xor neural network in MATLAB and got these weights: iw: [-2.162
I am a beginner SQL user (not formally trained; OJT only) and need some
I have successfully trained a classifier (bayesnet) and constructed a test set (ARFF-format), which
I am currently working on an application in WPF/C# for personal use. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.