Is Tesla overvalued? How to do stock valuation with machine learning.

The answer is yes, of course.

Over the course of 2020, the price of Tesla stock increased from $88 to $705 (~720%). This is despite revenue and earnings increasing only 39% and 73%, respectively. While the Tesla company is unquestionably impressive, these price gains seem excessive.

I’m going to make a bold and specific claim. On January 4th, 2021, when TSLA was selling for $730, it was fundamentally overvalued by 12.35x. In other words, Tesla’s closing price should have been about $59.

How can I claim this? I trained a machine learning model to predict stock prices.

Model basic anatomy

  • Input variables (Xs): A total of 16 different financial figures for each company, pulled from the last quarterly filing (10Q). Think income, revenue, assets, dividends-paid, revenue-growth, etc.
  • Output variable (Y): Market cap. This is the stock price multiplied by the number of shares outstanding. You can think of the market cap as the price to buy the entire company. Tesla’s market cap is currently about $700 billion.

In the sections below, I will detail what stock valuation is, how I designed my model, its weaknesses, and my results. To see just the data science, skip to the “ Model Design” section.

Conventional stock valuation

How do you identify an undervalued stock?

Price/Earnings (P/E)

Earnings vs. Market Cap. TSLA is red.

Price/Sales (P/S)

Sales vs. Market Cap. TSLA is red.

Price/Book (P/B)

Book Value vs. Market Cap. TSLA is red.

Dividend yield

Dividend Yield vs. Market Cap. TSLA is red.

The problem with valuation ratios

TSLA figures from MorningStar. S&P 500 figures from multpl.

Leaving aside the possibility that Tesla is infinity-times overpriced, these figures suggest that TSLA costs between 11x and 37x what it is rationally worth. But which ratio is the appropriate one for understanding Tesla? The answer is none of the above. A fair valuation of Tesla is a factor of more than its earnings or sales or assets. At the very least, for a company like Tesla, we need to take its growth into account. More generally, any company’s underlying value is a factor of a thousand different things.

In the previous century, before computers, valuation ratios were the only reasonable way to do stock valuation. In that era, investors would look at several valuation ratios, decide whether a stock price felt “fair”, and trade accordingly.

With increasing computerization, many professionals now de-emphasize valuation ratios. Instead, they are deploying increasingly sophisticated multivariate models. Amateur investors, unfortunately, have not had the same opportunity. Most of the “odd-lotter” class, myself included, have had no choice but to use antiquated tools.

While it’s unlikely that amateur investors could ever catch up to the professionals, we can certainly get better. Hypothetically, most information that would impact underlying valuation exists in a company’s financial statements. The task then is to find a way to aggregate that information into a usable number. This is where machine learning comes in.

Model Design


For the market caps, I used the free (and deprecated) Yahoo finance API.

Algorithm selection

  • Linear regression
  • Polynomial regression
  • Linear SVMs
  • Decision trees
  • Neural networks

Stock price estimation is a complex problem. As such, my initial tests with simple linear/polynomial regression didn’t go well. Linear SVMs were also unsuccessful. With decision trees (specifically XGBoost) and neural networks, I finally found some success. Overall, XGBoost performed somewhat better. With time, I think I could have designed a neural network with better performance than XGBoost. But, when taking into account how slow neural networks are to train, XGBoost was the obvious best choice.

Model inputs

  1. Lack of consistency: Apart from a handful of top-line items like revenue, earnings, and assets, companies are surprisingly different in what they choose to report and how they choose to calculate their figures.
  2. Overfitting: Overfitting is more likely when there is a limited dataset. My dataset only contained 1407 individual data points.

So given lots of financial figures and a small dataset, I needed to select a handful of “most important” figures as inputs. To do this, I started by training a model with as many figures as I could — in my case about 60. This initial model was deeply overfit — which was easy to detect. In its simplest definition, overfitting is when the test error is high relative to the training error.

To step down from 60 to 59 inputs, I utilized the “feature importance” metric of the XGBoost model. This provides a ranked list of features by importance. I removed the “least important” feature and retrained. I continued doing this until I minimized the test error at 16 inputs — listed below:


  • Algorithm: XGBoost in a 100-model ensemble
  • Runs: 100 random test/train splits
  • Average test r²: 0.95

Below is a table of a few select stocks:

Overall, the output feels correct. Tesla, the namesake of this article, is the most overvalued stock. At the other end, the model identifies boring/struggling companies like Bank of America and CVS as undervalued.

I’ve been calling the ratio between the real price and the price estimate the “Fundamental Fitted Estimate Ratio” or FFER. Calculating this ratio is an ongoing project. The current calculations for several hundred stocks, updated daily, can be found at

Problems with the model / next steps

  1. More data != better results: While we’re using the S&P 1500 stocks for the dataset, we would like to use the 6000+ stocks from the US market (NYSE + Nasdaq). However, attempting to use this larger dataset throws off the model. Our hypothesis is that S&P selects their index constituents partially for the rationality of their market caps. However, a good stock valuation model should be able to predict any market cap.
  2. Model jitter: Given that financial fundamentals only change once-per-quarter, price estimates also shouldn’t swing much day-to-day. However, because the market caps change, the model itself also tends to swing. We think this is partially explained by XGBoost, which is a decision tree algorithm. Decision tree algorithms have a reputation for being more “touchy” like this. The problem might be remedied with a different algorithm or by averaging market caps over several days/weeks.
  3. Better explainability: While the model has a high r², the input dimensions are somewhat discordant. Some are absolute values, others are ratios, others seem like repeats. Missing, but not for lack of effort, are any input dimensions that capture the “acceleration” of a company — e.g. the change of the change.

So should I buy Tesla stock?

Scott Rogowski co-publishes the FFER— a daily table of ML-derived stock valuations.

Author of mongita & code2flow. Working on FFER & fastmap.